kern/rescue_parser.c kern/rescue_reader.c \
kern/list.c kern/handler.c kern/command.c kern/corecmd.c \
kern/parser.c kern/partition.c kern/env.c kern/$(target_cpu)/dl.c \
- kern/generic/millisleep.c kern/time.c \
+ kern/generic/millisleep.c kern/generic/rtc_get_time_ms.c kern/time.c \
symlist.c kern/$(target_cpu)/cache.S
kernel_img_CFLAGS = $(COMMON_CFLAGS)
kernel_img_ASFLAGS = $(COMMON_ASFLAGS)
lsmmap_mod_CFLAGS = $(COMMON_CFLAGS)
lsmmap_mod_LDFLAGS = $(COMMON_LDFLAGS)
+# For serial.mod.
+pkglib_MODULES += serial.mod
+serial_mod_SOURCES = term/serial.c
+serial_mod_CFLAGS = $(COMMON_CFLAGS)
+serial_mod_LDFLAGS = $(COMMON_LDFLAGS)
+
include $(srcdir)/conf/common.mk
/* Compare NAME and FN by hand in order to cope with duplicate
slashes. */
- i = 1;
+ i = 0;
j = 0;
+ while (name[i] == '/')
+ i++;
while (1)
{
if (name[i] != fn[j])
if (name[i] == '\0')
break;
- if (name[i] == '/' && name[i+1] == '/')
+ while (name[i] == '/' && name[i+1] == '/')
i++;
i++;
j++;
}
+ if (name[i] != fn[j])
+ goto no_match;
+
file->data = data;
file->size = data->size;
grub_free (fn);
#{@name}: $(#{prefix}_DEPENDENCIES) #{objs_str}
$(TARGET_CC) -o $@ #{objs_str} $(TARGET_LDFLAGS) $(#{prefix}_LDFLAGS)
+ $(STRIP) -R .rel.dyn -R .reginfo -R .note -R .comment $@
" + objs.collect_with_index do |obj, i|
src = sources[i]
"#{obj}: #{src} $(#{src}_DEPENDENCIES)
$(TARGET_CC) -I#{dir} -I$(srcdir)/#{dir} $(TARGET_CPPFLAGS) #{extra_flags} $(TARGET_#{flag}) $(#{prefix}_#{flag}) -MD -c -o $@ $<
+
-include #{dep}
"
--- /dev/null
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GRUB_CPU_DL_H
+#define GRUB_CPU_DL_H 1
+
+/* Dummy __gnu_local_gp. Resolved by linker. */
+char EXPORT_VAR (__gnu_local_gp);
+
+#endif /* ! GRUB_CPU_DL_H */
--- /dev/null
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GRUB_IO_H
+#define GRUB_IO_H 1
+
+#include <grub/types.h>
+
+typedef grub_addr_t grub_port_t;
+
+static __inline unsigned char
+grub_inb (grub_port_t port)
+{
+ return *(grub_uint8_t *) port;
+}
+
+static __inline unsigned short int
+grub_inw (grub_port_t port)
+{
+ return *(grub_uint16_t *) port;
+}
+
+static __inline unsigned int
+grub_inl (grub_port_t port)
+{
+ return *(grub_uint32_t *) port;
+}
+
+static __inline void
+grub_outb (unsigned char value, grub_port_t port)
+{
+ *(grub_uint8_t *) port = value;
+}
+
+static __inline void
+grub_outw (unsigned short int value, grub_port_t port)
+{
+ *(grub_uint16_t *) port = value;
+}
+
+static __inline void
+grub_outl (unsigned int value, grub_port_t port)
+{
+ *(grub_uint32_t *) port = value;
+}
+
+#endif /* _SYS_IO_H */
for (dev = grub_disk_dev_list; dev; dev = dev->next)
{
- grub_printf ("open: %p\n", dev->open);
- grub_getkey ();
if ((dev->open) (raw, disk) == GRUB_ERR_NONE)
break;
else if (grub_errno == GRUB_ERR_UNKNOWN_DEVICE)
grub_errno = GRUB_ERR_NONE;
else
goto fail;
- grub_printf ("survived\n");
}
if (! dev)
grub_size_t gp_size = 0;
/* FIXME: suboptimal. */
grub_uint32_t *gp, *gpptr;
+ grub_uint32_t gp0;
/* Find a symbol table. */
for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff);
entsize = s->sh_entsize;
+ /* Find reginfo. */
+ for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff);
+ i < e->e_shnum;
+ i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize))
+ if (s->sh_type == SHT_MIPS_REGINFO)
+ break;
+
+ if (i == e->e_shnum)
+ return grub_error (GRUB_ERR_BAD_MODULE, "no reginfo found");
+
+ gp0 = ((grub_uint32_t *)((char *) e + s->sh_offset))[5];
+
for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff);
i < e->e_shnum;
i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize))
gpptr = gp = grub_malloc (gp_size);
if (!gp)
return grub_errno;
- grub_printf ("gp=%p\n", gp);
for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff);
i < e->e_shnum;
*(grub_uint16_t *) addr += (sym->st_value) & 0xffff;
break;
case R_MIPS_32:
- *(grub_uint32_t *) addr = sym->st_value;
+ *(grub_uint32_t *) addr += sym->st_value;
+ break;
+ case R_MIPS_GPREL32:
+ *(grub_uint32_t *) addr = sym->st_value
+ + *(grub_uint32_t *) addr + gp0 - (grub_uint32_t)gp;
break;
+
case R_MIPS_26:
{
grub_uint32_t value;
= sizeof (grub_uint32_t) * (gpptr - gp);
gpptr++;
break;
- case R_MIPS_GPREL32:
- grub_printf ("gp32\n");
- *gpptr = sym->st_value + *(grub_uint16_t *) addr;
- *(grub_uint32_t *) addr
- = sizeof (grub_uint32_t) * (gpptr - gp);
- gpptr++;
- break;
default:
- grub_printf ("Unknown relocation type %d\n",
- ELF_R_TYPE (rel->r_info));
+ {
+ grub_free (gp);
+ return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ "Unknown relocation type %d\n",
+ ELF_R_TYPE (rel->r_info));
+ }
break;
}
}
#include <grub/types.h>
#include <grub/misc.h>
#include <grub/mm.h>
+#include <grub/time.h>
#include <grub/machine/kernel.h>
#include <grub/machine/memory.h>
#include <grub/cpu/kernel.h>
void
grub_putcode (grub_uint32_t code)
{
- // int height = grub_getwh () & 255;
+ int height = grub_getwh () & 255;
+
+ if (!grub_cur_term_output)
+ return;
-#if 0
if (code == '\t' && grub_cur_term_output->getxy)
{
int n;
return;
}
-#endif
- // (grub_cur_term_output->putchar) (code);
- *((grub_uint8_t *)0x140003f8) = code;
+ (grub_cur_term_output->putchar) (code);
if (code == '\n')
{
grub_putcode ('\r');
-#if 0
+
grub_more_lines++;
if (grub_more && grub_more_lines == height - 1)
else
grub_more_lines = 0;
}
-#endif
}
}
grub_ssize_t
grub_getcharwidth (grub_uint32_t code)
{
+ if (!grub_cur_term_output)
+ return 1;
return (grub_cur_term_output->getcharwidth) (code);
}
int
grub_getkey (void)
{
- while (!(*((grub_uint8_t *)0x140003f8+5) & 0x01));
- return *((grub_uint8_t *)0x140003f8);
- // return (grub_cur_term_input->getkey) ();
+ int c;
+ if (!grub_cur_term_input)
+ return 0;
+ return (grub_cur_term_input->getkey) ();
}
int
grub_checkkey (void)
{
- return !!(*((grub_uint8_t *)0x140003f8+5) & 0x01);
- //return (grub_cur_term_input->checkkey) ();
+ if (!grub_cur_term_input)
+ return 0;
+ return (grub_cur_term_input->checkkey) ();
}
int
grub_getkeystatus (void)
{
- /* if (grub_cur_term_input->getkeystatus)
+ if (grub_cur_term_input && grub_cur_term_input->getkeystatus)
return (grub_cur_term_input->getkeystatus) ();
- else*/
+ else
return 0;
}
grub_uint16_t
grub_getxy (void)
{
+ if (!grub_cur_term_output)
+ return 0;
return (grub_cur_term_output->getxy) ();
}
grub_uint16_t
grub_getwh (void)
{
+ if (!grub_cur_term_output)
+ return (80 << 8) | 25;
return (grub_cur_term_output->getwh) ();
}
void
grub_gotoxy (grub_uint8_t x, grub_uint8_t y)
{
- (grub_cur_term_output->gotoxy) (x, y);
+ if (grub_cur_term_output && grub_cur_term_output->gotoxy)
+ (grub_cur_term_output->gotoxy) (x, y);
}
void
grub_cls (void)
{
+ if (!grub_cur_term_output)
+ return;
+
if ((grub_cur_term_output->flags & GRUB_TERM_DUMB) || (grub_env_get ("debug")))
{
grub_putchar ('\n');
void
grub_setcolorstate (grub_term_color_state state)
{
- if (grub_cur_term_output && grub_cur_term_output->setcolorstate)
+ if (!grub_cur_term_output)
+ return;
+
+ if (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 && grub_cur_term_output->setcolor)
+ if (!grub_cur_term_output)
+ return;
+
+ if (grub_cur_term_output->setcolor)
(grub_cur_term_output->setcolor) (normal_color, highlight_color);
}
void
grub_getcolor (grub_uint8_t *normal_color, grub_uint8_t *highlight_color)
{
+ if (!grub_cur_term_output)
+ return;
+
if (grub_cur_term_output->getcolor)
(grub_cur_term_output->getcolor) (normal_color, highlight_color);
}
{
int ret = cursor_state;
- if (grub_cur_term_output->setcursor)
+ if (grub_cur_term_output && grub_cur_term_output->setcursor)
{
(grub_cur_term_output->setcursor) (on);
cursor_state = on;
void
grub_refresh (void)
{
- if (grub_cur_term_output->refresh)
+ if (grub_cur_term_output && grub_cur_term_output->refresh)
(grub_cur_term_output->refresh) ();
}
#include <grub/machine/machine.h>
#include <grub/machine/memory.h>
-#include <grub/machine/serial.h>
-#include <grub/machine/console.h>
+#include <grub/serial.h>
+//#include <grub/machine/console.h>
#include <grub/term.h>
#include <grub/types.h>
#include <grub/dl.h>
#ifdef GRUB_MACHINE_PCBIOS
static const unsigned short *serial_hw_io_addr = (const unsigned short *) GRUB_MEMORY_MACHINE_BIOS_DATA_AREA_ADDR;
#define GRUB_SERIAL_PORT_NUM 4
+#elif defined (GRUB_MACHINE_MIPS_QEMU)
+static const grub_port_t serial_hw_io_addr[] = { 0x140003f8 };
+#define GRUB_SERIAL_PORT_NUM (ARRAY_SIZE(serial_hw_io_addr))
#else
static const grub_port_t serial_hw_io_addr[] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8 };
#define GRUB_SERIAL_PORT_NUM (ARRAY_SIZE(serial_hw_io_addr))
if (input_buf[0] != '\e' || input_buf[1] != '[')
return;
- for (i = 0; ARRAY_SIZE (three_code_table); i++)
+ for (i = 0; i < ARRAY_SIZE (three_code_table); i++)
if (three_code_table[i].key == input_buf[2])
{
input_buf[0] = three_code_table[i].ascii;
;
c = input_buf[0];
+ if (c == 0x7f)
+ c = GRUB_TERM_BACKSPACE;
+
grub_memmove (input_buf, input_buf + 1, --npending);
return c;