sgi support

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2011-05-13 16:36:05 +02:00
parent 11d86592b7
commit 8906c3dd40
31 changed files with 1453 additions and 120 deletions

View File

@ -28,10 +28,10 @@ endif
if COND_mips_yeeloong
CFLAGS_PLATFORM += -mexplicit-relocs
CPPFLAGS_PLATFORM = -DUSE_ASCII_FAILBACK
CCASFLAGS_PLATFORM = -march=mips3
endif
if COND_mips
CFLAGS_PLATFORM += -mflush-func=grub_cpu_flush_cache
CCASFLAGS_PLATFORM = -march=mips3
endif
if COND_sparc64_ieee1275
CFLAGS_PLATFORM += -mno-app-regs

View File

@ -124,6 +124,7 @@ case "$target_cpu"-"$platform" in
sparc64-ieee1275) ;;
mips-qemu-mips) ;;
mips-yeeloong) ;;
mips-arc) ;;
*-emu) ;;
*) AC_MSG_ERROR([platform "$platform" is not supported for target CPU "$target_cpu"]) ;;
esac
@ -158,6 +159,7 @@ case "$platform" in
emu) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_EMU=1" ;;
yeeloong) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_YEELOONG=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
qemu-mips) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_QEMU_MIPS=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
mips-arc) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_ARC=1 -DGRUB_MACHINE_ARC=1" ;;
esac
case "$target_cpu" in
mips) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS=1" ;;
@ -952,6 +954,7 @@ AM_CONDITIONAL([COND_i386_multiboot], [test x$target_cpu = xi386 -a x$platform =
AM_CONDITIONAL([COND_x86_64_efi], [test x$target_cpu = xx86_64 -a x$platform = xefi])
AM_CONDITIONAL([COND_mips_yeeloong], [test x$target_cpu = xmips -a x$platform = xyeeloong])
AM_CONDITIONAL([COND_mips_qemu_mips], [test x$target_cpu = xmips -a x$platform = xqemu_mips])
AM_CONDITIONAL([COND_mips_arc], [test x$target_cpu = xmips -a x$platform = xarc])
AM_CONDITIONAL([COND_sparc64_ieee1275], [test x$target_cpu = xsparc64 -a x$platform = xieee1275])
AM_CONDITIONAL([COND_powerpc_ieee1275], [test x$target_cpu = xpowerpc -a x$platform = xieee1275])
AM_CONDITIONAL([COND_mips], [test x$target_cpu = xmips])

View File

@ -7,7 +7,7 @@
GRUB_PLATFORMS = [ "emu", "i386_pc", "i386_efi", "i386_qemu", "i386_coreboot",
"i386_multiboot", "i386_ieee1275", "x86_64_efi",
"mips_yeeloong", "sparc64_ieee1275",
"powerpc_ieee1275" ]
"powerpc_ieee1275", "mips_arc" ]
GROUPS = {}
@ -17,7 +17,7 @@ GROUPS["common"] = GRUB_PLATFORMS[:]
GROUPS["i386"] = [ "i386_pc", "i386_efi", "i386_qemu", "i386_coreboot", "i386_multiboot", "i386_ieee1275" ]
GROUPS["x86_64"] = [ "x86_64_efi" ]
GROUPS["x86"] = GROUPS["i386"] + GROUPS["x86_64"]
GROUPS["mips"] = [ "mips_yeeloong" ]
GROUPS["mips"] = [ "mips_yeeloong", "mips_arc" ]
GROUPS["sparc64"] = [ "sparc64_ieee1275" ]
GROUPS["powerpc"] = [ "powerpc_ieee1275" ]
@ -30,7 +30,7 @@ GROUPS["noemu"] = GRUB_PLATFORMS[:]; GROUPS["noemu"].remove("emu")
# Groups based on hardware features
GROUPS["cmos"] = GROUPS["x86"][:] + ["mips_yeeloong"]; GROUPS["cmos"].remove("i386_efi"); GROUPS["cmos"].remove("x86_64_efi")
GROUPS["pci"] = GROUPS["x86"] + GROUPS["mips"]
GROUPS["pci"] = GROUPS["x86"] + ["mips_yeeloong"]
GROUPS["usb"] = GROUPS["pci"]
# If gfxterm is main output console integrate it into kernel
@ -39,7 +39,7 @@ GROUPS["videomodules"] = GRUB_PLATFORMS[:];
for i in GROUPS["videoinkernel"]: GROUPS["videomodules"].remove(i)
# Similar for terminfo
GROUPS["terminfoinkernel"] = ["mips_yeeloong"] + GROUPS["ieee1275"];
GROUPS["terminfoinkernel"] = ["mips_yeeloong", "mips_arc"] + GROUPS["ieee1275"];
GROUPS["terminfomodule"] = GRUB_PLATFORMS[:];
for i in GROUPS["terminfoinkernel"]: GROUPS["terminfomodule"].remove(i)

View File

@ -125,9 +125,17 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/pit.h
endif
if COND_mips
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/cpu/kernel.h
endif
if COND_mips_arc
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/arc/arc.h
endif
if COND_mips_yeeloong
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/keyboard_layouts.h
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/kernel.h
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/cpu/cache.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/bitmap.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/video.h

View File

@ -35,6 +35,7 @@ kernel = {
mips_yeeloong_ldflags = '-Wl,-Ttext,0x80200000';
powerpc_ieee1275_ldflags = '-Wl,-Ttext,0x200000';
sparc64_ieee1275_ldflags = '-Wl,-Ttext,0x4400';
mips_arc_ldflags = '-Wl,-Ttext,0x8a000000';
mips_yeeloong_cppflags = '-DUSE_ASCII_FAILBACK';
i386_qemu_cppflags = '-DGRUB_BOOT_MACHINE_LINK_ADDR=$(GRUB_BOOT_MACHINE_LINK_ADDR)';
@ -48,7 +49,7 @@ kernel = {
i386_ieee1275_startup = kern/i386/ieee1275/startup.S;
i386_coreboot_startup = kern/i386/coreboot/startup.S;
i386_multiboot_startup = kern/i386/coreboot/startup.S;
mips_yeeloong_startup = kern/mips/startup.S;
mips_startup = kern/mips/startup.S;
sparc64_ieee1275_startup = kern/sparc64/ieee1275/crt0.S;
powerpc_ieee1275_startup = kern/powerpc/ieee1275/startup.S;
@ -81,7 +82,7 @@ kernel = {
i386_qemu = kern/generic/rtc_get_time_ms.c;
i386_coreboot = kern/generic/rtc_get_time_ms.c;
i386_multiboot = kern/generic/rtc_get_time_ms.c;
mips_yeeloong = kern/generic/rtc_get_time_ms.c;
mips = kern/generic/rtc_get_time_ms.c;
ieee1275 = disk/ieee1275/ofdisk.c;
ieee1275 = kern/ieee1275/cmain.c;
@ -136,13 +137,18 @@ kernel = {
i386_ieee1275 = kern/ieee1275/init.c;
mips = kern/mips/cache.S;
mips = kern/mips/dl.c;
mips = kern/mips/init.c;
mips_arc = kern/mips/arc/init.c;
mips_arc = term/arc/console.c;
mips_arc = disk/arc/arcdisk.c;
mips_yeeloong = term/ns8250.c;
mips_yeeloong = bus/bonito.c;
mips_yeeloong = bus/cs5536.c;
mips_yeeloong = bus/pci.c;
mips_yeeloong = kern/mips/cache.S;
mips_yeeloong = kern/mips/dl.c;
mips_yeeloong = kern/mips/init.c;
mips_yeeloong = kern/mips/yeeloong/init.c;
mips_yeeloong = term/at_keyboard.c;
mips_yeeloong = term/serial.c;
@ -297,10 +303,12 @@ image = {
cppflags = '-I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/xzembed';
mips_cppflags = '-I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/xzembed -DGRUB_EMBED_DECOMPRESSOR=1 -DGRUB_MACHINE_LINK_ADDR=0x80200000';
mips_arc_cppflags = '-I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/xzembed -DGRUB_EMBED_DECOMPRESSOR=1 -DGRUB_MACHINE_LINK_ADDR=0x8a000000';
mips_yeeloong_cppflags = '-I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/xzembed -DGRUB_EMBED_DECOMPRESSOR=1 -DGRUB_MACHINE_LINK_ADDR=0x80200000';
objcopyflags = '-O binary';
ldflags = '-static-libgcc -Wl,-Ttext,0x80100000';
mips_yeeloong_ldflags = '-static-libgcc -Wl,-Ttext,0x80100000';
mips_arc_ldflags = '-static-libgcc -Wl,-Ttext,0x89f00000';
ldadd = '-lgcc';
cflags = '-static-libgcc';
enable = mips;
@ -311,10 +319,12 @@ image = {
mips = boot/mips/startup_raw.S;
common = boot/decompressor/none.c;
mips_cppflags = '-DGRUB_EMBED_DECOMPRESSOR=1 -DGRUB_MACHINE_LINK_ADDR=0x80200000';
mips_arc_cppflags = '-DGRUB_EMBED_DECOMPRESSOR=1 -DGRUB_MACHINE_LINK_ADDR=0x8a000000';
mips_yeeloong_cppflags = '-DGRUB_EMBED_DECOMPRESSOR=1 -DGRUB_MACHINE_LINK_ADDR=0x80200000';
objcopyflags = '-O binary';
ldflags = '-static-libgcc -Wl,-Ttext,0x80100000';
mips_yeeloong_ldflags = '-static-libgcc -Wl,-Ttext,0x80100000';
mips_arc_ldflags = '-static-libgcc -Wl,-Ttext,0x89f00000';
ldadd = '-lgcc';
cflags = '-static-libgcc';
enable = mips;
@ -408,6 +418,13 @@ module = {
emu_condition = COND_GRUB_EMU_PCI;
};
module = {
name = lsdev;
common = commands/arc/lsdev.c;
enable = mips_arc;
};
library = {
name = libgnulib.a;
common = gnulib/regex.c;
@ -1117,6 +1134,7 @@ module = {
x86_efi = lib/efi/datetime.c;
sparc64_ieee1275 = lib/ieee1275/datetime.c;
powerpc_ieee1275 = lib/ieee1275/datetime.c;
mips_arc = lib/arc/datetime.c;
enable = noemu;
};
@ -1228,10 +1246,10 @@ module = {
x86_efi = mmap/efi/mmap.c;
mips_yeeloong = mmap/mips/yeeloong/uppermem.c;
mips = mmap/mips/uppermem.c;
enable = x86;
enable = mips_yeeloong;
enable = mips;
};
module = {
@ -1305,6 +1323,11 @@ module = {
common = partmap/sun.c;
};
module = {
name = part_dvh;
common = partmap/dvh.c;
};
module = {
name = part_bsd;
common = partmap/bsdlabel.c;

View File

@ -0,0 +1,53 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2011 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/dl.h>
#include <grub/misc.h>
#include <grub/command.h>
#include <grub/i18n.h>
#include <grub/arc/arc.h>
GRUB_MOD_LICENSE ("GPLv3+");
static grub_err_t
grub_cmd_lsdev (grub_command_t cmd __attribute__ ((unused)),
int argc __attribute__ ((unused)),
char **args __attribute__ ((unused)))
{
auto int hook (const char *name, const struct grub_arc_component *comp);
int hook (const char *name, const struct grub_arc_component *comp __attribute__ ((unused)))
{
grub_printf ("%s\n", name);
return 0;
}
grub_arc_iterate_devs (hook, 0);
return 0;
}
static grub_command_t cmd;
GRUB_MOD_INIT(lsdev)
{
cmd = grub_register_command ("lsdev", grub_cmd_lsdev, "",
N_("List devices."));
}
GRUB_MOD_FINI(lsdev)
{
grub_unregister_command (cmd);
}

View File

@ -0,0 +1,232 @@
/* ofdisk.c - Open Firmware disk access. */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2004,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/>.
*/
#include <grub/misc.h>
#include <grub/disk.h>
#include <grub/mm.h>
#include <grub/arc/arc.h>
static unsigned last_handle = 0;
static char *last_path = NULL;
static int
grub_arcdisk_iterate (int (*hook_in) (const char *name))
{
auto int hook (const char *name, const struct grub_arc_component *comp);
int hook (const char *name, const struct grub_arc_component *comp)
{
if (!(comp->type == GRUB_ARC_COMPONENT_TYPE_DISK
|| comp->type == GRUB_ARC_COMPONENT_TYPE_DISK
|| comp->type == GRUB_ARC_COMPONENT_TYPE_TAPE))
return 0;
return hook_in (name);
}
return grub_arc_iterate_devs (hook, 1);
}
#define RAW_SUFFIX "partition(10)"
static grub_err_t
reopen (const char *name)
{
unsigned handle;
if (last_path && grub_strcmp (last_path, name) == 0)
{
grub_dprintf ("arcdisk", "using already opened %s\n", name);
return GRUB_ERR_NONE;
}
if (GRUB_ARC_FIRMWARE_VECTOR->open (name, 0, &handle))
{
grub_dprintf ("arcdisk", "couldn't open %s\n", name);
return grub_error (GRUB_ERR_IO, "couldn't open %s", name);
}
if (last_path)
{
GRUB_ARC_FIRMWARE_VECTOR->close (last_handle);
grub_free (last_path);
last_path = NULL;
last_handle = 0;
}
last_path = grub_strdup (name);
if (!last_path)
return grub_errno;
last_handle = handle;
grub_dprintf ("arcdisk", "opened %s\n", name);
return GRUB_ERR_NONE;
}
static grub_err_t
grub_arcdisk_open (const char *name, grub_disk_t disk)
{
char *fullname, *optr;
const char *iptr;
int state = 0;
grub_err_t err;
int r;
struct grub_arc_fileinfo info;
if (grub_memcmp (name, "arc/", 4) != 0)
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not arc device");
fullname = grub_malloc (2 * grub_strlen (name) + sizeof (RAW_SUFFIX));
if (!fullname)
return grub_errno;
optr = fullname;
for (iptr = name + 4; *iptr; iptr++)
if (state == 0)
{
if (!grub_isdigit (*iptr))
*optr++ = *iptr;
else
{
*optr++ = '(';
*optr++ = *iptr;
state = 1;
}
}
else
{
if (grub_isdigit (*iptr))
*optr++ = *iptr;
else
{
*optr++ = ')';
state = 0;
}
}
if (state)
*optr++ = ')';
grub_memcpy (optr, RAW_SUFFIX, sizeof (RAW_SUFFIX));
disk->data = fullname;
grub_dprintf ("arcdisk", "opening %s\n", fullname);
err = reopen (fullname);
if (err)
return err;
r = GRUB_ARC_FIRMWARE_VECTOR->getfileinformation (last_handle, &info);
if (r)
{
grub_uint64_t res = 0;
int i;
grub_dprintf ("arcdisk", "couldn't retrieve size: %d\n", r);
for (i = 40; i >= 9; i--)
{
grub_uint64_t pos = res | (1ULL << i);
char buf[512];
long unsigned count = 0;
grub_dprintf ("arcdisk",
"seek to 0x%" PRIxGRUB_UINT64_T "\n", pos);
if (GRUB_ARC_FIRMWARE_VECTOR->seek (last_handle, &pos, 0))
continue;
if (GRUB_ARC_FIRMWARE_VECTOR->read (last_handle, buf,
0x200, &count))
continue;
if (count == 0)
continue;
res |= (1ULL << i);
}
grub_dprintf ("arcdisk",
"determined disk size 0x%" PRIxGRUB_UINT64_T "\n", res);
disk->total_sectors = (res + 0x200) >> 9;
}
else
disk->total_sectors = (info.end >> 9);
disk->id = 0; /* XXX */
return GRUB_ERR_NONE;
}
static void
grub_arcdisk_close (grub_disk_t disk)
{
grub_free (disk->data);
}
static grub_err_t
grub_arcdisk_read (grub_disk_t disk, grub_disk_addr_t sector,
grub_size_t size, char *buf)
{
grub_err_t err;
grub_uint64_t pos = sector << 9;
unsigned long count;
grub_uint64_t totl = size << 9;
int r;
err = reopen (disk->data);
if (err)
return err;
r = GRUB_ARC_FIRMWARE_VECTOR->seek (last_handle, &pos, 0);
if (r)
{
grub_dprintf ("arcdisk", "seek to 0x%" PRIxGRUB_UINT64_T " failed: %d\n",
pos, r);
return grub_error (GRUB_ERR_IO, "couldn't seek");
}
while (totl)
{
if (GRUB_ARC_FIRMWARE_VECTOR->read (last_handle, buf,
totl, &count))
return grub_error (GRUB_ERR_READ_ERROR, "read failed");
totl -= count;
buf += count;
}
return GRUB_ERR_NONE;
}
static grub_err_t
grub_arcdisk_write (grub_disk_t disk __attribute ((unused)),
grub_disk_addr_t sector __attribute ((unused)),
grub_size_t size __attribute ((unused)),
const char *buf __attribute ((unused)))
{
return GRUB_ERR_NOT_IMPLEMENTED_YET;
}
static struct grub_disk_dev grub_arcdisk_dev =
{
.name = "arcdisk",
.id = GRUB_DISK_DEVICE_ARCDISK_ID,
.iterate = grub_arcdisk_iterate,
.open = grub_arcdisk_open,
.close = grub_arcdisk_close,
.read = grub_arcdisk_read,
.write = grub_arcdisk_write,
.next = 0
};
void
grub_arcdisk_init (void)
{
grub_disk_dev_register (&grub_arcdisk_dev);
}
void
grub_arcdisk_fini (void)
{
if (last_path)
{
GRUB_ARC_FIRMWARE_VECTOR->close (last_handle);
grub_free (last_path);
last_path = NULL;
last_handle = 0;
}
grub_disk_dev_unregister (&grub_arcdisk_dev);
}

View File

@ -0,0 +1,203 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2009,2010 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/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/arc/console.h>
#include <grub/cpu/memory.h>
#include <grub/cpu/time.h>
#include <grub/memory.h>
#include <grub/term.h>
#include <grub/arc/arc.h>
#include <grub/offsets.h>
const char *type_names[] = {
#ifdef GRUB_CPU_WORDS_BIGENDIAN
NULL,
#endif
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
"eisa", "tc", "scsi", "dti", "multi", "disk", "tape", "cdrom", "worm",
"serial", "net", "video", "par", "point", "key", "audio", "other",
"rdisk", "fdisk", "tape", "modem", "monitor", "print", "pointer",
"keyboard", "term", "other", "line", "network", NULL
};
static int
iterate_rec (const char *prefix, const struct grub_arc_component *parent,
int (*hook) (const char *name,
const struct grub_arc_component *comp),
int alt_names)
{
const struct grub_arc_component *comp;
FOR_ARC_CHILDREN(comp, parent)
{
char *name;
const char *cname = NULL;
if (comp->type < ARRAY_SIZE (type_names))
cname = type_names[comp->type];
if (!cname)
cname = "unknown";
if (alt_names)
name = grub_xasprintf ("%s/%s%d", prefix, cname, comp->key);
else
name = grub_xasprintf ("%s%s(%d)", prefix, cname, comp->key);
if (!name)
return 1;
if (hook (name, comp))
{
grub_free (name);
return 1;
}
if (iterate_rec ((parent ? name : prefix), comp, hook, alt_names))
{
grub_free (name);
return 1;
}
grub_free (name);
}
return 0;
}
int
grub_arc_iterate_devs (int (*hook) (const char *name,
const struct grub_arc_component *comp),
int alt_names)
{
return iterate_rec ((alt_names ? "arc" : ""), NULL, hook, alt_names);
}
grub_err_t
grub_machine_mmap_iterate (grub_memory_hook_t hook)
{
struct grub_arc_memory_descriptor *cur = NULL;
while (1)
{
grub_memory_type_t type;
cur = GRUB_ARC_FIRMWARE_VECTOR->getmemorydescriptor (cur);
if (!cur)
return GRUB_ERR_NONE;
switch (cur->type)
{
case GRUB_ARC_MEMORY_EXCEPTION_BLOCK:
case GRUB_ARC_MEMORY_SYSTEM_PARAMETER_BLOCK:
case GRUB_ARC_MEMORY_FW_PERMANENT:
default:
type = GRUB_MEMORY_RESERVED;
break;
case GRUB_ARC_MEMORY_FW_TEMPORARY:
case GRUB_ARC_MEMORY_FREE:
case GRUB_ARC_MEMORY_LOADED:
case GRUB_ARC_MEMORY_FREE_CONTIGUOUS:
type = GRUB_MEMORY_AVAILABLE;
break;
case GRUB_ARC_MEMORY_BADRAM:
type = GRUB_MEMORY_BADRAM;
break;
}
if (hook (((grub_uint64_t) cur->start_page) << 12,
((grub_uint64_t) cur->num_pages) << 12, type))
return GRUB_ERR_NONE;
}
}
void
grub_machine_init (void)
{
struct grub_arc_memory_descriptor *cur = NULL;
grub_console_init_early ();
/* FIXME: measure this. */
grub_arch_cpuclock = 64000000;
grub_install_get_time_ms (grub_rtc_get_time_ms);
while (1)
{
grub_uint64_t start, end;
cur = GRUB_ARC_FIRMWARE_VECTOR->getmemorydescriptor (cur);
if (!cur)
break;
if (cur->type != GRUB_ARC_MEMORY_FREE
&& cur->type != GRUB_ARC_MEMORY_LOADED
&& cur->type != GRUB_ARC_MEMORY_FREE_CONTIGUOUS)
continue;
start = ((grub_uint64_t) cur->start_page) << 12;
end = ((grub_uint64_t) cur->num_pages) << 12;
end += start;
if ((grub_uint64_t) end > (GRUB_KERNEL_MIPS_ARC_LINK_ADDR & 0x1fffffff))
end = (GRUB_KERNEL_MIPS_ARC_LINK_ADDR & 0x1fffffff);
if (end > start)
grub_mm_init_region ((void *) (grub_addr_t) (start | 0x80000000),
end - start);
}
grub_console_init_lately ();
grub_arcdisk_init ();
}
void
grub_machine_fini (void)
{
}
void
grub_halt (void)
{
GRUB_ARC_FIRMWARE_VECTOR->powerdown ();
grub_millisleep (1500);
grub_printf ("Shutdown failed\n");
grub_refresh ();
while (1);
}
void
grub_exit (void)
{
GRUB_ARC_FIRMWARE_VECTOR->exit ();
grub_millisleep (1500);
grub_printf ("Exit failed\n");
grub_refresh ();
while (1);
}
void
grub_reboot (void)
{
GRUB_ARC_FIRMWARE_VECTOR->restart ();
grub_millisleep (1500);
grub_printf ("Reboot failed\n");
grub_refresh ();
while (1);
}

View File

@ -18,6 +18,24 @@
#include <grub/kernel.h>
#include <grub/env.h>
#include <grub/cpu/time.h>
#include <grub/cpu/mips.h>
/* FIXME: use interrupt to count high. */
grub_uint64_t
grub_get_rtc (void)
{
static grub_uint32_t high = 0;
static grub_uint32_t last = 0;
grub_uint32_t low;
asm volatile ("mfc0 %0, " GRUB_CPU_MIPS_COP0_TIMER_COUNT : "=r" (low));
if (low < last)
high++;
last = low;
return (((grub_uint64_t) high) << 32) | low;
}
void
grub_machine_set_prefix (void)

View File

@ -31,6 +31,7 @@
#include <grub/cs5536.h>
#include <grub/term.h>
#include <grub/machine/ec.h>
#include <grub/cpu/memory.h>
extern void grub_video_sm712_init (void);
extern void grub_video_init (void);
@ -43,22 +44,6 @@ extern void grub_terminfo_init (void);
extern void grub_keylayouts_init (void);
extern void grub_boot_init (void);
/* FIXME: use interrupt to count high. */
grub_uint64_t
grub_get_rtc (void)
{
static grub_uint32_t high = 0;
static grub_uint32_t last = 0;
grub_uint32_t low;
asm volatile ("mfc0 %0, " GRUB_CPU_LOONGSON_COP0_TIMER_COUNT : "=r" (low));
if (low < last)
high++;
last = low;
return (((grub_uint64_t) high) << 32) | low;
}
grub_err_t
grub_machine_mmap_iterate (grub_memory_hook_t hook)
{

View File

@ -0,0 +1,48 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2011 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/datetime.h>
#include <grub/dl.h>
#include <grub/misc.h>
#include <grub/arc/arc.h>
GRUB_MOD_LICENSE ("GPLv3+");
grub_err_t
grub_get_datetime (struct grub_datetime *datetime)
{
struct grub_arc_timeinfo *dt;
grub_memset (datetime, 0, sizeof (*datetime));
dt = GRUB_ARC_FIRMWARE_VECTOR->gettime ();
datetime->year = dt->y;
datetime->month = dt->m;
datetime->day = dt->d;
datetime->hour = dt->h;
datetime->minute = dt->min;
datetime->second = dt->s;
return 0;
}
grub_err_t
grub_set_datetime (struct grub_datetime *datetime __attribute__ ((unused)))
{
return grub_error (GRUB_ERR_IO, "setting time isn't supported");
}

View File

@ -20,7 +20,7 @@
#include <grub/memory.h>
#include <grub/mm.h>
#include <grub/misc.h>
#include <grub/machine/memory.h>
#include <grub/cpu/memory.h>
grub_uint64_t
grub_mmap_get_lower (void)

124
grub-core/partmap/dvh.c Normal file
View File

@ -0,0 +1,124 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2002,2005,2006,2007,2011 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/partition.h>
#include <grub/disk.h>
#include <grub/mm.h>
#include <grub/misc.h>
#include <grub/dl.h>
#include <grub/symbol.h>
#include <grub/types.h>
#include <grub/err.h>
GRUB_MOD_LICENSE ("GPLv3+");
#define DVH_MAGIC 0x0be5a941
struct grub_dvh_partition_descriptor
{
grub_uint32_t length;
grub_uint32_t start;
grub_uint32_t type;
} __attribute__ ((packed));
struct grub_dvh_block
{
grub_uint32_t magic;
grub_uint8_t unused[308];
struct grub_dvh_partition_descriptor parts[16];
grub_uint32_t checksum;
grub_uint32_t unused2;
} __attribute__ ((packed));
static struct grub_partition_map grub_dvh_partition_map;
/* Verify checksum (true=ok). */
static int
grub_dvh_is_valid (struct grub_dvh_block *label)
{
grub_uint32_t *pos;
grub_uint32_t sum = 0;
for (pos = (grub_uint32_t *) label;
pos < (grub_uint32_t *) (label + 1);
pos++)
sum += *pos;
return ! sum;
}
static grub_err_t
dvh_partition_map_iterate (grub_disk_t disk,
int (*hook) (grub_disk_t disk,
const grub_partition_t partition))
{
struct grub_partition p;
struct grub_dvh_block block;
unsigned partnum;
grub_err_t err;
p.partmap = &grub_dvh_partition_map;
err = grub_disk_read (disk, 0, 0, sizeof (struct grub_dvh_block),
&block);
if (err)
return err;
if (DVH_MAGIC != grub_be_to_cpu32 (block.magic))
return grub_error (GRUB_ERR_BAD_PART_TABLE, "not a dvh partition table");
if (! grub_dvh_is_valid (&block))
return grub_error (GRUB_ERR_BAD_PART_TABLE, "invalid checksum");
/* Maybe another error value would be better, because partition
table _is_ recognized but invalid. */
for (partnum = 0; partnum < ARRAY_SIZE (block.parts); partnum++)
{
if (block.parts[partnum].length == 0)
continue;
if (partnum == 10)
continue;
p.start = grub_be_to_cpu32 (block.parts[partnum].start);
p.len = grub_be_to_cpu32 (block.parts[partnum].length);
p.number = p.index = partnum;
if (hook (disk, &p))
break;
}
return grub_errno;
}
/* Partition map type. */
static struct grub_partition_map grub_dvh_partition_map =
{
.name = "dvh",
.iterate = dvh_partition_map_iterate,
};
GRUB_MOD_INIT(part_dvh)
{
grub_partition_map_register (&grub_dvh_partition_map);
}
GRUB_MOD_FINI(part_dvh)
{
grub_partition_map_unregister (&grub_dvh_partition_map);
}

View File

@ -0,0 +1,123 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2011 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/arc/arc.h>
#include <grub/arc/console.h>
#include <grub/term.h>
#include <grub/terminfo.h>
/* FIXME: use unicode. */
static int
readkey (struct grub_term_input *term __attribute__ ((unused)))
{
unsigned long count;
char chr;
if (GRUB_ARC_FIRMWARE_VECTOR->get_read_status (GRUB_ARC_STDIN))
return -1;
if (GRUB_ARC_FIRMWARE_VECTOR->read (GRUB_ARC_STDIN, &chr, 1, &count))
return -1;
if (!count)
return -1;
return chr;
}
static void
put (struct grub_term_output *term __attribute__ ((unused)), const int c)
{
unsigned long count;
char chr = c;
GRUB_ARC_FIRMWARE_VECTOR->write (GRUB_ARC_STDOUT, &chr, 1, &count);
}
static struct grub_terminfo_output_state grub_console_terminfo_output;
static grub_err_t
grub_console_init_output (struct grub_term_output *term)
{
struct grub_arc_display_status *info = NULL;
if (GRUB_ARC_SYSTEM_PARAMETER_BLOCK->firmware_vector_length
>= ((char *) (&GRUB_ARC_FIRMWARE_VECTOR->getdisplaystatus + 1)
- (char *) GRUB_ARC_FIRMWARE_VECTOR)
&& GRUB_ARC_FIRMWARE_VECTOR->getdisplaystatus)
info = GRUB_ARC_FIRMWARE_VECTOR->getdisplaystatus (GRUB_ARC_STDOUT);
if (info)
{
grub_console_terminfo_output.width = info->w;
grub_console_terminfo_output.height = info->h;
}
grub_terminfo_output_init (term);
return 0;
}
static struct grub_terminfo_input_state grub_console_terminfo_input =
{
.readkey = readkey
};
static struct grub_terminfo_output_state grub_console_terminfo_output =
{
.put = put,
.width = 80,
.height = 36
};
static struct grub_term_input grub_console_term_input =
{
.name = "console",
.init = grub_terminfo_input_init,
.getkey = grub_terminfo_getkey,
.data = &grub_console_terminfo_input
};
static struct grub_term_output grub_console_term_output =
{
.name = "console",
.init = grub_console_init_output,
.putchar = grub_terminfo_putchar,
.getxy = grub_terminfo_getxy,
.getwh = grub_terminfo_getwh,
.gotoxy = grub_terminfo_gotoxy,
.cls = grub_terminfo_cls,
.setcolorstate = grub_terminfo_setcolorstate,
.setcursor = grub_terminfo_setcursor,
.flags = GRUB_TERM_CODE_TYPE_ASCII,
.data = &grub_console_terminfo_output,
.normal_color = GRUB_TERM_DEFAULT_NORMAL_COLOR,
.highlight_color = GRUB_TERM_DEFAULT_HIGHLIGHT_COLOR,
};
void
grub_console_init_early (void)
{
grub_term_register_input ("console", &grub_console_term_input);
grub_term_register_output ("console", &grub_console_term_output);
}
void grub_terminfo_init (void);
void
grub_console_init_lately (void)
{
grub_terminfo_init ();
grub_terminfo_output_register (&grub_console_term_output, "arc");
}

View File

@ -36,6 +36,9 @@
GRUB_MOD_LICENSE ("GPLv3+");
#define ANSI_C0 0x9b
#define ANSI_C0_STR "\x9b"
static struct grub_term_output *terminfo_outputs;
/* Get current terminfo name. */
@ -123,6 +126,20 @@ grub_terminfo_set_current (struct grub_term_output *term,
return grub_errno;
}
if (grub_strcmp ("arc", str) == 0)
{
data->name = grub_strdup ("arc");
data->gotoxy = grub_strdup (ANSI_C0_STR "%i%p1%d;%p2%dH");
data->cls = grub_strdup (ANSI_C0_STR "2J");
data->reverse_video_on = grub_strdup (ANSI_C0_STR "7m");
data->reverse_video_off = grub_strdup (ANSI_C0_STR "0m");
data->cursor_on = 0;
data->cursor_off = 0;
data->setcolor = grub_strdup (ANSI_C0_STR "3%p1%dm"
ANSI_C0_STR "4%p2%dm");
return grub_errno;
}
if (grub_strcmp ("ieee1275", str) == 0)
{
data->name = grub_strdup ("ieee1275");
@ -369,8 +386,6 @@ grub_terminfo_getwh (struct grub_term_output *term)
return (data->width << 8) | data->height;
}
#define ANSI_C0 0x9b
static void
grub_terminfo_readkey (struct grub_term_input *term, int *keys, int *len,
int (*readkey) (struct grub_term_input *term))

244
include/grub/arc/arc.h Normal file
View File

@ -0,0 +1,244 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2011 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_ARC_HEADER
#define GRUB_ARC_HEADER 1
#include <grub/types.h>
#include <grub/symbol.h>
struct grub_arc_memory_descriptor
{
grub_uint32_t type;
grub_uint32_t start_page;
grub_uint32_t num_pages;
};
enum grub_arc_memory_type
{
GRUB_ARC_MEMORY_EXCEPTION_BLOCK,
GRUB_ARC_MEMORY_SYSTEM_PARAMETER_BLOCK,
#ifdef GRUB_CPU_WORDS_BIGENDIAN
GRUB_ARC_MEMORY_FREE_CONTIGUOUS,
#endif
GRUB_ARC_MEMORY_FREE,
GRUB_ARC_MEMORY_BADRAM,
GRUB_ARC_MEMORY_LOADED, GRUB_ARC_MEMORY_FW_TEMPORARY,
GRUB_ARC_MEMORY_FW_PERMANENT,
#ifndef GRUB_CPU_WORDS_BIGENDIAN
GRUB_ARC_MEMORY_FREE_CONTIGUOUS,
#endif
} grub_arc_memory_type_t;
struct grub_arc_timeinfo
{
grub_uint16_t y;
grub_uint16_t m;
grub_uint16_t d;
grub_uint16_t h;
grub_uint16_t min;
grub_uint16_t s;
grub_uint16_t ms;
};
struct grub_arc_display_status
{
grub_uint16_t x;
grub_uint16_t y;
grub_uint16_t w;
grub_uint16_t h;
grub_uint8_t fgcolor;
grub_uint8_t bgcolor;
grub_uint8_t high_intensity;
grub_uint8_t underscored;
grub_uint8_t reverse_video;
};
struct grub_arc_component
{
unsigned class;
unsigned type;
unsigned flags;
grub_uint16_t version;
grub_uint16_t rev;
grub_uint32_t key;
grub_uint32_t affinity;
grub_uint32_t configdatasize;
grub_uint32_t idlen;
const char *idstr;
};
enum
{
#ifdef GRUB_CPU_WORDS_BIGENDIAN
GRUB_ARC_COMPONENT_TYPE_ARC = 1,
#else
GRUB_ARC_COMPONENT_TYPE_ARC,
#endif
GRUB_ARC_COMPONENT_TYPE_CPU,
GRUB_ARC_COMPONENT_TYPE_FPU,
GRUB_ARC_COMPONENT_TYPE_PRI_I_CACHE,
GRUB_ARC_COMPONENT_TYPE_PRI_D_CACHE,
GRUB_ARC_COMPONENT_TYPE_SEC_I_CACHE,
GRUB_ARC_COMPONENT_TYPE_SEC_D_CACHE,
GRUB_ARC_COMPONENT_TYPE_SEC_CACHE,
GRUB_ARC_COMPONENT_TYPE_EISA,
GRUB_ARC_COMPONENT_TYPE_TCA,
GRUB_ARC_COMPONENT_TYPE_SCSI,
GRUB_ARC_COMPONENT_TYPE_DTIA,
GRUB_ARC_COMPONENT_TYPE_MULTIFUNC,
GRUB_ARC_COMPONENT_TYPE_DISK_CONTROLLER,
GRUB_ARC_COMPONENT_TYPE_TAPE_CONTROLLER,
GRUB_ARC_COMPONENT_TYPE_CDROM_CONTROLLER,
GRUB_ARC_COMPONENT_TYPE_WORM_CONTROLLER,
GRUB_ARC_COMPONENT_TYPE_SERIAL_CONTROLLER,
GRUB_ARC_COMPONENT_TYPE_NET_CONTROLLER,
GRUB_ARC_COMPONENT_TYPE_DISPLAY_CONTROLLER,
GRUB_ARC_COMPONENT_TYPE_PARALLEL_CONTROLLER,
GRUB_ARC_COMPONENT_TYPE_POINTER_CONTROLLER,
GRUB_ARC_COMPONENT_TYPE_KBD_CONTROLLER,
GRUB_ARC_COMPONENT_TYPE_AUDIO_CONTROLLER,
GRUB_ARC_COMPONENT_TYPE_OTHER_CONTROLLER,
GRUB_ARC_COMPONENT_TYPE_DISK,
GRUB_ARC_COMPONENT_TYPE_FLOPPY,
GRUB_ARC_COMPONENT_TYPE_TAPE,
GRUB_ARC_COMPONENT_TYPE_MODEM,
GRUB_ARC_COMPONENT_TYPE_MONITOR,
GRUB_ARC_COMPONENT_TYPE_PRINTER,
GRUB_ARC_COMPONENT_TYPE_POINTER,
GRUB_ARC_COMPONENT_TYPE_KBD,
GRUB_ARC_COMPONENT_TYPE_TERMINAL,
GRUB_ARC_COMPONENT_TYPE_OTHER_PERIPHERAL,
GRUB_ARC_COMPONENT_TYPE_LINE,
GRUB_ARC_COMPONENT_TYPE_NET,
GRUB_ARC_COMPONENT_TYPE_MEMORY_UNIT,
};
struct grub_arc_fileinfo
{
grub_uint64_t start;
grub_uint64_t end;
grub_uint64_t current;
grub_uint32_t type;
grub_uint32_t fnamelength;
grub_uint8_t attr;
char filename[32];
};
struct grub_arc_firmware_vector
{
/* 0x00. */
void *load;
void *invoke;
void *execute;
void *halt;
/* 0x10. */
void (*powerdown) (void);
void (*restart) (void);
void (*reboot) (void);
void (*exit) (void);
/* 0x20. */
void *reserved1;
const struct grub_arc_component * (*getpeer) (const struct grub_arc_component *comp);
const struct grub_arc_component * (*getchild) (const struct grub_arc_component *comp);
void *getparent;
/* 0x30. */
void *getconfigurationdata;
void *addchild;
void *deletecomponent;
void *getcomponent;
/* 0x40. */
void *saveconfiguration;
void *getsystemid;
struct grub_arc_memory_descriptor *(*getmemorydescriptor) (struct grub_arc_memory_descriptor *current);
void *reserved2;
/* 0x50. */
struct grub_arc_timeinfo *(*gettime) (void);
void *getrelativetime;
void *getdirectoryentry;
int (*open) (const char *path, int mode, unsigned *fileno);
/* 0x60. */
int (*close) (unsigned fileno);
int (*read) (unsigned fileno, void *buf, unsigned long n,
unsigned long *count);
int (*get_read_status) (unsigned fileno);
int (*write) (unsigned fileno, void *buf, unsigned long n,
unsigned long *count);
/* 0x70. */
int (*seek) (unsigned fileno, grub_uint64_t *pos, int mode);
void *mount;
void *getenvironmentvariable;
void *setenvironmentvariable;
/* 0x80. */
int (*getfileinformation) (unsigned fileno, struct grub_arc_fileinfo *info);
void *setfileinformation;
void *flushallcaches;
void *testunicodecharacter;
/* 0x90. */
struct grub_arc_display_status * (*getdisplaystatus) (unsigned fileno);
};
struct grub_arc_adapter
{
grub_uint32_t adapter_type;
grub_uint32_t adapter_vector_length;
void *adapter_vector;
};
struct grub_arc_system_parameter_block
{
grub_uint32_t signature;
grub_uint32_t length;
grub_uint16_t version;
grub_uint16_t revision;
void *restartblock;
void *debugblock;
void *gevector;
void *utlbmissvector;
grub_uint32_t firmware_vector_length;
struct grub_arc_firmware_vector *firmwarevector;
grub_uint32_t private_vector_length;
void *private_vector;
grub_uint32_t adapter_count;
struct grub_arc_adapter adapters[0];
};
#define GRUB_ARC_SYSTEM_PARAMETER_BLOCK ((struct grub_arc_system_parameter_block *) 0xa0001000)
#define GRUB_ARC_FIRMWARE_VECTOR (GRUB_ARC_SYSTEM_PARAMETER_BLOCK->firmwarevector)
#define GRUB_ARC_STDIN 0
#define GRUB_ARC_STDOUT 1
int EXPORT_FUNC (grub_arc_iterate_devs) (int (*hook) (const char *name, const struct grub_arc_component *comp), int alt_names);
#define FOR_ARC_CHILDREN(comp, parent) for (comp = GRUB_ARC_FIRMWARE_VECTOR->getchild (parent); comp; comp = GRUB_ARC_FIRMWARE_VECTOR->getpeer (comp))
extern void grub_arcdisk_init (void);
extern void grub_arcdisk_fini (void);
#endif

View File

@ -0,0 +1,31 @@
/*
* 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_CONSOLE_MACHINE_HEADER
#define GRUB_CONSOLE_MACHINE_HEADER 1
#include <grub/symbol.h>
/* Initialize the console system. */
void grub_console_init_early (void);
void grub_console_init_lately (void);
/* Finish the console system. */
void grub_console_fini (void);
#endif /* ! GRUB_CONSOLE_MACHINE_HEADER */

View File

@ -42,7 +42,8 @@ enum grub_disk_dev_id
GRUB_DISK_DEVICE_PXE_ID,
GRUB_DISK_DEVICE_SCSI_ID,
GRUB_DISK_DEVICE_FILE_ID,
GRUB_DISK_DEVICE_LUKS_ID
GRUB_DISK_DEVICE_LUKS_ID,
GRUB_DISK_DEVICE_ARCDISK_ID,
};
struct grub_disk;

View File

@ -0,0 +1,2 @@
#include <grub/cpu/kernel.h>

View File

@ -0,0 +1,42 @@
/*
* 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
#define GRUB_MACHINE_MEMORY_STACK_HIGH 0x8bfffff0
#ifndef ASM_FILE
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

View File

@ -0,0 +1,30 @@
/*
* 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_halt) (void) __attribute__ ((noreturn));
#endif
#endif /* ! GRUB_KERNEL_MACHINE_HEADER */

View File

@ -19,11 +19,7 @@
#ifndef GRUB_LOONGSON_CPU_HEADER
#define GRUB_LOONGSON_CPU_HEADER 1
#ifdef ASM_FILE
#define GRUB_CPU_REGISTER_WRAP(x) x
#else
#define GRUB_CPU_REGISTER_WRAP(x) #x
#endif
#include <grub/cpu/mips.h>
#define GRUB_CPU_LOONGSON_FLASH_START 0xbfc00000
#define GRUB_CPU_LOONGSON_FLASH_TLB_REFILL 0xbfc00200
@ -68,7 +64,6 @@
#define GRUB_CPU_LOONGSON_SECONDARY_CACHE_LOG_SIZE 19
#define GRUB_CPU_LOONGSON_COP0_BADVADDR GRUB_CPU_REGISTER_WRAP($8)
#define GRUB_CPU_LOONGSON_COP0_TIMER_COUNT GRUB_CPU_REGISTER_WRAP($9)
#define GRUB_CPU_LOONGSON_COP0_CAUSE GRUB_CPU_REGISTER_WRAP($13)
#define GRUB_CPU_LOONGSON_COP0_EPC GRUB_CPU_REGISTER_WRAP($14)
#define GRUB_CPU_LOONGSON_COP0_CACHE_TAGLO GRUB_CPU_REGISTER_WRAP($28)

View File

@ -1 +1,60 @@
#include <grub/machine/memory.h>
/*
* 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_ARCH_LOWMEMVSTART 0x80000000
#define GRUB_ARCH_LOWMEMPSTART 0x00000000
#define GRUB_ARCH_LOWMEMMAXSIZE 0x10000000
#define GRUB_ARCH_HIGHMEMPSTART 0x10000000
#ifndef ASM_FILE
typedef grub_addr_t grub_phys_addr_t;
static inline grub_phys_addr_t
grub_vtop (void *a)
{
return ((grub_phys_addr_t) a) & 0x1fffffff;
}
static inline void *
grub_map_memory (grub_phys_addr_t a, grub_size_t size __attribute__ ((unused)))
{
return (void *) (a | 0x80000000);
}
static inline void
grub_unmap_memory (void *a __attribute__ ((unused)),
grub_size_t size __attribute__ ((unused)))
{
}
grub_uint64_t grub_mmap_get_lower (void);
grub_uint64_t grub_mmap_get_upper (void);
#endif
#endif

30
include/grub/mips/mips.h Normal file
View File

@ -0,0 +1,30 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2010 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_REGISTORS_CPU_HEADER
#define GRUB_REGISTORS_CPU_HEADER 1
#ifdef ASM_FILE
#define GRUB_CPU_REGISTER_WRAP(x) x
#else
#define GRUB_CPU_REGISTER_WRAP(x) #x
#endif
#define GRUB_CPU_MIPS_COP0_TIMER_COUNT GRUB_CPU_REGISTER_WRAP($9)
#endif

View File

@ -1,6 +1,37 @@
#ifdef GRUB_MACHINE_EMU
/*
* 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_CPU_TIME_HEADER
#define KERNEL_CPU_TIME_HEADER 1
#ifndef GRUB_UTIL
#define GRUB_TICKS_PER_SECOND (grub_arch_cpuclock / 2)
/* Return the real time in ticks. */
grub_uint64_t EXPORT_FUNC (grub_get_rtc) (void);
extern grub_uint32_t EXPORT_VAR (grub_arch_cpuclock);
#endif
static inline void
grub_cpu_idle(void)
{
}
#endif

View File

@ -1,31 +1 @@
/*
* 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) __attribute__ ((noreturn));
void EXPORT_FUNC (grub_halt) (void) __attribute__ ((noreturn));
#endif
#endif /* ! GRUB_KERNEL_MACHINE_HEADER */
#include <grub/cpu/kernel.h>

View File

@ -19,43 +19,16 @@
#ifndef GRUB_MEMORY_MACHINE_HEADER
#define GRUB_MEMORY_MACHINE_HEADER 1
#define GRUB_MACHINE_MEMORY_STACK_HIGH 0x801ffff0
#ifndef ASM_FILE
#include <grub/symbol.h>
#include <grub/err.h>
#include <grub/types.h>
#endif
#define GRUB_MACHINE_MEMORY_STACK_HIGH 0x801ffff0
#define GRUB_ARCH_LOWMEMVSTART 0x80000000
#define GRUB_ARCH_LOWMEMPSTART 0x00000000
#define GRUB_ARCH_LOWMEMMAXSIZE 0x10000000
#define GRUB_ARCH_HIGHMEMPSTART 0x10000000
#ifndef ASM_FILE
typedef grub_addr_t grub_phys_addr_t;
static inline grub_phys_addr_t
grub_vtop (void *a)
{
return ((grub_phys_addr_t) a) & 0x1fffffff;
}
static inline void *
grub_map_memory (grub_phys_addr_t a, grub_size_t size __attribute__ ((unused)))
{
return (void *) (a | 0x80000000);
}
static inline void
grub_unmap_memory (void *a __attribute__ ((unused)),
grub_size_t size __attribute__ ((unused)))
{
}
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)),
@ -70,9 +43,6 @@ grub_machine_mmap_unregister (int handle __attribute__ ((unused)))
return GRUB_ERR_NONE;
}
grub_uint64_t grub_mmap_get_lower (void);
grub_uint64_t grub_mmap_get_upper (void);
extern grub_uint32_t EXPORT_VAR (grub_arch_memsize);
extern grub_uint32_t EXPORT_VAR (grub_arch_highmemsize);

View File

@ -20,18 +20,8 @@
#define KERNEL_MACHINE_TIME_HEADER 1
#include <grub/symbol.h>
#define GRUB_TICKS_PER_SECOND (grub_arch_cpuclock / 2)
/* Return the real time in ticks. */
grub_uint64_t EXPORT_FUNC (grub_get_rtc) (void);
#include <grub/cpu/time.h>
extern grub_uint32_t EXPORT_VAR (grub_arch_busclock);
extern grub_uint32_t EXPORT_VAR (grub_arch_cpuclock);
static inline void
grub_cpu_idle(void)
{
}
#endif /* ! KERNEL_MACHINE_TIME_HEADER */

View File

@ -111,6 +111,17 @@
#define GRUB_KERNEL_MIPS_YEELOONG_PREFIX 0x0c
#define GRUB_KERNEL_MIPS_YEELOONG_PREFIX_END 0x54
#define GRUB_KERNEL_MIPS_ARC_LINK_ADDR 0x8a000000
#define GRUB_KERNEL_MIPS_ARC_LINK_ALIGN 32
#define GRUB_KERNEL_MIPS_ARC_COMPRESSED_SIZE 0x8
#define GRUB_KERNEL_MIPS_ARC_UNCOMPRESSED_SIZE 0xc
#define GRUB_KERNEL_MIPS_ARC_TOTAL_MODULE_SIZE 0x08
#define GRUB_KERNEL_MIPS_ARC_PREFIX 0x0c
#define GRUB_KERNEL_MIPS_ARC_PREFIX_END 0x54
/* The offset of GRUB_PREFIX. */
#define GRUB_KERNEL_I386_EFI_PREFIX 0x8
@ -145,6 +156,7 @@
#define GRUB_KERNEL_POWERPC_IEEE1275_MOD_ALIGN 0x1000
#define GRUB_KERNEL_MIPS_YEELOONG_MOD_ALIGN 0x1
#define GRUB_KERNEL_MIPS_ARC_MOD_ALIGN 0x1
/* Minimal gap between _end and the start of the modules. It's a hack
for PowerMac to prevent "CLAIM failed" error. The real fix is to

View File

@ -65,7 +65,7 @@ struct image_target_desc
IMAGE_I386_PC, IMAGE_EFI, IMAGE_COREBOOT,
IMAGE_SPARC64_AOUT, IMAGE_SPARC64_RAW, IMAGE_I386_IEEE1275,
IMAGE_YEELOONG_ELF, IMAGE_QEMU, IMAGE_PPC, IMAGE_YEELOONG_FLASH,
IMAGE_I386_PC_PXE
IMAGE_I386_PC_PXE, IMAGE_MIPS_ARC
} id;
enum
{
@ -355,6 +355,27 @@ struct image_target_desc image_targets[] =
.install_bsd_part = TARGET_NO_FIELD,
.link_addr = GRUB_KERNEL_SPARC64_IEEE1275_LINK_ADDR
},
{
.name = "mips-arc",
.voidp_sizeof = 4,
.bigendian = 1,
.id = IMAGE_MIPS_ARC,
.flags = PLATFORM_FLAGS_DECOMPRESSORS,
.prefix = GRUB_KERNEL_MIPS_ARC_PREFIX,
.prefix_end = GRUB_KERNEL_MIPS_ARC_PREFIX_END,
.raw_size = 0,
.total_module_size = GRUB_KERNEL_MIPS_ARC_TOTAL_MODULE_SIZE,
.compressed_size = TARGET_NO_FIELD,
.kernel_image_size = TARGET_NO_FIELD,
.section_align = 1,
.vaddr_offset = 0,
.install_dos_part = TARGET_NO_FIELD,
.install_bsd_part = TARGET_NO_FIELD,
.link_addr = GRUB_KERNEL_MIPS_ARC_LINK_ADDR,
.elf_target = EM_MIPS,
.link_align = GRUB_KERNEL_MIPS_ARC_LINK_ALIGN,
.default_compression = COMPRESSION_NONE
},
};
#define grub_target_to_host32(x) (grub_target_to_host32_real (image_target, (x)))
@ -1217,6 +1238,76 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
core_size = rom_size;
}
break;
case IMAGE_MIPS_ARC:
{
char *ecoff_img;
struct ecoff_header {
grub_uint16_t magic;
grub_uint16_t nsec;
grub_uint32_t time;
grub_uint32_t syms;
grub_uint32_t nsyms;
grub_uint16_t opt;
grub_uint16_t flags;
grub_uint16_t magic2;
grub_uint16_t version;
grub_uint32_t textsize;
grub_uint32_t datasize;
grub_uint32_t bsssize;
grub_uint32_t entry;
grub_uint32_t text_start;
grub_uint32_t data_start;
grub_uint32_t bss_start;
grub_uint32_t gprmask;
grub_uint32_t cprmask[4];
grub_uint32_t gp_value;
};
struct ecoff_section
{
char name[8];
grub_uint32_t paddr;
grub_uint32_t vaddr;
grub_uint32_t size;
grub_uint32_t file_offset;
grub_uint32_t reloc;
grub_uint32_t gp;
grub_uint16_t nreloc;
grub_uint16_t ngp;
grub_uint32_t flags;
};
struct ecoff_header *head;
struct ecoff_section *section;
grub_uint32_t target_addr;
size_t program_size;
program_size = ALIGN_ADDR (core_size);
target_addr = image_target->link_addr - ALIGN_UP(program_size, 1048576)
- (1 << 20);
ecoff_img = xmalloc (program_size + sizeof (*head) + sizeof (*section));
grub_memset (ecoff_img, 0, program_size + sizeof (*head) + sizeof (*section));
head = (void *) ecoff_img;
section = (void *) (head + 1);
head->magic = grub_host_to_target16 (0x160);
head->nsec = grub_host_to_target16 (1);
head->time = grub_host_to_target32 (0);
head->opt = grub_host_to_target16 (0x38);
head->flags = grub_host_to_target16 (0x207);
head->magic2 = grub_host_to_target16 (0x107);
head->textsize = grub_host_to_target32 (program_size);
head->entry = grub_host_to_target32 (target_addr);
head->text_start = grub_host_to_target32 (target_addr);
head->data_start = grub_host_to_target32 (target_addr + program_size);
grub_memcpy (section->name, ".text", sizeof (".text") - 1);
section->vaddr = grub_host_to_target32 (target_addr);
section->size = grub_host_to_target32 (program_size);
section->file_offset = grub_host_to_target32 (sizeof (*head) + sizeof (*section));
memcpy (section + 1, core_img, core_size);
free (core_img);
core_img = ecoff_img;
core_size = program_size + sizeof (*head) + sizeof (*section);
}
break;
case IMAGE_YEELOONG_ELF:
case IMAGE_PPC:
case IMAGE_COREBOOT: