]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
various fixes. MIPSsim support
authorphcoder <phcoder@debian.bg45.phnet>
Sun, 11 Oct 2009 16:18:18 +0000 (18:18 +0200)
committerphcoder <phcoder@debian.bg45.phnet>
Sun, 11 Oct 2009 16:18:18 +0000 (18:18 +0200)
15 files changed:
conf/mips-qemu-mipssim.rmk [new file with mode: 0644]
conf/mips.rmk
configure.ac
disk/ata.c
include/grub/ata.h
include/grub/mips/libgcc.h
include/grub/mips/pci.h [new file with mode: 0644]
include/grub/mips/qemu-mipssim/kernel.h [new file with mode: 0644]
include/grub/mips/qemu-mipssim/machine.h [new file with mode: 0644]
include/grub/mips/qemu-mipssim/memory.h [new file with mode: 0644]
include/grub/mips/qemu-mipssim/time.h [new file with mode: 0644]
include/grub/mips/qemu-r4k/machine.h
kern/mips/qemu-mipssim/init.c [new file with mode: 0644]
kern/mips/qemu-mipssim/startup.S [new file with mode: 0644]
term/serial.c

diff --git a/conf/mips-qemu-mipssim.rmk b/conf/mips-qemu-mipssim.rmk
new file mode 100644 (file)
index 0000000..9000ae2
--- /dev/null
@@ -0,0 +1,4 @@
+# -*- makefile -*-
+LINK_BASE = 0x80010000
+target_machine=qemu-mipssim
+include $(srcdir)/conf/mips.mk
index d03b5d8f5c4e5e6e65c01fec006b8a7cf53e5d60..6ebd7d665b56c06228a7fa6cf6cd3af077811404 100644 (file)
@@ -84,7 +84,7 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c   \
 
 grub_emu_LDFLAGS = $(LIBCURSES)
 
-kernel_img_SOURCES = kern/mips/qemu-r4k/startup.S \
+kernel_img_SOURCES = kern/$(target_cpu)/$(target_machine)/startup.S \
        kern/main.c kern/device.c kern/$(target_cpu)/$(target_machine)/init.c           \
        kern/disk.c kern/dl.c kern/err.c kern/file.c kern/fs.c          \
        kern/misc.c kern/mm.c kern/reader.c kern/term.c         \
@@ -128,4 +128,16 @@ serial_mod_SOURCES = term/serial.c
 serial_mod_CFLAGS = $(COMMON_CFLAGS)
 serial_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
+# For ata.mod.
+pkglib_MODULES += ata.mod
+ata_mod_SOURCES = disk/ata.c
+ata_mod_CFLAGS = $(COMMON_CFLAGS)
+ata_mod_LDFLAGS = $(COMMON_LDFLAGS)
+
+# For pci.mod.
+pkglib_MODULES += pci.mod
+pci_mod_SOURCES = bus/pci.c
+pci_mod_CFLAGS = $(COMMON_CFLAGS)
+pci_mod_LDFLAGS = $(COMMON_LDFLAGS)
+
 include $(srcdir)/conf/common.mk
index 97486e42166c991e2a776457c3ff8f9bc8e3dc6a..98750280e4806f28f482bb456e741a1d079267b9 100644 (file)
@@ -91,6 +91,8 @@ case "$target_cpu"-"$platform" in
   sparc64-ieee1275) ;;
   mipsel-qemu-r4k) ;;
   mips-qemu-r4k) ;;
+  mipsel-qemu-mipssim) ;;
+  mips-qemu-mipssim) ;;
   *) AC_MSG_ERROR([platform "$platform" is not supported for target CPU "$target_cpu"]) ;;
 esac
 
index 78d396526c757206e01a8686e035874ca116b32a..b8ce88df30992d5f6fc04bdc8bbbea37c4c10fca 100644 (file)
 #include <grub/time.h>
 #include <grub/pci.h>
 #include <grub/scsi.h>
+#include <grub/machine/machine.h>
 
 /* At the moment, only two IDE ports are supported.  */
-static const int grub_ata_ioaddress[] = { 0x1f0, 0x170 };
-static const int grub_ata_ioaddress2[] = { 0x3f6, 0x376 };
+static const grub_port_t grub_ata_ioaddress[] = { 0x1f0, 0x170 };
+static const grub_port_t grub_ata_ioaddress2[] = { 0x3f6, 0x376 };
 
 static struct grub_ata_device *grub_ata_devices;
 
index aaa2e147a498531886985bd6c6e287b8508ba3cb..940e671023c9deb10eac44e27a26c770b850431c 100644 (file)
@@ -98,8 +98,8 @@ struct grub_ata_device
 
   /* IO addresses on which the registers for this device can be
      found.  */
-  int ioaddress;
-  int ioaddress2;
+  grub_port_t ioaddress;
+  grub_port_t ioaddress2;
 
   /* Two devices can be connected to a single cable.  Use this field
      to select device 0 (commonly known as "master") or device 1
index a6584252235256d6ed4520b8230475edd54e4244..a04a8f14046fbaceba70b115a47650f57d08986b 100644 (file)
  *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-void *EXPORT_FUNC (memset) (void *s, int c, int n) __attribute__ ((weak));
-void EXPORT_FUNC (__ashldi3) (void) __attribute__ ((weak));
-void EXPORT_FUNC (__ashrdi3) (void) __attribute__ ((weak));
-void EXPORT_FUNC (__lshrdi3) (void) __attribute__ ((weak));
-void EXPORT_FUNC (__trampoline_setup) (void) __attribute__ ((weak));
-void EXPORT_FUNC (__ucmpdi2) (void) __attribute__ ((weak));
-void EXPORT_FUNC (__bswapsi2) (void) __attribute__ ((weak));
-void EXPORT_FUNC (__bswapdi2) (void) __attribute__ ((weak));
+void *EXPORT_FUNC (memset) (void *s, int c, int n);
+void EXPORT_FUNC (__ashldi3) (void);
+void EXPORT_FUNC (__ashrdi3) (void);
+void EXPORT_FUNC (__lshrdi3) (void);
+void EXPORT_FUNC (__ucmpdi2) (void);
+void EXPORT_FUNC (__bswapsi2) (void);
+void EXPORT_FUNC (__bswapdi2) (void);
diff --git a/include/grub/mips/pci.h b/include/grub/mips/pci.h
new file mode 100644 (file)
index 0000000..38a95a4
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2008  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_PCI_H
+#define        GRUB_CPU_PCI_H  1
+
+#include <grub/types.h>
+#include <grub/cpu/io.h>
+
+#define GRUB_PCI_ADDR_REG      0x14000cf8
+#define GRUB_PCI_DATA_REG      0x14000cfc
+
+static inline grub_uint32_t
+grub_pci_read (grub_pci_address_t addr)
+{
+  grub_outl (addr, GRUB_PCI_ADDR_REG);
+  return grub_inl (GRUB_PCI_DATA_REG);
+}
+
+static inline grub_uint16_t
+grub_pci_read_word (grub_pci_address_t addr)
+{
+  grub_outl (addr & ~3, GRUB_PCI_ADDR_REG);
+  return grub_inw (GRUB_PCI_DATA_REG + (addr & 3));
+}
+
+static inline grub_uint8_t
+grub_pci_read_byte (grub_pci_address_t addr)
+{
+  grub_outl (addr & ~3, GRUB_PCI_ADDR_REG);
+  return grub_inb (GRUB_PCI_DATA_REG + (addr & 3));
+}
+
+static inline void
+grub_pci_write (grub_pci_address_t addr, grub_uint32_t data)
+{
+  grub_outl (addr, GRUB_PCI_ADDR_REG);
+  grub_outl (data, GRUB_PCI_DATA_REG);
+}
+
+static inline void
+grub_pci_write_word (grub_pci_address_t addr, grub_uint16_t data)
+{
+  grub_outl (addr & ~3, GRUB_PCI_ADDR_REG);
+  grub_outw (data, GRUB_PCI_DATA_REG + (addr & 3));
+}
+
+static inline void
+grub_pci_write_byte (grub_pci_address_t addr, grub_uint8_t data)
+{
+  grub_outl (addr & ~3, GRUB_PCI_ADDR_REG);
+  grub_outb (data, GRUB_PCI_DATA_REG + (addr & 3));
+}
+
+#endif /* GRUB_CPU_PCI_H */
diff --git a/include/grub/mips/qemu-mipssim/kernel.h b/include/grub/mips/qemu-mipssim/kernel.h
new file mode 100644 (file)
index 0000000..6a10f2d
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2005,2006,2007,2008,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_KERNEL_MACHINE_HEADER
+#define GRUB_KERNEL_MACHINE_HEADER     1
+
+#include <grub/symbol.h>
+
+#ifndef ASM_FILE
+
+void EXPORT_FUNC (grub_reboot) (void);
+void EXPORT_FUNC (grub_halt) (void);
+
+/* The prefix which points to the directory where GRUB modules and its
+   configuration file are located.  */
+extern char grub_prefix[];
+
+#endif
+
+#endif /* ! GRUB_KERNEL_MACHINE_HEADER */
diff --git a/include/grub/mips/qemu-mipssim/machine.h b/include/grub/mips/qemu-mipssim/machine.h
new file mode 100644 (file)
index 0000000..9062662
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2007  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_MACHINE_MACHINE_HEADER
+#define GRUB_MACHINE_MACHINE_HEADER    1
+
+#define GRUB_MACHINE_MIPS_QEMU_MIPSSIM 1
+
+#endif /* ! GRUB_MACHINE_MACHINE_HEADER */
diff --git a/include/grub/mips/qemu-mipssim/memory.h b/include/grub/mips/qemu-mipssim/memory.h
new file mode 100644 (file)
index 0000000..87e6867
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ *  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_MEMORY_MACHINE_HEADER
+#define GRUB_MEMORY_MACHINE_HEADER     1
+
+#ifndef ASM_FILE
+#include <grub/symbol.h>
+#include <grub/err.h>
+#include <grub/types.h>
+#endif
+
+#define GRUB_MACHINE_MEMORY_STACK_HIGH       0x80f00000
+#define GRUB_MACHINE_MEMORY_USABLE       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/include/grub/mips/qemu-mipssim/time.h b/include/grub/mips/qemu-mipssim/time.h
new file mode 100644 (file)
index 0000000..5c8564e
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2003,2004,2005,2007  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 KERNEL_MACHINE_TIME_HEADER
+#define KERNEL_MACHINE_TIME_HEADER     1
+
+#include <grub/symbol.h>
+
+#define GRUB_TICKS_PER_SECOND  1000
+
+/* Return the real time in ticks.  */
+grub_uint32_t EXPORT_FUNC (grub_get_rtc) (void);
+
+static inline void
+grub_cpu_idle(void)
+{
+  /*  asm volatile ("wait");*/
+}
+
+#endif /* ! KERNEL_MACHINE_TIME_HEADER */
index 9bad5dca943c3d66c12f190cba994d4ddd62895f..386cad75028a50a461a485bc3cdaab830bd18bcf 100644 (file)
@@ -19,6 +19,6 @@
 #ifndef GRUB_MACHINE_MACHINE_HEADER
 #define GRUB_MACHINE_MACHINE_HEADER    1
 
-#define GRUB_MACHINE_MIPS_QEMU 1
+#define GRUB_MACHINE_MIPS_QEMU_R4K     1
 
 #endif /* ! GRUB_MACHINE_MACHINE_HEADER */
diff --git a/kern/mips/qemu-mipssim/init.c b/kern/mips/qemu-mipssim/init.c
new file mode 100644 (file)
index 0000000..d4001cf
--- /dev/null
@@ -0,0 +1,76 @@
+#include <grub/kernel.h>
+#include <grub/misc.h>
+#include <grub/env.h>
+#include <grub/time.h>
+#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>
+
+#define RAMSIZE (64 << 20)
+
+grub_uint32_t
+grub_get_rtc (void)
+{
+  static int calln = 0;
+  return calln++;
+}
+
+void
+grub_machine_init (void)
+{
+  grub_mm_init_region ((void *) GRUB_MACHINE_MEMORY_USABLE,
+                      RAMSIZE - (GRUB_MACHINE_MEMORY_USABLE & 0x7fffffff));
+  grub_install_get_time_ms (grub_rtc_get_time_ms);
+}
+
+void
+grub_machine_fini (void)
+{
+}
+
+void
+grub_exit (void)
+{
+  while (1);
+}
+
+void
+grub_halt (void)
+{
+  while (1);
+}
+
+void
+grub_reboot (void)
+{
+  while (1);
+}
+
+void
+grub_machine_set_prefix (void)
+{
+  grub_env_set ("prefix", grub_prefix);
+}
+
+extern char _start[];
+extern char _end[];
+
+grub_addr_t
+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/mips/qemu-mipssim/startup.S b/kern/mips/qemu-mipssim/startup.S
new file mode 100644 (file)
index 0000000..19de477
--- /dev/null
@@ -0,0 +1,55 @@
+/* startup.S - Startup code for the MIPS.  */
+/*
+ *  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/>.
+ */
+
+#include <grub/symbol.h>
+#include <grub/cpu/kernel.h>
+#include <grub/machine/memory.h>
+
+.extern __bss_start
+.extern _end
+       
+       .globl __start, _start, start
+__start:
+_start:
+start: 
+       b codestart
+       . = _start + GRUB_KERNEL_CPU_PREFIX
+
+VARIABLE(grub_prefix)
+       /* to be filled by grub-mkelfimage */
+
+       /*
+        *  Leave some breathing room for the prefix.
+        */
+
+       . = _start + GRUB_KERNEL_CPU_DATA_END
+codestart:
+       lui $t1, %hi(__bss_start)
+       addiu $t1, %lo(__bss_start)
+       lui $t2, %hi(_end)
+       addiu $t2, %lo(_end)
+
+bsscont:
+       sb $0,0($t1)
+       addiu $t1,$t1,1
+       sltu $t3,$t1,$t2
+       bne $3, $0, bsscont
+
+       li $sp, GRUB_MACHINE_MEMORY_STACK_HIGH
+       b grub_main
\ No newline at end of file
index 4b6ac981dafc077d483d723899e95cf80fe3356b..30f8bb91a16229f3f5ec4a1bd7bde5c74b3ece8d 100644 (file)
@@ -67,7 +67,10 @@ static struct serial_port serial_settings;
 #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)
+#elif defined (GRUB_MACHINE_MIPS_QEMU_MIPSSIM)
+static const grub_port_t serial_hw_io_addr[] = { 0x1fd003f8 };
+#define GRUB_SERIAL_PORT_NUM (ARRAY_SIZE(serial_hw_io_addr))
+#elif defined (GRUB_MACHINE_MIPS_QEMU_R4K)
 static const grub_port_t serial_hw_io_addr[] = { 0x140003f8 };
 #define GRUB_SERIAL_PORT_NUM (ARRAY_SIZE(serial_hw_io_addr))
 #else