3 /* <project_name> -- <project_description>
5 * Copyright (C) 2006 - 2007
6 * Giuseppe Coviello <cjg@cruxppc.org>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 static context_t
*context
= NULL
;
27 void context_init(context_t
* ctx
)
32 inline context_t
*context_get(void)
37 /* terminal IO functions */
40 return context
->c_getc();
44 static char *scan_list
[7] = {
54 /* devices functions */
55 inline void *get_scan_list(void)
57 if (strncmp(((char**)context
->c_scan_list
)[0], "boot2", 5) == 0)
59 return context
->c_scan_list
;
62 inline list_t
*get_devices_list(void)
64 return context
->c_devices_list
;
67 inline SCAN_HANDLE
get_curr_device(void)
69 return context
->c_curr_device
;
72 inline SCAN_HANDLE
start_unit_scan(const void *scan_list
,
73 uint32_t * const blocksize
)
75 return context
->c_start_unit_scan(scan_list
, blocksize
);
78 inline SCAN_HANDLE
next_unit_scan(SCAN_HANDLE h
, unsigned int *const blocksize
)
80 return context
->c_next_unit_scan(h
, blocksize
);
83 inline int open_specific_unit(const SCAN_HANDLE h
)
85 return context
->c_open_specific_unit(h
);
88 inline void end_unit_scan(SCAN_HANDLE h
)
90 return context
->c_end_unit_scan(h
);
93 inline void end_global_scan(void)
95 return context
->c_end_global_scan();
98 inline int loadsector(const unsigned int sectn
, const unsigned int sect_size
,
99 const unsigned int numb_sects
, void *const dest_buf
)
101 return context
->c_loadsector(sectn
, sect_size
, numb_sects
, dest_buf
);
104 inline int netloop(char *filename
, void *dump_here
)
106 return context
->c_my_netloop(filename
, dump_here
);
109 /* memory functions */
110 inline void *malloc(int size
)
112 return context
->c_alloc_mem_for_anythingelse(size
);
115 inline void free(void *ptr
)
117 return context
->c_free_mem(ptr
);
120 inline void *memmove(void *dest
, const void *src
, int count
)
122 return context
->c_memmove(dest
, src
, count
);
126 inline char *getenv(unsigned char *var
)
128 return context
->c_getenv(var
);
131 inline void setenv(char *var
, char *value
)
133 return context
->c_setenv(var
, value
);
137 inline int tstc(void)
139 return context
->c_tstc();
142 inline void udelay(unsigned long t
)
144 return context
->c_udelay(t
);
147 /* video functions */
148 inline void video_clear(void)
150 return context
->c_video_clear();
153 inline void video_draw_box(int style
, int attr
, char *title
, int separate
,
154 int x
, int y
, int w
, int h
)
156 return context
->c_video_draw_box(style
, attr
, title
, separate
, x
, y
,
160 inline void video_draw_text(int x
, int y
, int attr
, char *text
, int field
)
162 return context
->c_video_draw_text(x
, y
, attr
, text
, field
);
165 inline void video_repeat_char(int x
, int y
, int repcnt
, int repchar
, int attr
)
167 return context
->c_video_repeat_char(x
, y
, repcnt
, repchar
, attr
);
170 inline unsigned short video_set_partial_scroll_limits(const short start
,
173 return context
->c_set_partial_scroll_limits(start
, end
);
176 inline void video_get_partial_scroll_limits(short *const start
,
179 return context
->c_get_partial_scroll_limits(start
, end
);
182 inline int video_get_key(void)
184 return context
->c_video_get_key();
187 /* ext2fs functions */
188 inline int ext2fs_set_blk_dev_full(block_dev_desc_t
* const rbdd
,
189 disk_partition_t
* const p
)
191 return context
->c_ext2fs_set_blk_dev_full(rbdd
, p
);
194 inline int ext2fs_open(char *filename
)
196 return context
->c_ext2fs_open(filename
);
199 inline int ext2fs_read(char *buf
, unsigned len
)
201 return context
->c_ext2fs_read(buf
, len
);
204 inline int ext2fs_mount(unsigned part_length
)
206 return context
->c_ext2fs_mount(part_length
);
209 inline int ext2fs_close(void)
211 return context
->c_ext2fs_close();
214 /* booting functions */
215 inline int bootm(cmd_tbl_t
* cmdtp
, int flag
, int argc
, char *argv
[])
217 return context
->c_do_bootm(cmdtp
, flag
, argc
, argv
);
220 inline void set_load_addr(void *const la
)
222 return context
->c_set_load_addr(la
);
225 inline int bootu(char *device
)
227 setenv("stdout", "vga");
228 setenv("boot1", device
);
229 return context
->c_bootu(device
);