diff options
author | Michael Brown | 2005-04-08 17:01:17 +0200 |
---|---|---|
committer | Michael Brown | 2005-04-08 17:01:17 +0200 |
commit | 0ff80b477dcff0726ebdbed95e8a93971e59e82b (patch) | |
tree | 860b7150212a07c24a9529ea072f3fb12700974c /src/core/main.c | |
parent | Merged this file into HEAD (diff) | |
download | ipxe-0ff80b477dcff0726ebdbed95e8a93971e59e82b.tar.gz ipxe-0ff80b477dcff0726ebdbed95e8a93971e59e82b.tar.xz ipxe-0ff80b477dcff0726ebdbed95e8a93971e59e82b.zip |
Merged mcb30-realmode-redesign back to HEAD
Diffstat (limited to 'src/core/main.c')
-rw-r--r-- | src/core/main.c | 137 |
1 files changed, 13 insertions, 124 deletions
diff --git a/src/core/main.c b/src/core/main.c index e92d2929..9cd89c22 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -23,12 +23,10 @@ Literature dealing with the network protocols: #include "http.h" #include "timer.h" #include "cpu.h" +#include "console.h" +#include "init.h" #include <stdarg.h> -#ifdef CONSOLE_BTEXT -#include "btext.h" -#endif - #ifdef CONFIG_FILO #include <lib.h> #endif @@ -43,51 +41,6 @@ int freebsd_howto = 0; char freebsd_kernel_env[FREEBSD_KERNEL_ENV_SIZE]; #endif -/* in_call(): the entry point to Etherboot. Generally called from - * arch_in_call(), which in turn will have been invoked from - * platform-specific assembly code. - */ -int in_call ( in_call_data_t *data, uint32_t opcode, va_list params ) { - int old_as_main_program = as_main_program; - int ret = 0; - - /* Set flat to indicate that we are not running as the main - * program (i.e. we are something like a PXE stack). - */ - as_main_program = 0; - - /* NOTE: params will cease to be valid if we relocate, since - * it represents a virtual address - */ - switch ( EB_OPCODE(opcode) ) { - - case EB_OPCODE_CHECK: - /* Installation check - */ - ret = EB_CHECK_RESULT; - break; - case EB_OPCODE_MAIN: - /* Start up Etherboot as a standalone program. */ - as_main_program = 1; - ret = main ( data, params ); - break; -#ifdef PXE_EXPORT - case EB_OPCODE_PXE: - /* !PXE API call */ - ret = pxe_in_call ( data, params ); - break; -#endif - default: - printf ( "Unsupported API \"%c%c\"\n", - EB_OPCODE(opcode) >> 8, EB_OPCODE(opcode) & 0xff ); - ret = -1; - break; - } - - as_main_program = old_as_main_program; - return ret; -} - static inline unsigned long ask_boot(unsigned *index) { unsigned long order = DEFAULT_BOOT_ORDER; @@ -166,26 +119,6 @@ static inline void try_floppy_first(void) #endif /* TRY_FLOPPY_FIRST */ } -void console_init(void) -{ -#ifdef CONSOLE_SERIAL - (void)serial_init(); -#endif -#ifdef CONSOLE_DIRECT_VGA - video_init(); -#endif -#ifdef CONSOLE_BTEXT - map_boot_text(); -#endif -} - -static void console_fini(void) -{ -#ifdef CONSOLE_SERIAL - (void)serial_fini(); -#endif -} - static struct class_operations { struct dev *dev; int (*probe)(struct dev *dev); @@ -204,44 +137,16 @@ static int exit_ok; static int exit_status; static int initialized; + /************************************************************************** MAIN - Kick off routine **************************************************************************/ -int main(in_call_data_t *data, va_list params) -{ - char *p; +int main ( void ) { int state; - for (p = _bss; p < _ebss; p++) - *p = 0; /* Zero BSS */ - - console_init(); - arch_main(data,params); - -#if 0 -#ifdef CONSOLE_BTEXT - btext_init(); - map_boot_text(); - btext_clearscreen(); -#endif -#endif - - if ( rom.rom_segment ) { - printf ( "ROM segment %#hx length %#hx reloc %#x\n", - rom.rom_segment, rom.rom_length, _text ); - } - - cpu_setup(); - setup_timers(); - gateA20_set(); print_config(); - get_memsizes(); cleanup(); -#ifdef CONFIG_PCMCIA - pcmcia_init_all(); -#endif - /* -1: timeout or ESC -2: error return from loader -3: finish the current run. @@ -258,10 +163,7 @@ int main(in_call_data_t *data, va_list params) for(;state != 255;) { state = main_loop(state); } - arch_on_exit(exit_status); -#ifdef CONFIG_PCMCIA - pcmcia_shutdown_all(); -#endif + /* arch_on_exit(exit_status) */ return exit_status; } @@ -283,13 +185,11 @@ static int main_loop(int state) static unsigned boot_index; static struct dev * dev = 0; static struct class_operations *ops; - static void *heap_base; static int type; static int i; if (!initialized) { initialized = 1; - console_init(); if (dev && (state >= 1) && (state <= 2)) { dev->how_probe = PROBE_AWAKE; dev->how_probe = ops->probe(dev); @@ -304,21 +204,8 @@ static int main_loop(int state) static int firsttime = 1; /* First time through */ if (firsttime) { - relocate(); + /* relocate(); */ cleanup(); - console_init(); - init_heap(); -#ifdef CONSOLE_BTEXT - //I need to all allot - btext_init(); - map_boot_text(); - btext_clearscreen(); -#else - #ifdef CONFIG_FILO - pci_init(); - #endif -#endif - firsttime = 0; } #ifdef EXIT_IF_NO_OFFER @@ -327,7 +214,6 @@ static int main_loop(int state) exit(0); } #endif - heap_base = allot(0); i = -1; state = 4; dev = 0; @@ -339,8 +225,7 @@ static int main_loop(int state) } case 4: cleanup(); - console_init(); - forget(heap_base); + call_reset_fns(); /* Find a dev entry to probe with */ if (!dev) { int boot; @@ -377,7 +262,12 @@ static int main_loop(int state) break; case 3: state = -1; - heap_base = allot(0); + /* Removed the following line because it was causing + * heap.o to be dragged in unnecessarily. It's also + * slightly puzzling: by resetting heap_base, doesn't + * this mean that we permanently leak memory? + */ + /* heap_base = allot(0); */ dev->how_probe = ops->probe(dev); if (dev->how_probe == PROBE_FAILED) { dev = 0; @@ -518,7 +408,6 @@ void cleanup(void) /* Stop receiving packets */ eth_disable(); disk_disable(); - console_fini(); initialized = 0; } |