d0fe275058d015ee3ecadfe58094bc59200200a4
[AROS.git] / arch / ppc-sam440 / boot / parthenope / src / context.c
blobd0fe275058d015ee3ecadfe58094bc59200200a4
1 /* context.c */
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.
23 #include "context.h"
25 static context_t *context = NULL;
27 void context_init(context_t * ctx)
29 context = ctx;
32 inline context_t *context_get(void)
34 return context;
37 /* terminal IO functions */
38 inline int getc(void)
40 return context->c_getc();
43 /* devices functions */
44 inline void *get_scan_list(void)
46 return context->c_scan_list;
49 inline list_t *get_devices_list(void)
51 return context->c_devices_list;
54 inline SCAN_HANDLE get_curr_device(void)
56 return context->c_curr_device;
59 inline SCAN_HANDLE start_unit_scan(const void *scan_list,
60 uint32_t * const blocksize)
62 return context->c_start_unit_scan(scan_list, blocksize);
65 inline SCAN_HANDLE next_unit_scan(SCAN_HANDLE h, unsigned int *const blocksize)
67 return context->c_next_unit_scan(h, blocksize);
70 inline int open_specific_unit(const SCAN_HANDLE h)
72 return context->c_open_specific_unit(h);
75 inline void end_unit_scan(SCAN_HANDLE h)
77 return context->c_end_unit_scan(h);
80 inline void end_global_scan(void)
82 return context->c_end_global_scan();
85 inline int loadsector(const unsigned int sectn, const unsigned int sect_size,
86 const unsigned int numb_sects, void *const dest_buf)
88 return context->c_loadsector(sectn, sect_size, numb_sects, dest_buf);
91 inline int netloop(char *filename, void *dump_here)
93 return context->c_my_netloop(filename, dump_here);
96 /* memory functions */
97 inline void *malloc(int size)
99 return context->c_alloc_mem_for_anythingelse(size);
102 inline void free(void *ptr)
104 return context->c_free_mem(ptr);
107 inline void *memmove(void *dest, const void *src, int count)
109 return context->c_memmove(dest, src, count);
112 /* ENV functions */
113 inline char *getenv(unsigned char *var)
115 return context->c_getenv(var);
118 inline void setenv(char *var, char *value)
120 return context->c_setenv(var, value);
123 /* misc functions */
124 inline int tstc(void)
126 return context->c_tstc();
129 inline void udelay(unsigned long t)
131 return context->c_udelay(t);
134 /* video functions */
135 inline void video_clear(void)
137 return context->c_video_clear();
140 inline void video_draw_box(int style, int attr, char *title, int separate,
141 int x, int y, int w, int h)
143 return context->c_video_draw_box(style, attr, title, separate, x, y,
144 w, h);
147 inline void video_draw_text(int x, int y, int attr, char *text, int field)
149 return context->c_video_draw_text(x, y, attr, text, field);
152 inline void video_repeat_char(int x, int y, int repcnt, int repchar, int attr)
154 return context->c_video_repeat_char(x, y, repcnt, repchar, attr);
157 inline unsigned short video_set_partial_scroll_limits(const short start,
158 const short end)
160 return context->c_set_partial_scroll_limits(start, end);
163 inline void video_get_partial_scroll_limits(short *const start,
164 short *const end)
166 return context->c_get_partial_scroll_limits(start, end);
169 inline int video_get_key(void)
171 return context->c_video_get_key();
174 /* ext2fs functions */
175 inline int ext2fs_set_blk_dev_full(block_dev_desc_t * const rbdd,
176 disk_partition_t * const p)
178 return context->c_ext2fs_set_blk_dev_full(rbdd, p);
181 inline int ext2fs_open(char *filename)
183 return context->c_ext2fs_open(filename);
186 inline int ext2fs_read(char *buf, unsigned len)
188 return context->c_ext2fs_read(buf, len);
191 inline int ext2fs_mount(unsigned part_length)
193 return context->c_ext2fs_mount(part_length);
196 inline int ext2fs_close(void)
198 return context->c_ext2fs_close();
201 /* booting functions */
202 inline int bootm(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
204 return context->c_do_bootm(cmdtp, flag, argc, argv);
207 inline void set_load_addr(void *const la)
209 return context->c_set_load_addr(la);
212 inline int bootu(char *device)
214 setenv("stdout", "vga");
215 setenv("boot1", device);
216 return context->c_bootu(device);