SGI ARCS port.
* Makefile.util.def (libgrubmods.a): Add dvh.c. * conf/Makefile.common (CCASFLAGS_PLATFORM): Add -mips3 on all mips platforms. * configure.ac: New target mips-arc. * gentpl.py: Likewise. * grub-core/Makefile.am: Likewise. * grub-core/Makefile.core.def: Likewise. (xz_decompress): Remove -D GRUB_MACHINE_LINK_ADDR. (none_decompress): Likewise. (lsdev): New module. (datetime): Use lib/arc/datetime.c on ARC. (part_dvh): New module. * grub-core/commands/arc/lsdev.c: New file. * grub-core/disk/arc/arcdisk.c: Likewise. * grub-core/kern/mips/arc/init.c: Likewise. * grub-core/kern/mips/cache_flush.S: Don't flush non 4-byte aligned addresses. * grub-core/kern/mips/dl.c (grub_arch_dl_check_header): Fix bigendian support. (grub_arch_dl_relocate_symbols): Likewise. * grub-core/kern/mips/loongson/init.c (grub_get_rtc): Moved from here... * grub-core/kern/mips/init.c (grub_get_rtc): ... here. * grub-core/kern/mips/startup.S (grub_arch_cpuclock): Have on all platforms. * grub-core/lib/arc/datetime.c: New file. * grub-core/loader/mips/linux.c: Always include time.h. Don't include pci.h on non-loongson. (envp_off) [!GRUB_MACHINE_MIPS_LOONGSON]: Remove. (grub_linux_boot): Set unused registers to 0. (grub_cmd_linux) [!GRUB_MACHINE_MIPS_LOONGSON]: Remove envp. * grub-core/mmap/mips/loongson/uppermem.c: Moved from here ... * grub-core/mmap/mips/uppermem.c: ...here. * grub-core/partmap/dvh.c: New file. * grub-core/term/arc/console.c: Likewise. * grub-core/term/terminfo.c (ANSI_C0_STR): New const. (grub_terminfo_set_current): Add terminal "arc". (grub_terminfo_readkey): Support ARC sequences. * include/grub/arc/arc.h: New file. * include/grub/arc/console.h: Likewise. * include/grub/disk.h (grub_disk_dev_id): Add GRUB_DISK_DEVICE_ARCDISK_ID. * include/grub/mips/arc/kernel.h: New file. * include/grub/mips/arc/memory.h: Likewise. * include/grub/mips/arc/time.h: Likewise. * include/grub/mips/loongson/kernel.h (grub_halt): Moved from here ... * include/grub/mips/kernel.h (grub_halt): ... here. * include/grub/mips/loongson.h (GRUB_CPU_REGISTER_WRAP): Moved from here... * include/grub/mips/mips.h (GRUB_CPU_REGISTER_WRAP): ... here. (GRUB_CPU_LOONGSON_COP0_TIMER_COUNT): Moved from here ... * include/grub/mips/mips.h (GRUB_CPU_LOONGSON_COP0_TIMER_COUNT): .. here * include/grub/mips/loongson/kernel.h (grub_reboot): Removed redundant proto. * include/grub/mips/loongson/memory.h (GRUB_ARCH_LOWMEMVSTART): Moved from here ... * include/grub/mips/memory.h (GRUB_ARCH_LOWMEMVSTART): ... here. (GRUB_ARCH_LOWMEMPSTART): Moved from here ... * include/grub/mips/memory.h (GRUB_ARCH_LOWMEMPSTART): ... here. (GRUB_ARCH_LOWMEMMAXSIZE): Moved from here ... * include/grub/mips/memory.h (GRUB_ARCH_LOWMEMMAXSIZE): ... here. (GRUB_ARCH_HIGHMEMPSTART): Moved from here ... * include/grub/mips/memory.h (GRUB_ARCH_HIGHMEMPSTART): ... here. (grub_phys_addr_t): Moved from here ... * include/grub/mips/memory.h (grub_phys_addr_t): ... here. (grub_vtop): Moved from here ... * include/grub/mips/memory.h (grub_vtop): ... here. (grub_map_memory): Moved from here ... * include/grub/mips/memory.h (grub_map_memory): ... here. (grub_unmap_memory): Moved from here ... * include/grub/mips/memory.h (grub_unmap_memory): ... here. (grub_machine_mmap_iterate): Moved from here ... * include/grub/mips/memory.h (grub_machine_mmap_iterate): ... here. (grub_mmap_get_lower): Moved from here ... * include/grub/mips/memory.h (grub_mmap_get_lower): ... here. (grub_mmap_get_upper): Moved from here ... * include/grub/mips/memory.h (grub_mmap_get_upper): ... here. * include/grub/mips/loongson/time.h (grub_arch_cpuclock): Moved from here ... * include/grub/mips/time.h (grub_arch_cpuclock): ... here. * include/grub/mips/loongson/time.h (grub_get_rtc): Moved from here ... * include/grub/mips/time.h (grub_get_rtc): ... here. * include/grub/mips/loongson/time.h (grub_arch_cpuclock): Moved from here ... * include/grub/mips/time.h (grub_arch_cpuclock): ... here. * include/grub/mips/loongson/time.h (grub_cpu_idle): Moved from here ... * include/grub/mips/time.h (grub_cpu_idle): ... here. * include/grub/offsets.h (GRUB_KERNEL_MIPS_ARC_LINK_ADDR): New definition. (GRUB_KERNEL_MIPS_ARC_LINK_ALIGN): Likewise. (GRUB_KERNEL_MIPS_ARC_COMPRESSED_SIZE): Likewise. (GRUB_KERNEL_MIPS_ARC_UNCOMPRESSED_SIZE): Likewise. (GRUB_KERNEL_MIPS_ARC_TOTAL_MODULE_SIZE): Likewise. (GRUB_KERNEL_MIPS_ARC_PREFIX): Likewise. (GRUB_KERNEL_MIPS_ARC_PREFIX_END): Likewise. (GRUB_KERNEL_MIPS_ARC_MOD_ALIGN): Likewise. (GRUB_MACHINE_LINK_ADDR): Likewise. * include/grub/terminfo.h (GRUB_TERMINFO_READKEY_MAX_LEN): Increased to 6. * util/grub-install.in: Run dvhtool on ARC. * util/grub-mkimage.c (image_targets): Add mips-arc.
This commit is contained in:
commit
400b93718f
39 changed files with 1736 additions and 115 deletions
|
@ -131,6 +131,15 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/time.h
|
|||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.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_loongson
|
||||
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/keyboard_layouts.h
|
||||
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/kernel.h
|
||||
|
|
|
@ -41,6 +41,7 @@ kernel = {
|
|||
mips_loongson_ldflags = '-Wl,-Ttext,0x80200000';
|
||||
powerpc_ieee1275_ldflags = '-Wl,-Ttext,0x200000';
|
||||
sparc64_ieee1275_ldflags = '-Wl,-Ttext,0x4400';
|
||||
mips_arc_ldflags = '-Wl,-Ttext,0x8a000000';
|
||||
|
||||
mips_loongson_cppflags = '-DUSE_ASCII_FAILBACK';
|
||||
i386_qemu_cppflags = '-DGRUB_BOOT_MACHINE_LINK_ADDR=$(GRUB_BOOT_MACHINE_LINK_ADDR)';
|
||||
|
@ -54,7 +55,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_loongson_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;
|
||||
|
||||
|
@ -86,7 +87,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_loongson = 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;
|
||||
|
@ -147,13 +148,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_loongson = term/ns8250.c;
|
||||
mips_loongson = bus/bonito.c;
|
||||
mips_loongson = bus/cs5536.c;
|
||||
mips_loongson = bus/pci.c;
|
||||
mips_loongson = kern/mips/cache.S;
|
||||
mips_loongson = kern/mips/dl.c;
|
||||
mips_loongson = kern/mips/init.c;
|
||||
mips_loongson = kern/mips/loongson/init.c;
|
||||
mips_loongson = term/at_keyboard.c;
|
||||
mips_loongson = term/serial.c;
|
||||
|
@ -308,12 +314,11 @@ image = {
|
|||
common = lib/xzembed/xz_dec_lzma2.c;
|
||||
common = lib/xzembed/xz_dec_stream.c;
|
||||
|
||||
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';
|
||||
cppflags = '-I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/xzembed -DGRUB_EMBED_DECOMPRESSOR=1';
|
||||
|
||||
objcopyflags = '-O binary';
|
||||
ldflags = '-static-libgcc -Wl,-Ttext,0x80100000';
|
||||
mips_loongson_ldflags = '-static-libgcc -Wl,-Ttext,0x80100000';
|
||||
mips_arc_ldflags = '-static-libgcc -Wl,-Ttext,0x89f00000';
|
||||
ldadd = '-lgcc';
|
||||
cflags = '-static-libgcc';
|
||||
enable = mips;
|
||||
|
@ -324,10 +329,11 @@ image = {
|
|||
mips = boot/mips/startup_raw.S;
|
||||
common = boot/decompressor/none.c;
|
||||
|
||||
mips_cppflags = '-DGRUB_EMBED_DECOMPRESSOR=1 -DGRUB_MACHINE_LINK_ADDR=0x80200000';
|
||||
cppflags = '-DGRUB_EMBED_DECOMPRESSOR=1';
|
||||
|
||||
objcopyflags = '-O binary';
|
||||
ldflags = '-static-libgcc -Wl,-Ttext,0x80100000';
|
||||
mips_loongson_ldflags = '-static-libgcc -Wl,-Ttext,0x80100000';
|
||||
mips_arc_ldflags = '-static-libgcc -Wl,-Ttext,0x89f00000';
|
||||
ldadd = '-lgcc';
|
||||
cflags = '-static-libgcc';
|
||||
enable = mips;
|
||||
|
@ -430,6 +436,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;
|
||||
|
@ -1157,6 +1170,7 @@ module = {
|
|||
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;
|
||||
};
|
||||
|
||||
|
@ -1270,11 +1284,11 @@ module = {
|
|||
|
||||
efi = mmap/efi/mmap.c;
|
||||
|
||||
mips_loongson = mmap/mips/loongson/uppermem.c;
|
||||
mips = mmap/mips/uppermem.c;
|
||||
|
||||
enable = x86;
|
||||
enable = ia64_efi;
|
||||
enable = mips_loongson;
|
||||
enable = mips;
|
||||
};
|
||||
|
||||
module = {
|
||||
|
@ -1348,6 +1362,11 @@ module = {
|
|||
common = partmap/sun.c;
|
||||
};
|
||||
|
||||
module = {
|
||||
name = part_dvh;
|
||||
common = partmap/dvh.c;
|
||||
};
|
||||
|
||||
module = {
|
||||
name = part_bsd;
|
||||
common = partmap/bsdlabel.c;
|
||||
|
|
53
grub-core/commands/arc/lsdev.c
Normal file
53
grub-core/commands/arc/lsdev.c
Normal 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);
|
||||
}
|
295
grub-core/disk/arc/arcdisk.c
Normal file
295
grub-core/disk/arc/arcdisk.c
Normal file
|
@ -0,0 +1,295 @@
|
|||
/* 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 grub_arc_fileno_t last_handle = 0;
|
||||
static char *last_path = NULL;
|
||||
|
||||
static int lnum = 0;
|
||||
|
||||
struct arcdisk_hash_ent
|
||||
{
|
||||
char *devpath;
|
||||
int num;
|
||||
struct arcdisk_hash_ent *next;
|
||||
};
|
||||
|
||||
#define ARCDISK_HASH_SZ 8
|
||||
static struct arcdisk_hash_ent *arcdisk_hash[ARCDISK_HASH_SZ];
|
||||
|
||||
static int
|
||||
arcdisk_hash_fn (const char *devpath)
|
||||
{
|
||||
int hash = 0;
|
||||
while (*devpath)
|
||||
hash ^= *devpath++;
|
||||
return (hash & (ARCDISK_HASH_SZ - 1));
|
||||
}
|
||||
|
||||
static struct arcdisk_hash_ent *
|
||||
arcdisk_hash_find (const char *devpath)
|
||||
{
|
||||
struct arcdisk_hash_ent *p = arcdisk_hash[arcdisk_hash_fn (devpath)];
|
||||
|
||||
while (p)
|
||||
{
|
||||
if (!grub_strcmp (p->devpath, devpath))
|
||||
break;
|
||||
p = p->next;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
static struct arcdisk_hash_ent *
|
||||
arcdisk_hash_add (char *devpath)
|
||||
{
|
||||
struct arcdisk_hash_ent *p;
|
||||
struct arcdisk_hash_ent **head = &arcdisk_hash[arcdisk_hash_fn(devpath)];
|
||||
|
||||
p = grub_malloc (sizeof (*p));
|
||||
if (!p)
|
||||
return NULL;
|
||||
|
||||
p->devpath = devpath;
|
||||
p->next = *head;
|
||||
p->num = lnum++;
|
||||
*head = p;
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
grub_arc_fileno_t 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;
|
||||
grub_arc_err_t r;
|
||||
struct grub_arc_fileinfo info;
|
||||
struct arcdisk_hash_ent *hash;
|
||||
|
||||
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);
|
||||
|
||||
hash = arcdisk_hash_find (fullname);
|
||||
if (!hash)
|
||||
hash = arcdisk_hash_add (fullname);
|
||||
if (!hash)
|
||||
return grub_errno;
|
||||
|
||||
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: %ld\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 = hash->num;
|
||||
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;
|
||||
grub_arc_err_t 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: %ld\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);
|
||||
}
|
203
grub-core/kern/mips/arc/init.c
Normal file
203
grub-core/kern/mips/arc/init.c
Normal 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%lu", prefix, cname, comp->key);
|
||||
else
|
||||
name = grub_xasprintf ("%s%s(%lu)", 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);
|
||||
}
|
||||
|
|
@ -9,15 +9,15 @@
|
|||
subu $t1, $t3, $t2
|
||||
1:
|
||||
cache 1, 0($t0)
|
||||
addiu $t1, $t1, 0xffff
|
||||
addiu $t1, $t1, -0x4
|
||||
bne $t1, $zero, 1b
|
||||
addiu $t0, $t0, 0x1
|
||||
addiu $t0, $t0, 0x4
|
||||
sync
|
||||
move $t0, $t2
|
||||
subu $t1, $t3, $t2
|
||||
2:
|
||||
cache 0, 0($t0)
|
||||
addiu $t1, $t1, 0xffff
|
||||
addiu $t1, $t1, -0x4
|
||||
bne $t1, $zero, 2b
|
||||
addiu $t0, $t0, 0x1
|
||||
addiu $t0, $t0, 0x4
|
||||
sync
|
||||
|
|
|
@ -34,7 +34,7 @@ grub_arch_dl_check_header (void *ehdr)
|
|||
Elf_Ehdr *e = ehdr;
|
||||
|
||||
/* Check the magic numbers. */
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
#ifdef GRUB_CPU_WORDS_BIGENDIAN
|
||||
if (e->e_ident[EI_CLASS] != ELFCLASS32
|
||||
|| e->e_ident[EI_DATA] != ELFDATA2MSB
|
||||
|| e->e_machine != EM_MIPS)
|
||||
|
@ -144,14 +144,14 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
|
|||
rel < max;
|
||||
rel++)
|
||||
{
|
||||
Elf_Word *addr;
|
||||
grub_uint8_t *addr;
|
||||
Elf_Sym *sym;
|
||||
|
||||
if (seg->size < rel->r_offset)
|
||||
return grub_error (GRUB_ERR_BAD_MODULE,
|
||||
"reloc offset is out of the segment");
|
||||
|
||||
addr = (Elf_Word *) ((char *) seg->addr + rel->r_offset);
|
||||
addr = (grub_uint8_t *) ((char *) seg->addr + rel->r_offset);
|
||||
sym = (Elf_Sym *) ((char *) mod->symtab
|
||||
+ entsize * ELF_R_SYM (rel->r_info));
|
||||
if (sym->st_value == (grub_addr_t) &__gnu_local_gp_dummy)
|
||||
|
@ -163,7 +163,11 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
|
|||
{
|
||||
grub_uint32_t value;
|
||||
Elf_Rel *rel2;
|
||||
|
||||
|
||||
#ifdef GRUB_CPU_WORDS_BIGENDIAN
|
||||
addr += 2;
|
||||
#endif
|
||||
|
||||
/* Handle partner lo16 relocation. Lower part is
|
||||
treated as signed. Hence add 0x8000 to compensate.
|
||||
*/
|
||||
|
@ -175,13 +179,20 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
|
|||
&& ELF_R_TYPE (rel2->r_info) == R_MIPS_LO16)
|
||||
{
|
||||
value += *(grub_int16_t *)
|
||||
((char *) seg->addr + rel2->r_offset);
|
||||
((char *) seg->addr + rel2->r_offset
|
||||
#ifdef GRUB_CPU_WORDS_BIGENDIAN
|
||||
+ 2
|
||||
#endif
|
||||
);
|
||||
break;
|
||||
}
|
||||
*(grub_uint16_t *) addr = (value >> 16) & 0xffff;
|
||||
}
|
||||
break;
|
||||
case R_MIPS_LO16:
|
||||
#ifdef GRUB_CPU_WORDS_BIGENDIAN
|
||||
addr += 2;
|
||||
#endif
|
||||
*(grub_uint16_t *) addr += (sym->st_value) & 0xffff;
|
||||
break;
|
||||
case R_MIPS_32:
|
||||
|
@ -208,6 +219,9 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
|
|||
case R_MIPS_GOT16:
|
||||
case R_MIPS_CALL16:
|
||||
/* FIXME: reuse*/
|
||||
#ifdef GRUB_CPU_WORDS_BIGENDIAN
|
||||
addr += 2;
|
||||
#endif
|
||||
*gpptr = sym->st_value + *(grub_uint16_t *) addr;
|
||||
*(grub_uint16_t *) addr
|
||||
= sizeof (grub_uint32_t) * (gpptr - gp);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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_sis315pro_init (void);
|
||||
|
@ -44,22 +45,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)
|
||||
{
|
||||
|
|
|
@ -51,11 +51,11 @@ VARIABLE(grub_prefix)
|
|||
*/
|
||||
|
||||
. = _start + GRUB_KERNEL_MACHINE_PREFIX_END
|
||||
VARIABLE (grub_arch_cpuclock)
|
||||
.long 0
|
||||
#ifdef GRUB_MACHINE_MIPS_LOONGSON
|
||||
VARIABLE (grub_arch_busclock)
|
||||
.long 0
|
||||
VARIABLE (grub_arch_cpuclock)
|
||||
.long 0
|
||||
VARIABLE (grub_arch_memsize)
|
||||
.long 0
|
||||
VARIABLE (grub_arch_highmemsize)
|
||||
|
|
48
grub-core/lib/arc/datetime.c
Normal file
48
grub-core/lib/arc/datetime.c
Normal 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");
|
||||
}
|
|
@ -31,10 +31,10 @@
|
|||
GRUB_MOD_LICENSE ("GPLv3+");
|
||||
|
||||
/* For frequencies. */
|
||||
#include <grub/pci.h>
|
||||
#include <grub/machine/time.h>
|
||||
|
||||
#ifdef GRUB_MACHINE_MIPS_LOONGSON
|
||||
#include <grub/pci.h>
|
||||
#include <grub/machine/kernel.h>
|
||||
|
||||
const char loongson_machtypes[][60] =
|
||||
|
@ -54,7 +54,10 @@ static struct grub_relocator *relocator;
|
|||
static grub_uint8_t *playground;
|
||||
static grub_addr_t target_addr, entry_addr;
|
||||
static int linux_argc;
|
||||
static grub_off_t argv_off, envp_off;
|
||||
static grub_off_t argv_off;
|
||||
#ifdef GRUB_MACHINE_MIPS_LOONGSON
|
||||
static grub_off_t envp_off;
|
||||
#endif
|
||||
static grub_off_t rd_addr_arg_off, rd_size_arg_off;
|
||||
static int initrd_loaded = 0;
|
||||
|
||||
|
@ -67,7 +70,12 @@ grub_linux_boot (void)
|
|||
state.gpr[1] = entry_addr;
|
||||
state.gpr[4] = linux_argc;
|
||||
state.gpr[5] = target_addr + argv_off;
|
||||
#ifdef GRUB_MACHINE_MIPS_LOONGSON
|
||||
state.gpr[6] = target_addr + envp_off;
|
||||
#else
|
||||
state.gpr[6] = 0;
|
||||
#endif
|
||||
state.gpr[7] = 0;
|
||||
state.jumpreg = 1;
|
||||
grub_relocator32_boot (relocator, state);
|
||||
|
||||
|
@ -202,9 +210,13 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
|||
int i;
|
||||
int size;
|
||||
void *extra = NULL;
|
||||
grub_uint32_t *linux_argv, *linux_envp;
|
||||
char *linux_args, *linux_envs;
|
||||
grub_uint32_t *linux_argv;
|
||||
char *linux_args;
|
||||
grub_err_t err;
|
||||
#ifdef GRUB_MACHINE_MIPS_LOONGSON
|
||||
char *linux_envs;
|
||||
grub_uint32_t *linux_envp;
|
||||
#endif
|
||||
|
||||
if (argc == 0)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "no kernel specified");
|
||||
|
@ -321,6 +333,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
|||
|
||||
extra = linux_args;
|
||||
|
||||
#ifdef GRUB_MACHINE_MIPS_LOONGSON
|
||||
linux_envp = extra;
|
||||
envp_off = (grub_uint8_t *) linux_envp - (grub_uint8_t *) playground;
|
||||
linux_envs = (char *) (linux_envp + 5);
|
||||
|
@ -348,8 +361,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
|||
+ target_addr;
|
||||
linux_envs += ALIGN_UP (grub_strlen (linux_envs) + 1, 4);
|
||||
|
||||
|
||||
linux_envp[4] = 0;
|
||||
#endif
|
||||
|
||||
grub_loader_set (grub_linux_boot, grub_linux_unload, 1);
|
||||
initrd_loaded = 0;
|
||||
|
|
|
@ -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
124
grub-core/partmap/dvh.c
Normal 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);
|
||||
}
|
||||
|
123
grub-core/term/arc/console.c
Normal file
123
grub-core/term/arc/console.c
Normal 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");
|
||||
}
|
|
@ -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))
|
||||
|
@ -430,7 +445,8 @@ grub_terminfo_readkey (struct grub_term_input *term, int *keys, int *len,
|
|||
{'K', GRUB_TERM_KEY_END},
|
||||
{'P', GRUB_TERM_KEY_DC},
|
||||
{'?', GRUB_TERM_KEY_PPAGE},
|
||||
{'/', GRUB_TERM_KEY_NPAGE}
|
||||
{'/', GRUB_TERM_KEY_NPAGE},
|
||||
{'@', GRUB_TERM_KEY_INSERT},
|
||||
};
|
||||
|
||||
static struct
|
||||
|
@ -445,6 +461,14 @@ grub_terminfo_readkey (struct grub_term_input *term, int *keys, int *len,
|
|||
{'5', GRUB_TERM_KEY_PPAGE},
|
||||
{'6', GRUB_TERM_KEY_NPAGE}
|
||||
};
|
||||
char fx_key[] =
|
||||
{ 'P', 'Q', 'w', 'x', 't', 'u',
|
||||
'q', 'r', 'p', 'M', 'A', 'B' };
|
||||
unsigned fx_code[] =
|
||||
{ GRUB_TERM_KEY_F1, GRUB_TERM_KEY_F2, GRUB_TERM_KEY_F3,
|
||||
GRUB_TERM_KEY_F4, GRUB_TERM_KEY_F5, GRUB_TERM_KEY_F6,
|
||||
GRUB_TERM_KEY_F7, GRUB_TERM_KEY_F8, GRUB_TERM_KEY_F9,
|
||||
GRUB_TERM_KEY_F10, GRUB_TERM_KEY_F11, GRUB_TERM_KEY_F12 };
|
||||
unsigned i;
|
||||
|
||||
if (c == '\e')
|
||||
|
@ -465,17 +489,53 @@ grub_terminfo_readkey (struct grub_term_input *term, int *keys, int *len,
|
|||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE (four_code_table); i++)
|
||||
if (four_code_table[i].key == c)
|
||||
switch (c)
|
||||
{
|
||||
case 'O':
|
||||
CONTINUE_READ;
|
||||
for (i = 0; i < ARRAY_SIZE (fx_key); i++)
|
||||
if (fx_key[i] == c)
|
||||
{
|
||||
keys[0] = fx_code[i];
|
||||
*len = 1;
|
||||
return;
|
||||
}
|
||||
return;
|
||||
|
||||
case '0':
|
||||
{
|
||||
int num = 0;
|
||||
CONTINUE_READ;
|
||||
if (c != '~')
|
||||
if (c != '0' && c != '1')
|
||||
return;
|
||||
keys[0] = three_code_table[i].ascii;
|
||||
num = (c - '0') * 10;
|
||||
CONTINUE_READ;
|
||||
if (c < '0' || c > '9')
|
||||
return;
|
||||
num += (c - '0');
|
||||
if (num == 0 || num > 12)
|
||||
return;
|
||||
CONTINUE_READ;
|
||||
if (c != 'q')
|
||||
return;
|
||||
keys[0] = fx_code[num - 1];
|
||||
*len = 1;
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
default:
|
||||
for (i = 0; i < ARRAY_SIZE (four_code_table); i++)
|
||||
if (four_code_table[i].key == c)
|
||||
{
|
||||
CONTINUE_READ;
|
||||
if (c != '~')
|
||||
return;
|
||||
keys[0] = three_code_table[i].ascii;
|
||||
*len = 1;
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
#undef CONTINUE_READ
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue