From de75aa3d67a83ce74cac4aa74e47f9affb1489a6 Mon Sep 17 00:00:00 2001 From: phcoder Date: Sat, 10 Oct 2009 13:30:14 +0200 Subject: [PATCH] Hello from mipsel --- conf/mips.rmk | 8 ++++---- genmoddep.awk | 2 +- include/grub/mipsel/qemu-r4k/memory.h | 18 ++++++++++++++++++ kern/main.c | 16 ++++++++++++++++ kern/mipsel/cache.S | 2 +- kern/mipsel/qemu-r4k/init.c | 16 ++++++++++++++++ kern/misc.c | 2 +- kern/term.c | 14 +++++++++----- 8 files changed, 66 insertions(+), 12 deletions(-) diff --git a/conf/mips.rmk b/conf/mips.rmk index 6d8df9e4e..ad0219b06 100644 --- a/conf/mips.rmk +++ b/conf/mips.rmk @@ -2,7 +2,7 @@ # -*- makefile -*- COMMON_ASFLAGS = -nostdinc -COMMON_CFLAGS = +COMMON_CFLAGS = -mexplicit-relocs -mflush-func=grub_cpu_flush_cache COMMON_LDFLAGS += -nostdlib # Used by various components. These rules need to precede them. @@ -17,7 +17,7 @@ kernel_img_HEADERS = boot.h cache.h device.h disk.h dl.h elf.h elfload.h \ env.h err.h file.h fs.h kernel.h misc.h mm.h net.h parser.h reader.h \ symbol.h term.h time.h types.h loader.h partition.h \ msdos_partition.h machine/kernel.h handler.h list.h \ - command.h + command.h machine/memory.h cpu/libgcc.h cpu/cache.h symlist.c: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h gensymlist.sh /bin/sh gensymlist.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1) @@ -99,8 +99,8 @@ kernel_img_LDFLAGS = $(COMMON_LDFLAGS) -static-libgcc -lgcc \ -Wl,-N,-S,-Ttext,$(LINK_BASE),-Bstatic # Scripts. -sbin_SCRIPTS = grub-install -bin_SCRIPTS = grub-mkrescue +sbin_SCRIPTS = +bin_SCRIPTS = # Modules. pkglib_MODULES = memdisk.mod \ diff --git a/genmoddep.awk b/genmoddep.awk index f7f085e99..af967ec07 100644 --- a/genmoddep.awk +++ b/genmoddep.awk @@ -29,7 +29,7 @@ FNR == 1 { if ($1 in symtab) { modtab[module] = modtab[module] " " symtab[$1]; } - else { + else if ($1 != "__gnu_local_gp"){ printf "%s in %s is not defined\n", $1, module >"/dev/stderr"; error++; exit; diff --git a/include/grub/mipsel/qemu-r4k/memory.h b/include/grub/mipsel/qemu-r4k/memory.h index 6021bab04..21f295b67 100644 --- a/include/grub/mipsel/qemu-r4k/memory.h +++ b/include/grub/mipsel/qemu-r4k/memory.h @@ -27,9 +27,27 @@ #define GRUB_MACHINE_MEMORY_STACK_HIGH 0x81000000 +#define GRUB_MACHINE_MEMORY_AVAILABLE 1 + #ifndef ASM_FILE grub_err_t EXPORT_FUNC (grub_machine_mmap_iterate) (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uint64_t, grub_uint32_t)); +grub_err_t EXPORT_FUNC(grub_machine_mmap_iterate) + (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uint64_t, grub_uint32_t)); + +static inline grub_err_t +grub_machine_mmap_register (grub_uint64_t start __attribute__ ((unused)), + grub_uint64_t size __attribute__ ((unused)), + int type __attribute__ ((unused)), + int handle __attribute__ ((unused))) +{ + return GRUB_ERR_NONE; +} +static inline grub_err_t +grub_machine_mmap_unregister (int handle __attribute__ ((unused))) +{ + return GRUB_ERR_NONE; +} #endif #endif diff --git a/kern/main.c b/kern/main.c index 9215d55e7..222897d7d 100644 --- a/kern/main.c +++ b/kern/main.c @@ -149,29 +149,45 @@ grub_load_normal_mode (void) void grub_main (void) { + *((grub_uint8_t *)0x140003f8) = '1'; + /* First of all, initialize the machine. */ grub_machine_init (); + *((grub_uint8_t *)0x140003f8) = '2'; + /* Hello. */ grub_setcolorstate (GRUB_TERM_COLOR_HIGHLIGHT); + *((grub_uint8_t *)0x140003f8) = 'a'; grub_printf ("Welcome to GRUB!\n\n"); + *((grub_uint8_t *)0x140003f8) = 'b'; grub_setcolorstate (GRUB_TERM_COLOR_STANDARD); + *((grub_uint8_t *)0x140003f8) = '3'; + /* Load pre-loaded modules and free the space. */ grub_register_exported_symbols (); grub_load_modules (); + *((grub_uint8_t *)0x140003f8) = '4'; + /* It is better to set the root device as soon as possible, for convenience. */ grub_machine_set_prefix (); grub_env_export ("prefix"); grub_set_root_dev (); + *((grub_uint8_t *)0x140003f8) = '5'; + grub_register_core_commands (); grub_register_rescue_parser (); grub_register_rescue_reader (); + *((grub_uint8_t *)0x140003f8) = '6'; + grub_load_config (); + *((grub_uint8_t *)0x140003f8) = '7'; grub_load_normal_mode (); + *((grub_uint8_t *)0x140003f8) = '8'; grub_reader_loop (0); } diff --git a/kern/mipsel/cache.S b/kern/mipsel/cache.S index 5341f07a2..f613f57f2 100644 --- a/kern/mipsel/cache.S +++ b/kern/mipsel/cache.S @@ -1,5 +1,5 @@ #include FUNCTION (grub_arch_sync_caches) -FUNCTION (_flush_cache) +FUNCTION (grub_cpu_flush_cache) j $31 diff --git a/kern/mipsel/qemu-r4k/init.c b/kern/mipsel/qemu-r4k/init.c index 0600a345f..c4aec14ff 100644 --- a/kern/mipsel/qemu-r4k/init.c +++ b/kern/mipsel/qemu-r4k/init.c @@ -4,9 +4,13 @@ #include #include #include +#include #include +#include #include +#define RAMSIZE (*(grub_uint32_t *) ((16 << 20) - 264)) + grub_uint32_t grub_get_rtc (void) { @@ -17,6 +21,8 @@ grub_get_rtc (void) void grub_machine_init (void) { + grub_mm_init_region ((void *) GRUB_MACHINE_MEMORY_STACK_HIGH, + RAMSIZE - GRUB_MACHINE_MEMORY_STACK_HIGH); } void @@ -56,3 +62,13 @@ grub_arch_modules_addr (void) { return ALIGN_UP((grub_addr_t) _end + GRUB_MOD_GAP, GRUB_MOD_ALIGN); } + +grub_err_t +grub_machine_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, + grub_uint64_t, + grub_uint32_t)) +{ + hook (0, RAMSIZE, + GRUB_MACHINE_MEMORY_AVAILABLE); + return GRUB_ERR_NONE; +} diff --git a/kern/misc.c b/kern/misc.c index 1c38fe661..ba19705f3 100644 --- a/kern/misc.c +++ b/kern/misc.c @@ -598,7 +598,7 @@ grub_vsprintf (char *str, const char *fmt, va_list args) if (str) *str++ = ch; else - grub_putchar (ch); + grub_putchar (ch); count++; } diff --git a/kern/term.c b/kern/term.c index 94d5a9e1d..22660c6a8 100644 --- a/kern/term.c +++ b/kern/term.c @@ -48,8 +48,9 @@ struct grub_handler_class grub_term_output_class = void grub_putcode (grub_uint32_t code) { - int height = grub_getwh () & 255; + // int height = grub_getwh () & 255; +#if 0 if (code == '\t' && grub_cur_term_output->getxy) { int n; @@ -60,13 +61,15 @@ grub_putcode (grub_uint32_t code) return; } +#endif - (grub_cur_term_output->putchar) (code); + // (grub_cur_term_output->putchar) (code); + *((grub_uint8_t *)0x140003f8) = code; if (code == '\n') { grub_putcode ('\r'); - +#if 0 grub_more_lines++; if (grub_more && grub_more_lines == height - 1) @@ -93,6 +96,7 @@ grub_putcode (grub_uint32_t code) else grub_more_lines = 0; } +#endif } } @@ -182,14 +186,14 @@ grub_cls (void) void grub_setcolorstate (grub_term_color_state state) { - if (grub_cur_term_output->setcolorstate) + if (grub_cur_term_output && grub_cur_term_output->setcolorstate) (grub_cur_term_output->setcolorstate) (state); } void grub_setcolor (grub_uint8_t normal_color, grub_uint8_t highlight_color) { - if (grub_cur_term_output->setcolor) + if (grub_cur_term_output && grub_cur_term_output->setcolor) (grub_cur_term_output->setcolor) (normal_color, highlight_color); }