Hello from mipsel

This commit is contained in:
phcoder 2009-10-10 13:30:14 +02:00
parent e27fbc80e4
commit de75aa3d67
8 changed files with 66 additions and 12 deletions

View file

@ -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 \

View file

@ -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;

View file

@ -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

View file

@ -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);
}

View file

@ -1,5 +1,5 @@
#include <grub/symbol.h>
FUNCTION (grub_arch_sync_caches)
FUNCTION (_flush_cache)
FUNCTION (grub_cpu_flush_cache)
j $31

View file

@ -4,9 +4,13 @@
#include <grub/time.h>
#include <grub/types.h>
#include <grub/misc.h>
#include <grub/mm.h>
#include <grub/machine/kernel.h>
#include <grub/machine/memory.h>
#include <grub/cpu/kernel.h>
#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;
}

View file

@ -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++;
}

View file

@ -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);
}