merge mainline into sgi
This commit is contained in:
commit
bee1aeb9a1
49 changed files with 1148 additions and 348 deletions
165
ChangeLog
165
ChangeLog
|
@ -1,3 +1,168 @@
|
|||
2011-05-15 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Fuloong support.
|
||||
|
||||
* configure.ac: Rename yeeloong platform to loongson. All users updated.
|
||||
* grub-core/Makefile.core.def (fwstart_fuloong): New image.
|
||||
* grub-core/boot/mips/loongson/fuloong.S: New file.
|
||||
* grub-core/boot/mips/loongson/fwstart.S: Wait for CS5536 to come up.
|
||||
Explicitly init CS5536.
|
||||
[FULOONG]: Don't use serial until CS5536 is available.
|
||||
Set GPIO based on dumps.
|
||||
(serial_hw_init) [FULOONG]: Handle CS5536 parts.
|
||||
[FULOONG]: Handle GPIO and memory controller differences.
|
||||
Parse machine type in $a2.
|
||||
* grub-core/boot/mips/startup_raw.S: Determine and save the
|
||||
architecture.
|
||||
* grub-core/bus/cs5536.c (gpiodump): Move to fwstart.S.
|
||||
(grub_cs5536_init_geode): Remove gpio part. Conditionalise DIVIL
|
||||
init on architecture type.
|
||||
* grub-core/kern/mips/loongson/init.c (grub_machine_init): Init
|
||||
SIS315E. Don't init at_keyboard on fuloong.
|
||||
(grub_halt): Support Fuloong.
|
||||
* grub-core/kern/mips/startup.S [LOONGSON]: Save $s7.
|
||||
* grub-core/loader/mips/linux.c (LOONGSON_MACHTYPE): Removed.
|
||||
(loongson_machtypes): New array.
|
||||
(grub_cmd_linux) [GRUB_MACHINE_MIPS_LOONGSON]: Pass the right machine
|
||||
type.
|
||||
* grub-core/term/ns8250.c (serial_get_divisor): New parameter port and
|
||||
config. All users updated. Handle CS5536 serial.
|
||||
* grub-core/term/serial.c (grub_serial_register): Conditionalise
|
||||
default port on machine type. Register serial as inactive.
|
||||
* grub-core/video/sis315pro.c: New file.
|
||||
* include/grub/cs5536.h (GRUB_CS5536_MSR_MAILBOX_CONFIG_ENABLED): New
|
||||
definition.
|
||||
(GRUB_CS5536_MSR_MAILBOX_CONFIG): Likewise.
|
||||
(GRUB_CS5536_MSR_DIVIL_LEG_IO_UART1_COM1): Likewise.
|
||||
(GRUB_CS5536_MSR_DIVIL_LEG_IO_UART2_COM3): Likewise.
|
||||
(GRUB_CS5536_MSR_DIVIL_UART1_CONF): Likewise.
|
||||
(GRUB_CS5536_MSR_DIVIL_UART2_CONF): Likewise.
|
||||
* include/grub/mips/loongson.h (GRUB_CPU_LOONGSON_SHUTDOWN_GPIO): Rename
|
||||
to ...
|
||||
(GRUB_CPU_YEELOONG_SHUTDOWN_GPIO): ... this.
|
||||
* include/grub/mips/loongson/kernel.h (GRUB_ARCH_MACHINE_YEELOONG): New
|
||||
definition.
|
||||
(GRUB_ARCH_MACHINE_FULOONG): Likewise.
|
||||
(grub_arch_machine): New extern var.
|
||||
* include/grub/mips/loongson/serial.h
|
||||
(GRUB_MACHINE_SERIAL_DIVISOR_115200): Renamed to ...
|
||||
(GRUB_MACHINE_SERIAL_PORT0_DIVISOR_115200): ... this.
|
||||
(GRUB_MACHINE_SERIAL_PORT): Renamed to ...
|
||||
(GRUB_MACHINE_SERIAL_PORT0): ... this.
|
||||
(GRUB_MACHINE_SERIAL_PORT2_DIVISOR_115200): New definition.
|
||||
(GRUB_MACHINE_SERIAL_PORT1): Likewise.
|
||||
(GRUB_MACHINE_SERIAL_PORT2): Likewise.
|
||||
(GRUB_MACHINE_SERIAL_PORTS): Include ports 1 and 2.
|
||||
* include/grub/term.h (grub_term_register_input_inactive): New inline
|
||||
function.
|
||||
(grub_term_register_output_inactive): Likewise.
|
||||
* include/grub/video.h (grub_video_driver_id): New value
|
||||
GRUB_VIDEO_DRIVER_SIS315PRO.
|
||||
* util/grub-mkimage.c (image_target_desc): Rename name to dirname.
|
||||
New field "names". All users updated.
|
||||
New field value IMAGE_FULOONG_FLASH.
|
||||
(generate_image): USe separate fwstart hashes for yeeloong and fuloong.
|
||||
|
||||
2011-05-14 Jordan Uggla <jordan.uggla@gmail.com>
|
||||
|
||||
* docs/grub.texi (Invoking grub-install): Fix additional outdated claims
|
||||
and add some clarification.
|
||||
|
||||
2011-05-14 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* util/grub.d/10_linux.in: Autoload gzio since it's needed on some
|
||||
platforms if kernel is compressed.
|
||||
|
||||
2011-05-14 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/kern/mm.c (grub_memalign): Disable auto-unloadding of
|
||||
unused modules since currently referrence counter isn't reliable and
|
||||
there isn't much memory to recover there anyway.
|
||||
|
||||
2011-05-14 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/kern/dl.c (grub_dl_load_file): Decrease ref counter
|
||||
rather than resetting it to allow modules to reference themselves
|
||||
in init.
|
||||
|
||||
2011-05-14 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/kern/dl.c (grub_dl_unload): Don't decrease reference
|
||||
counter on dependencies since grub_dl_unref already handles this.
|
||||
|
||||
2011-05-14 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/font/font_cmd.c (loadfont_command): Set grub_errno
|
||||
on error if not already done.
|
||||
|
||||
2011-05-14 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Fix few potential memory misusage.
|
||||
|
||||
* grub-core/font/font.c (load_font_index): Don't free char_index to
|
||||
avoid double free.
|
||||
(grub_font_load): Zero-fill font at alloc for safety.
|
||||
Close file on error.
|
||||
(free_font): Free bmp_idx.
|
||||
|
||||
2011-05-14 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* docs/grub.texi (Installation): Fix several outdated claims.
|
||||
|
||||
2011-05-14 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Handle module_license on windows.
|
||||
|
||||
* util/grub-pe2elf.c (MODLICENSE_SECTION): New definition. All following
|
||||
sections shifted.
|
||||
(insert_string): Make argument const char * instead of char *.
|
||||
(write_section_data): Handle long section names.
|
||||
Handle module_license.
|
||||
|
||||
2011-05-14 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/commands/menuentry.c (grub_cmd_menuentry): Correctly
|
||||
handle class-free menuentries.
|
||||
(grub_normal_add_menu_entry): Add a check to be sure.
|
||||
|
||||
2011-05-14 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/term/at_keyboard.c (set1_e0_mapping): Fix swap between
|
||||
PgUp and PgDown.
|
||||
|
||||
2011-05-13 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* configure.ac: Bump version to 1.99.
|
||||
|
||||
2011-05-13 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Give ATA device a bit more time on first try in order to allow disks
|
||||
to spin up.
|
||||
|
||||
* grub-core/disk/ata.c (grub_atapi_identify): Use GRUB_ATA_TOUT_DEV_INIT
|
||||
if dev->present is 1. Reset dev->present on failure.
|
||||
(grub_ata_device_initialize): Set dev->present to 1.
|
||||
* include/grub/ata.h (GRUB_ATA_TOUT_DEV_INIT): New value.
|
||||
(grub_ata_device): New member 'present'.
|
||||
|
||||
2011-05-13 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* util/grub-mkimage.c (generate_image): Update hash.
|
||||
|
||||
2011-05-13 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Flush caches on DMA memory.
|
||||
|
||||
* grub-core/kern/mips/cache.S (grub_arch_sync_dma_caches): New function.
|
||||
* grub-core/bus/pci.c (grub_memalign_dma32): Flush caches.
|
||||
(grub_dma_free): Likewise.
|
||||
* include/grub/cache.h (grub_arch_sync_dma_caches): New declaration.
|
||||
|
||||
2011-05-13 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/boot/mips/yeeloong/fwstart.S: Add explicit set mips3
|
||||
to avoid asm treating ld and sd as macros.
|
||||
|
||||
2011-05-13 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/boot/mips/startup_raw.S: Flush cache after loading
|
||||
|
|
|
@ -25,7 +25,7 @@ endif
|
|||
if COND_i386_ieee1275
|
||||
CFLAGS_PLATFORM += -mrtd -mregparm=3
|
||||
endif
|
||||
if COND_mips_yeeloong
|
||||
if COND_mips_loongson
|
||||
CFLAGS_PLATFORM += -mexplicit-relocs
|
||||
CPPFLAGS_PLATFORM = -DUSE_ASCII_FAILBACK
|
||||
endif
|
||||
|
|
18
configure.ac
18
configure.ac
|
@ -32,7 +32,7 @@ dnl type, so there is no conflict. Variables with the prefix "TARGET_"
|
|||
dnl (such as TARGET_CC, TARGET_CFLAGS, etc.) are used for the target
|
||||
dnl type.
|
||||
|
||||
AC_INIT([GRUB],[1.99~rc2],[bug-grub@gnu.org])
|
||||
AC_INIT([GRUB],[1.99],[bug-grub@gnu.org])
|
||||
|
||||
AC_CONFIG_AUX_DIR([build-aux])
|
||||
|
||||
|
@ -96,7 +96,7 @@ if test "x$with_platform" = x; then
|
|||
powerpc-*) platform=ieee1275 ;;
|
||||
powerpc64-*) platform=ieee1275 ;;
|
||||
sparc64-*) platform=ieee1275 ;;
|
||||
mips-*) platform=yeeloong ;;
|
||||
mips-*) platform=loongson ;;
|
||||
*) AC_MSG_ERROR([unsupported CPU: "$target_cpu"]) ;;
|
||||
esac
|
||||
else
|
||||
|
@ -123,7 +123,9 @@ case "$target_cpu"-"$platform" in
|
|||
powerpc-ieee1275) ;;
|
||||
sparc64-ieee1275) ;;
|
||||
mips-qemu-mips) ;;
|
||||
mips-yeeloong) ;;
|
||||
mips-yeeloong) platform=loongson ;;
|
||||
mips-fuloong) platform=loongson ;;
|
||||
mips-loongson) ;;
|
||||
mips-arc) ;;
|
||||
*-emu) ;;
|
||||
*) AC_MSG_ERROR([platform "$platform" is not supported for target CPU "$target_cpu"]) ;;
|
||||
|
@ -157,7 +159,7 @@ case "$platform" in
|
|||
qemu) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_QEMU=1" ;;
|
||||
pc) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_PCBIOS=1" ;;
|
||||
emu) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_EMU=1" ;;
|
||||
yeeloong) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_YEELOONG=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
|
||||
loongson) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_LOONGSON=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
|
||||
|
@ -221,8 +223,8 @@ for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
|
|||
done
|
||||
done
|
||||
|
||||
if test "x$FONT_SOURCE" = x && ( test "x$platform" = xqemu || test "x$platform" = xyeeloong ); then
|
||||
AC_MSG_ERROR([qemu and yeeloong ports need unifont])
|
||||
if test "x$FONT_SOURCE" = x && ( test "x$platform" = xqemu || test "x$platform" = xloongson ); then
|
||||
AC_MSG_ERROR([qemu and loongson ports need unifont])
|
||||
fi
|
||||
|
||||
AC_SUBST([FONT_SOURCE])
|
||||
|
@ -400,7 +402,7 @@ if test "x$grub_cv_cc_fno_dwarf2_cfi_asm" = xyes; then
|
|||
TARGET_CFLAGS="$TARGET_CFLAGS -fno-dwarf2-cfi-asm"
|
||||
fi
|
||||
|
||||
if test "${target_cpu}-${platform}" = mips-yeeloong; then
|
||||
if test "${target_cpu}-${platform}" = mips-loongson; then
|
||||
AC_CACHE_CHECK([whether -march=loongson2f works], [grub_cv_cc_march_loongson2f], [
|
||||
SAVE_CFLAGS="$CFLAGS"
|
||||
CFLAGS="$CFLAGS -march=loongson2f"
|
||||
|
@ -952,7 +954,7 @@ AM_CONDITIONAL([COND_i386_ieee1275], [test x$target_cpu = xi386 -a x$platform =
|
|||
AM_CONDITIONAL([COND_i386_coreboot], [test x$target_cpu = xi386 -a x$platform = xcoreboot])
|
||||
AM_CONDITIONAL([COND_i386_multiboot], [test x$target_cpu = xi386 -a x$platform = xmultiboot])
|
||||
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_loongson], [test x$target_cpu = xmips -a x$platform = xloongson])
|
||||
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])
|
||||
|
|
|
@ -528,21 +528,15 @@ system (@pxref{Obtaining and Building GRUB}). You can do this either
|
|||
from the source tarball, or as a package for your OS.
|
||||
|
||||
After you have done that, you need to install the boot loader on a
|
||||
drive (floppy or hard disk). There are two ways of doing that - either
|
||||
using the utility @command{grub-install} (@pxref{Invoking
|
||||
grub-install}) on a UNIX-like OS, or by running GRUB itself from a
|
||||
floppy. These are quite similar, however the utility might probe a
|
||||
wrong BIOS drive, so you should be careful.
|
||||
|
||||
Also, if you install GRUB on a UNIX-like OS, please make sure that you
|
||||
have an emergency boot disk ready, so that you can rescue your computer
|
||||
if, by any chance, your hard drive becomes unusable (unbootable).
|
||||
drive (floppy or hard disk) by using the utility
|
||||
@command{grub-install} (@pxref{Invoking grub-install}) on a UNIX-like OS.
|
||||
|
||||
GRUB comes with boot images, which are normally put in the directory
|
||||
@file{/usr/lib/grub/i386-pc}. Hereafter, the directory where GRUB images are
|
||||
initially placed (normally @file{/usr/lib/grub/i386-pc}) will be
|
||||
@file{/usr/lib/grub/<cpu>-<platform>} (for BIOS-based machines
|
||||
@file{/usr/lib/grub/i386-pc}). Hereafter, the directory where GRUB images are
|
||||
initially placed (normally @file{/usr/lib/grub/<cpu>-<platform>}) will be
|
||||
called the @dfn{image directory}, and the directory where the boot
|
||||
loader needs to find them (usually @file{/boot/grub}) will be called
|
||||
loader needs to find them (usually @file{/boot}) will be called
|
||||
the @dfn{boot directory}.
|
||||
|
||||
@menu
|
||||
|
@ -556,27 +550,18 @@ the @dfn{boot directory}.
|
|||
@node Installing GRUB using grub-install
|
||||
@section Installing GRUB using grub-install
|
||||
|
||||
@strong{Caution:} This procedure is definitely less safe, because
|
||||
there are several ways in which your computer can become
|
||||
unbootable. For example, most operating systems don't tell GRUB how to
|
||||
map BIOS drives to OS devices correctly---GRUB merely @dfn{guesses}
|
||||
the mapping. This will succeed in most cases, but not
|
||||
always. Therefore, GRUB provides you with a map file called the
|
||||
@dfn{device map}, which you must fix if it is wrong. @xref{Device
|
||||
map}, for more details.
|
||||
|
||||
For information on where GRUB should be installed on PC BIOS platforms,
|
||||
@pxref{BIOS installation}.
|
||||
|
||||
If you still do want to install GRUB under a UNIX-like OS (such
|
||||
In order to install GRUB under a UNIX-like OS (such
|
||||
as @sc{gnu}), invoke the program @command{grub-install} (@pxref{Invoking
|
||||
grub-install}) as the superuser (@dfn{root}).
|
||||
|
||||
The usage is basically very simple. You only need to specify one
|
||||
argument to the program, namely, where to install the boot loader. The
|
||||
argument can be either a device file (like @samp{/dev/hda}) or a
|
||||
partition specified in GRUB's notation. For example, under Linux the
|
||||
following will install GRUB into the MBR of the first IDE disk:
|
||||
argument has to be either a device file (like @samp{/dev/hda}).
|
||||
For example, under Linux the following will install GRUB into the MBR
|
||||
of the first IDE disk:
|
||||
|
||||
@example
|
||||
# @kbd{grub-install /dev/hda}
|
||||
|
@ -588,37 +573,22 @@ Likewise, under GNU/Hurd, this has the same effect:
|
|||
# @kbd{grub-install /dev/hd0}
|
||||
@end example
|
||||
|
||||
But all the above examples assume that GRUB should use images under
|
||||
the root directory. If you want GRUB to use images under a directory
|
||||
other than the root directory, you need to specify the option
|
||||
@option{--root-directory}. The typical usage is that you create a GRUB
|
||||
But all the above examples assume that GRUB should put images under
|
||||
the @file{/boot} directory. If you want GRUB to put images under a directory
|
||||
other than @file{/boot}, you need to specify the option
|
||||
@option{--boot-directory}. The typical usage is that you create a GRUB
|
||||
boot floppy with a filesystem. Here is an example:
|
||||
|
||||
@example
|
||||
@group
|
||||
# @kbd{mke2fs /dev/fd0}
|
||||
# @kbd{mount -t ext2 /dev/fd0 /mnt}
|
||||
# @kbd{grub-install --root-directory=/mnt fd0}
|
||||
# @kbd{mkdir /mnt/boot}
|
||||
# @kbd{grub-install --boot-directory=/mnt/boot /dev/fd0}
|
||||
# @kbd{umount /mnt}
|
||||
@end group
|
||||
@end example
|
||||
|
||||
Another example is when you have a separate boot partition
|
||||
which is mounted at @file{/boot}. Since GRUB is a boot loader, it
|
||||
doesn't know anything about mountpoints at all. Thus, you need to run
|
||||
@command{grub-install} like this:
|
||||
|
||||
@example
|
||||
# @kbd{grub-install --root-directory=/boot /dev/hda}
|
||||
@end example
|
||||
|
||||
By the way, as noted above, it is quite difficult to guess BIOS drives
|
||||
correctly under a UNIX-like OS. Thus, @command{grub-install} will prompt
|
||||
you to check if it could really guess the correct mappings, after the
|
||||
installation. The format is defined in @ref{Device map}. Please be
|
||||
quite careful. If the output is wrong, it is unlikely that your
|
||||
computer will be able to boot with no problem.
|
||||
|
||||
Some BIOSes have a bug of exposing the first partition of a USB drive as a
|
||||
floppy instead of exposing the USB drive as a hard disk (they call it
|
||||
``USB-FDD'' boot). In such cases, you need to install like this:
|
||||
|
@ -4195,15 +4165,28 @@ Print a summary of the command-line options and exit.
|
|||
@item --version
|
||||
Print the version number of GRUB and exit.
|
||||
|
||||
@item --root-directory=@var{dir}
|
||||
Install GRUB images under the directory @var{dir} instead of the root
|
||||
directory. This option is useful when you want to install GRUB into a
|
||||
separate partition or a removable disk. Here is an example in which
|
||||
you have a separate @dfn{boot} partition which is mounted on
|
||||
@file{/boot}:
|
||||
@item --boot-directory=@var{dir}
|
||||
Install GRUB images under the directory @file{@var{dir}/grub/}
|
||||
This option is useful when you want to install GRUB into a
|
||||
separate partition or a removable disk.
|
||||
If this option is not specified then it defaults to @file{/boot}, so
|
||||
|
||||
@example
|
||||
@kbd{grub-install --root-directory=/boot hd0}
|
||||
@kbd{grub-install /dev/sda}
|
||||
@end example
|
||||
|
||||
is equivalent to
|
||||
|
||||
@example
|
||||
@kbd{grub-install --boot-directory=/boot/ /dev/sda}
|
||||
@end example
|
||||
|
||||
Here is an example in which you have a separate @dfn{boot} partition which is
|
||||
mounted on
|
||||
@file{/mnt/boot}:
|
||||
|
||||
@example
|
||||
@kbd{grub-install --boot-directory=/mnt/boot /dev/sdb}
|
||||
@end example
|
||||
|
||||
@item --recheck
|
||||
|
|
14
gentpl.py
14
gentpl.py
|
@ -6,7 +6,7 @@
|
|||
|
||||
GRUB_PLATFORMS = [ "emu", "i386_pc", "i386_efi", "i386_qemu", "i386_coreboot",
|
||||
"i386_multiboot", "i386_ieee1275", "x86_64_efi",
|
||||
"mips_yeeloong", "sparc64_ieee1275",
|
||||
"mips_loongson", "sparc64_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", "mips_arc" ]
|
||||
GROUPS["mips"] = [ "mips_loongson", "mips_arc" ]
|
||||
GROUPS["sparc64"] = [ "sparc64_ieee1275" ]
|
||||
GROUPS["powerpc"] = [ "powerpc_ieee1275" ]
|
||||
|
||||
|
@ -29,17 +29,17 @@ GROUPS["ieee1275"] = [ "i386_ieee1275", "sparc64_ieee1275", "powerpc_ieee1275"
|
|||
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"] + ["mips_yeeloong"]
|
||||
GROUPS["cmos"] = GROUPS["x86"][:] + ["mips_loongson"]; GROUPS["cmos"].remove("i386_efi"); GROUPS["cmos"].remove("x86_64_efi")
|
||||
GROUPS["pci"] = GROUPS["x86"] + ["mips_loongson"]
|
||||
GROUPS["usb"] = GROUPS["pci"]
|
||||
|
||||
# If gfxterm is main output console integrate it into kernel
|
||||
GROUPS["videoinkernel"] = ["mips_yeeloong"]
|
||||
GROUPS["videoinkernel"] = ["mips_loongson"]
|
||||
GROUPS["videomodules"] = GRUB_PLATFORMS[:];
|
||||
for i in GROUPS["videoinkernel"]: GROUPS["videomodules"].remove(i)
|
||||
|
||||
# Similar for terminfo
|
||||
GROUPS["terminfoinkernel"] = ["mips_yeeloong", "mips_arc"] + GROUPS["ieee1275"];
|
||||
GROUPS["terminfoinkernel"] = ["mips_loongson", "mips_arc"] + GROUPS["ieee1275"];
|
||||
GROUPS["terminfomodule"] = GRUB_PLATFORMS[:];
|
||||
for i in GROUPS["terminfoinkernel"]: GROUPS["terminfomodule"].remove(i)
|
||||
|
||||
|
@ -238,7 +238,7 @@ def foreach_enabled_platform(closure):
|
|||
# noemu = bus/usb/usbhub.c;
|
||||
# enable = emu;
|
||||
# enable = i386;
|
||||
# enable = mips_yeeloong;
|
||||
# enable = mips_loongson;
|
||||
# emu_condition = COND_GRUB_EMU_USB;
|
||||
# };
|
||||
#
|
||||
|
|
|
@ -134,7 +134,7 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h
|
|||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/arc/arc.h
|
||||
endif
|
||||
|
||||
if COND_mips_yeeloong
|
||||
if COND_mips_loongson
|
||||
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/keyboard_layouts.h
|
||||
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/cpu/cache.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/bitmap.h
|
||||
|
|
|
@ -32,12 +32,12 @@ kernel = {
|
|||
i386_coreboot_ldflags = '-Wl,-Ttext=0x8200';
|
||||
i386_multiboot_ldflags = '-Wl,-Ttext=0x8200';
|
||||
i386_ieee1275_ldflags = '-Wl,-Ttext=0x10000';
|
||||
mips_yeeloong_ldflags = '-Wl,-Ttext,0x80200000';
|
||||
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_yeeloong_cppflags = '-DUSE_ASCII_FAILBACK';
|
||||
mips_loongson_cppflags = '-DUSE_ASCII_FAILBACK';
|
||||
i386_qemu_cppflags = '-DGRUB_BOOT_MACHINE_LINK_ADDR=$(GRUB_BOOT_MACHINE_LINK_ADDR)';
|
||||
emu_cflags = '$(CFLAGS_GNULIB)';
|
||||
emu_cppflags = '$(CPPFLAGS_GNULIB)';
|
||||
|
@ -145,16 +145,17 @@ kernel = {
|
|||
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/yeeloong/init.c;
|
||||
mips_yeeloong = term/at_keyboard.c;
|
||||
mips_yeeloong = term/serial.c;
|
||||
mips_yeeloong = video/sm712.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/loongson/init.c;
|
||||
mips_loongson = term/at_keyboard.c;
|
||||
mips_loongson = term/serial.c;
|
||||
mips_loongson = video/sm712.c;
|
||||
mips_loongson = video/sis315pro.c;
|
||||
extra_dist = video/sm712_init.c;
|
||||
mips_yeeloong = commands/keylayouts.c;
|
||||
mips_loongson = commands/keylayouts.c;
|
||||
|
||||
powerpc_ieee1275 = kern/ieee1275/init.c;
|
||||
powerpc_ieee1275 = kern/powerpc/cache.S;
|
||||
|
@ -332,10 +333,18 @@ image = {
|
|||
|
||||
image = {
|
||||
name = fwstart;
|
||||
mips_yeeloong = boot/mips/yeeloong/fwstart.S;
|
||||
mips_loongson = boot/mips/loongson/fwstart.S;
|
||||
objcopyflags = '-O binary';
|
||||
ldflags = '-static-libgcc -lgcc -Wl,-N,-S,-Ttext,0xbfc00000,-Bstatic';
|
||||
enable = mips_yeeloong;
|
||||
enable = mips_loongson;
|
||||
};
|
||||
|
||||
image = {
|
||||
name = fwstart_fuloong;
|
||||
mips_loongson = boot/mips/loongson/fuloong.S;
|
||||
objcopyflags = '-O binary';
|
||||
ldflags = '-static-libgcc -lgcc -Wl,-N,-S,-Ttext,0xbfc00000,-Bstatic';
|
||||
enable = mips_loongson;
|
||||
};
|
||||
|
||||
module = {
|
||||
|
@ -359,8 +368,8 @@ module = {
|
|||
|
||||
module = {
|
||||
name = lsspd;
|
||||
mips_yeeloong = commands/mips/yeeloong/lsspd.c;
|
||||
enable = mips_yeeloong;
|
||||
mips_loongson = commands/mips/loongson/lsspd.c;
|
||||
enable = mips_loongson;
|
||||
};
|
||||
|
||||
module = {
|
||||
|
|
2
grub-core/boot/mips/loongson/fuloong.S
Normal file
2
grub-core/boot/mips/loongson/fuloong.S
Normal file
|
@ -0,0 +1,2 @@
|
|||
#define FULOONG 1
|
||||
#include "fwstart.S"
|
|
@ -16,51 +16,73 @@
|
|||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/mips/yeeloong/serial.h>
|
||||
#include <grub/mips/yeeloong/pci.h>
|
||||
#include <grub/mips/loongson/serial.h>
|
||||
#include <grub/mips/loongson/pci.h>
|
||||
#include <grub/mips/loongson.h>
|
||||
#include <grub/pci.h>
|
||||
#include <grub/machine/serial.h>
|
||||
#include <grub/machine/kernel.h>
|
||||
#include <grub/ns8250.h>
|
||||
#include <grub/cs5536.h>
|
||||
#include <grub/smbus.h>
|
||||
|
||||
#ifdef FULOONG
|
||||
#define GRUB_MACHINE_SERIAL_PORT GRUB_MACHINE_SERIAL_PORT2
|
||||
#define GRUB_MACHINE_SERIAL_DIVISOR_115200 GRUB_MACHINE_SERIAL_PORT2_DIVISOR_115200
|
||||
#else
|
||||
#define GRUB_MACHINE_SERIAL_PORT GRUB_MACHINE_SERIAL_PORT0
|
||||
#define GRUB_MACHINE_SERIAL_DIVISOR_115200 GRUB_MACHINE_SERIAL_PORT0_DIVISOR_115200
|
||||
#endif
|
||||
|
||||
.set noreorder
|
||||
.set noat
|
||||
.set nomacro
|
||||
.set mips3
|
||||
|
||||
.global start,_start,__start
|
||||
start:
|
||||
_start:
|
||||
__start:
|
||||
/* Put serial init as soon as possible. But on Fuloong serial is past
|
||||
Geode, so on Fuloong we need Geode first.
|
||||
*/
|
||||
#ifndef FULOONG
|
||||
bal serial_hw_init
|
||||
nop
|
||||
#endif
|
||||
|
||||
/* Find CS5536 controller. */
|
||||
/* $t4 chooses device in priority encoding. */
|
||||
/* Resulting value is kept in GRUB_MACHINE_PCI_CONF_CTRL_REG.
|
||||
This way we don't need to sacrifice a register for it. */
|
||||
retry_cs5536:
|
||||
/* We have only one bus (0). Function is 0. */
|
||||
lui $t0, %hi(GRUB_MACHINE_PCI_CONF_CTRL_REG_ADDR)
|
||||
lui $t1, %hi(GRUB_MACHINE_PCI_CONFSPACE)
|
||||
lui $t3, %hi(GRUB_CS5536_PCIID)
|
||||
addiu $t3, $t3, %lo(GRUB_CS5536_PCIID)
|
||||
ori $t4, $zero, 1
|
||||
lui $a0, %hi(no_cs5536)
|
||||
1:
|
||||
andi $t4, $t4, ((1 << GRUB_PCI_NUM_DEVICES) - 1)
|
||||
beql $t4, $zero, fatal
|
||||
addiu $a0, $a0, %lo(no_cs5536)
|
||||
/* In case of failure try again. CS5536 may be slow to come up. */
|
||||
beql $t4, $zero, retry_cs5536
|
||||
nop
|
||||
sw $t4, %lo(GRUB_MACHINE_PCI_CONF_CTRL_REG_ADDR) ($t0)
|
||||
lw $t2, (%lo(GRUB_MACHINE_PCI_CONFSPACE) + GRUB_PCI_REG_PCI_ID) ($t1)
|
||||
bnel $t2, $t3, 1b
|
||||
sll $t4, $t4, 1
|
||||
|
||||
#ifndef FULOONG
|
||||
bal message
|
||||
addiu $a0, $a0, %lo(cs5536_found)
|
||||
bal printhex
|
||||
move $a0, $t4
|
||||
#endif
|
||||
|
||||
lui $t0, %hi(GRUB_MACHINE_PCI_CONFSPACE)
|
||||
li $t1, GRUB_CS5536_MSR_MAILBOX_CONFIG_ENABLED
|
||||
sw $t1, (%lo(GRUB_MACHINE_PCI_CONFSPACE) + GRUB_CS5536_MSR_MAILBOX_CONFIG) ($t0)
|
||||
|
||||
/* Initialise SMBus controller. */
|
||||
/* Set GPIO LBAR. */
|
||||
lui $a0, %hi(GRUB_CS5536_MSR_GPIO_BAR)
|
||||
addiu $a0, $a0, %lo(GRUB_CS5536_MSR_GPIO_BAR)
|
||||
|
@ -70,6 +92,15 @@ __start:
|
|||
ori $a2, $zero, ((GRUB_CS5536_LBAR_MASK_MASK \
|
||||
| GRUB_CS5536_LBAR_ENABLE) >> 32)
|
||||
|
||||
bal gpio_init
|
||||
nop
|
||||
|
||||
#ifdef FULOONG
|
||||
bal serial_hw_init
|
||||
nop
|
||||
#endif
|
||||
|
||||
/* Initialise SMBus controller. */
|
||||
/* Set SMBUS LBAR. */
|
||||
lui $a0, %hi(GRUB_CS5536_MSR_SMB_BAR)
|
||||
addiu $a0, $a0, %lo(GRUB_CS5536_MSR_SMB_BAR)
|
||||
|
@ -83,14 +114,6 @@ __start:
|
|||
bal message
|
||||
addiu $a0, $a0, %lo(smbus_enabled)
|
||||
|
||||
/* Enable SMBus controller pins. */
|
||||
lui $t0, %hi(GRUB_MACHINE_PCI_IO_BASE + GRUB_CS5536_LBAR_GPIO)
|
||||
ori $t1, $zero, GRUB_GPIO_SMBUS_PINS
|
||||
sw $t1, %lo(GRUB_MACHINE_PCI_IO_BASE + GRUB_CS5536_LBAR_GPIO + GRUB_GPIO_REG_OUT_EN) ($t0)
|
||||
sw $t1, %lo(GRUB_MACHINE_PCI_IO_BASE + GRUB_CS5536_LBAR_GPIO + GRUB_GPIO_REG_OUT_AUX1) ($t0)
|
||||
sw $t1, %lo(GRUB_MACHINE_PCI_IO_BASE + GRUB_CS5536_LBAR_GPIO + GRUB_GPIO_REG_IN_EN) ($t0)
|
||||
sw $t1, %lo(GRUB_MACHINE_PCI_IO_BASE + GRUB_CS5536_LBAR_GPIO + GRUB_GPIO_REG_IN_AUX1) ($t0)
|
||||
|
||||
lui $t0, %hi(GRUB_MACHINE_PCI_IO_BASE + GRUB_CS5536_LBAR_SMBUS)
|
||||
|
||||
/* Disable SMB. */
|
||||
|
@ -107,7 +130,7 @@ __start:
|
|||
sb $t1, %lo(GRUB_MACHINE_PCI_IO_BASE + GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL3) ($t0)
|
||||
sb $t1, %lo(GRUB_MACHINE_PCI_IO_BASE + GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL2) ($t0)
|
||||
|
||||
/* Yeeloong has only one memory slot. */
|
||||
/* Yeeloong and Fuloong have only one memory slot. */
|
||||
/* Output first byte on serial for debugging. */
|
||||
ori $a1, $zero, GRUB_SMB_RAM_START_ADDR
|
||||
bal read_spd
|
||||
|
@ -206,10 +229,54 @@ other_exception:
|
|||
b fatal
|
||||
addiu $a0, $a0, %lo(unhandled_exception)
|
||||
|
||||
gpio_init:
|
||||
lui $t0, %hi(GRUB_MACHINE_PCI_IO_BASE + GRUB_CS5536_LBAR_GPIO)
|
||||
addiu $t0, $t0, %lo(GRUB_MACHINE_PCI_IO_BASE + GRUB_CS5536_LBAR_GPIO)
|
||||
lui $t1, %hi (gpio_dump)
|
||||
addiu $t1, $t1, %lo (gpio_dump)
|
||||
|
||||
1:
|
||||
lw $t2, 0($t1)
|
||||
sw $t2, 0($t0)
|
||||
addiu $t0, $t0, 4
|
||||
addiu $t1, $t1, 4
|
||||
lui $t2, %hi (gpio_dump_end)
|
||||
addiu $t2, $t2, %lo (gpio_dump_end)
|
||||
bne $t1, $t2, 1b
|
||||
nop
|
||||
jr $ra
|
||||
nop
|
||||
|
||||
/* Same as similarly named C function but in asm since
|
||||
we need it early. */
|
||||
/* In: none. Out: none. Clobbered: $t0, $t1, $a0. */
|
||||
/* In: none. Out: none. Clobbered: $t0, $t1, $t2, $a0, $a1, $a2. */
|
||||
serial_hw_init:
|
||||
move $t2, $ra
|
||||
#ifdef FULOONG
|
||||
lui $a0, %hi(GRUB_CS5536_MSR_DIVIL_LEG_IO)
|
||||
addiu $a0, $a0, %lo(GRUB_CS5536_MSR_DIVIL_LEG_IO)
|
||||
lui $a1, %hi (GRUB_CS5536_MSR_DIVIL_LEG_IO_UART2_COM3 \
|
||||
| GRUB_CS5536_MSR_DIVIL_LEG_IO_F_REMAP \
|
||||
| GRUB_CS5536_MSR_DIVIL_LEG_IO_MODE_X86 \
|
||||
| GRUB_CS5536_MSR_DIVIL_LEG_IO_UART1_COM1)
|
||||
ori $a1, $a1, (GRUB_CS5536_MSR_DIVIL_LEG_IO_RTC_ENABLE0 \
|
||||
| GRUB_CS5536_MSR_DIVIL_LEG_IO_RTC_ENABLE1)
|
||||
bal wrmsr
|
||||
move $a2, $zero
|
||||
|
||||
lui $a0, %hi(GRUB_CS5536_MSR_DIVIL_UART1_CONF)
|
||||
addiu $a0, $a0, %lo(GRUB_CS5536_MSR_DIVIL_UART1_CONF)
|
||||
li $a1, 2
|
||||
bal wrmsr
|
||||
move $a2, $zero
|
||||
|
||||
lui $a0, %hi(GRUB_CS5536_MSR_DIVIL_UART2_CONF)
|
||||
addiu $a0, $a0, %lo(GRUB_CS5536_MSR_DIVIL_UART2_CONF)
|
||||
li $a1, 2
|
||||
bal wrmsr
|
||||
move $a2, $zero
|
||||
#endif
|
||||
|
||||
lui $t0, %hi (GRUB_MACHINE_SERIAL_PORT)
|
||||
|
||||
/* Turn off the interrupt. */
|
||||
|
@ -239,6 +306,7 @@ serial_hw_init:
|
|||
/* Let message return to original caller. */
|
||||
lui $a0, %hi(notification_string)
|
||||
addiu $a0, $a0, %lo(notification_string)
|
||||
move $ra, $t2
|
||||
|
||||
/* Print message on serial console. */
|
||||
/* In: $a0 = asciiz message. Out: none. Clobbered: $t0, $t1, $a0. */
|
||||
|
@ -379,7 +447,6 @@ read_spd_fail:
|
|||
ori $v0, $v0, 0x100
|
||||
|
||||
notification_string: .asciz "GRUB "
|
||||
no_cs5536: .asciz "No CS5536 found.\n\r"
|
||||
cs5536_found: .asciz "CS5536 at "
|
||||
sm_failed: .asciz "SM transaction failed.\n\r"
|
||||
unhandled_tlb_refill: .asciz "Unhandled TLB refill.\n\r"
|
||||
|
@ -404,14 +471,22 @@ regdump:
|
|||
.quad 0x0100020200010101 /* 4 */
|
||||
.quad 0x0a04030603050203 /* 6 */
|
||||
.quad 0x0f0e040000010a0b /* 7 */
|
||||
#ifdef FULOONG
|
||||
.quad 0x0000000100000001 /* 8 */
|
||||
#else
|
||||
.quad 0x0000010200000102 /* 8 */
|
||||
#endif
|
||||
.quad 0x0000060c00000000 /* 9 */
|
||||
.quad 0x2323233f3f1f0200 /* a */
|
||||
.quad 0x5f7f232323232323 /* b */
|
||||
.quad 0x002a3c0615000000 /* c */
|
||||
.quad 0x002a002a002a002a /* d */
|
||||
.quad 0x002a002a002a002a /* e */
|
||||
#ifdef FULOONG
|
||||
.quad 0x00b40020005b0004 /* f */
|
||||
#else
|
||||
.quad 0x00b40020006d0004 /* f */
|
||||
#endif
|
||||
.quad 0x070007ff00000087 /* 10 */
|
||||
.quad 0x000000000016101f /* 11 */
|
||||
.quad 0x001c000000000000 /* 12 */
|
||||
|
@ -426,6 +501,45 @@ regdump:
|
|||
.quad 0 /* 1b */
|
||||
.quad 0 /* 1c */
|
||||
|
||||
/* Dump of GPIO connections. FIXME: Remove useless and macroify. */
|
||||
gpio_dump:
|
||||
#ifdef FULOONG
|
||||
.long 0xffff0000, 0x2eefd110, 0xffff0000, 0xffff0000
|
||||
.long 0x2eefd110, 0xffff0000, 0x1000efff, 0xefff1000
|
||||
.long 0x3df3c20c, 0xffff0000, 0xffff0000, 0xffff0000
|
||||
.long 0x7df3820c, 0x3df3c20c, 0xffff0000, 0x00000000
|
||||
.long 0xffff0000, 0xffff0000, 0x3de3c21c, 0x3d83c27c
|
||||
.long 0x00000000, 0x00000000, 0x00000000, 0x00000000
|
||||
.long 0x00000000, 0x00000000, 0x00000000, 0x00000000
|
||||
.long 0x00000000, 0x00000000, 0x00000000, 0x00000000
|
||||
.long 0xffff0000, 0xffff0000, 0xffff0000, 0xffff0000
|
||||
.long 0xffff0000, 0xffff0000, 0x0000ffff, 0xffff0000
|
||||
.long 0xefff1000, 0xffff0000, 0xffff0000, 0xffff0000
|
||||
.long 0xefff1000, 0xefff1000, 0xffff0000, 0x00000000
|
||||
.long 0xffff0000, 0xffff0000, 0xefff1000, 0xefff1000
|
||||
.long 0x00000000, 0x00000000, 0x00000000, 0x00000000
|
||||
.long 0x00000000, 0x00000000, 0x00000000, 0x00000000
|
||||
.long 0x00000000, 0x00000000, 0x00000000, 0x00000000
|
||||
#else
|
||||
.long 0xffff0000, 0x2ffdd002, 0xffff0000, 0xffff0000
|
||||
.long 0x2fffd000, 0xffff0000, 0x1000efff, 0xefff1000
|
||||
.long 0x3ffbc004, 0xffff0000, 0xffff0000, 0xffff0000
|
||||
.long 0x3ffbc004, 0x3ffbc004, 0xffff0000, 0x00000000
|
||||
.long 0xffff0000, 0xffff0000, 0x3ffbc004, 0x3f9bc064
|
||||
.long 0x00000000, 0x00000000, 0x00000000, 0x00000000
|
||||
.long 0x00000000, 0x00000000, 0x00000000, 0x00000000
|
||||
.long 0x00000000, 0x00000000, 0x00000000, 0x00000000
|
||||
.long 0xffff0000, 0xffff0000, 0xffff0000, 0xffff0000
|
||||
.long 0xffff0000, 0xffff0000, 0x0000ffff, 0xffff0000
|
||||
.long 0xefff1000, 0xffff0000, 0xffff0000, 0xffff0000
|
||||
.long 0xefff1000, 0xefff1000, 0xffff0000, 0x00000000
|
||||
.long 0xffff0000, 0xffff0000, 0xefff1000, 0xffff0000
|
||||
.long 0x00000000, 0x00000000, 0x00000000, 0x00000000
|
||||
.long 0x00000000, 0x00000000, 0x00000000, 0x00000000
|
||||
.long 0x00000000, 0x50000000, 0x00000000, 0x00000000
|
||||
#endif
|
||||
gpio_dump_end:
|
||||
|
||||
.p2align
|
||||
|
||||
write_dumpreg:
|
||||
|
@ -626,6 +740,10 @@ continue:
|
|||
lui $t0, %hi(cached_continue - 0x20000000)
|
||||
addiu $t0, $t0, %lo(cached_continue - 0x20000000)
|
||||
jr $t0
|
||||
addiu $a2, $zero, -1
|
||||
#ifdef FULOONG
|
||||
addiu $a2, $zero, -(1 + GRUB_ARCH_MACHINE_FULOONG)
|
||||
#else
|
||||
addiu $a2, $zero, -(1 + GRUB_ARCH_MACHINE_YEELOONG)
|
||||
#endif
|
||||
|
||||
cached_continue:
|
|
@ -20,6 +20,7 @@
|
|||
#include <grub/symbol.h>
|
||||
#include <grub/offsets.h>
|
||||
#include <grub/machine/memory.h>
|
||||
#include <grub/machine/kernel.h>
|
||||
#include <grub/offsets.h>
|
||||
|
||||
#define BASE_ADDR 8
|
||||
|
@ -49,15 +50,17 @@ codestart:
|
|||
|
||||
/* Parse arguments. Has to be done before relocation.
|
||||
So need to do it in asm. */
|
||||
#ifdef GRUB_MACHINE_MIPS_YEELOONG
|
||||
#ifdef GRUB_MACHINE_MIPS_LOONGSON
|
||||
move $s2, $zero
|
||||
move $s3, $zero
|
||||
move $s4, $zero
|
||||
move $s5, $zero
|
||||
move $s7, $zero
|
||||
|
||||
/* $a2 has the environment. */
|
||||
addiu $t0, $a2, 1
|
||||
beq $t0, $zero, argdone
|
||||
addiu $t0, $zero, -0x10
|
||||
and $t1, $a2, $t0
|
||||
beq $t0, $t1, argfw
|
||||
nop
|
||||
move $t0, $a2
|
||||
argcont:
|
||||
|
@ -73,10 +76,18 @@ argcont:
|
|||
b 2f;\
|
||||
move reg, $v0; \
|
||||
1:
|
||||
#define DO_CHECKT1(str, val) \
|
||||
move $t6, $t1 ;\
|
||||
addiu $t7, $s0, (str - base);\
|
||||
bal do_check ;\
|
||||
li $t2, val
|
||||
|
||||
DO_PARSE (busclockstr, $s2)
|
||||
DO_PARSE (cpuclockstr, $s3)
|
||||
DO_PARSE (memsizestr, $s4)
|
||||
DO_PARSE (highmemsizestr, $s5)
|
||||
DO_CHECKT1 (pmon_yeeloong_verstr, GRUB_ARCH_MACHINE_YEELOONG)
|
||||
DO_CHECKT1 (pmon_fuloong_verstr, GRUB_ARCH_MACHINE_FULOONG)
|
||||
2:
|
||||
b argcont
|
||||
addiu $t0, $t0, 4
|
||||
|
@ -120,8 +131,47 @@ busclockstr: .asciiz "busclock="
|
|||
cpuclockstr: .asciiz "cpuclock="
|
||||
memsizestr: .asciiz "memsize="
|
||||
highmemsizestr: .asciiz "highmemsize="
|
||||
machtype_yeeloong_str1: .asciiz "machtype=8.9"
|
||||
machtype_yeeloong_str2: .asciiz "machtype=lemote-yeeloong-"
|
||||
machtype_fuloong_str: .asciiz "machtype=lemote-fuloong-"
|
||||
pmon_yeeloong_str: .asciiz "PMON_VER=LM8"
|
||||
pmon_fuloong_str: .asciiz "PMON_VER=LM6"
|
||||
pmon_yeeloong_verstr: .asciiz "Version=LM8"
|
||||
pmon_fuloong_verstr: .asciiz "Version=LM6"
|
||||
.p2align 2
|
||||
|
||||
argdone:
|
||||
beq $a0, $zero, cmdlinedone
|
||||
nop
|
||||
#define DO_CHECKA1(str, val) \
|
||||
lw $t6, 0($a1) ;\
|
||||
addiu $t7, $s0, (str - base);\
|
||||
bal do_check ;\
|
||||
li $t2, val
|
||||
DO_CHECKA1 (machtype_yeeloong_str1, GRUB_ARCH_MACHINE_YEELOONG)
|
||||
DO_CHECKA1 (machtype_yeeloong_str2, GRUB_ARCH_MACHINE_YEELOONG)
|
||||
DO_CHECKA1 (pmon_yeeloong_str, GRUB_ARCH_MACHINE_YEELOONG)
|
||||
DO_CHECKA1 (machtype_fuloong_str, GRUB_ARCH_MACHINE_FULOONG)
|
||||
DO_CHECKA1 (pmon_fuloong_str, GRUB_ARCH_MACHINE_FULOONG)
|
||||
addiu $a0, $a0, -1
|
||||
b argdone
|
||||
addiu $a1, $a1, 4
|
||||
do_check:
|
||||
lb $t4, 0($t7)
|
||||
beq $t4, $zero, 1f
|
||||
lb $t3, 0($t6)
|
||||
bne $t3, $t4, 2f
|
||||
addiu $t6, $t6, 1
|
||||
b do_check
|
||||
addiu $t7, $t7, 1
|
||||
1:
|
||||
move $s7, $t2
|
||||
2:
|
||||
jr $ra
|
||||
nop
|
||||
argfw:
|
||||
not $s7, $a2
|
||||
cmdlinedone:
|
||||
#endif
|
||||
/* Copy the decompressor. */
|
||||
lui $t1, %hi(base)
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include <grub/pci.h>
|
||||
#include <grub/time.h>
|
||||
#include <grub/ata.h>
|
||||
#include <grub/machine/kernel.h>
|
||||
|
||||
#include <grub/dl.h>
|
||||
|
||||
|
@ -217,26 +218,6 @@ grub_cs5536_read_spd (grub_port_t smbbase, grub_uint8_t dev,
|
|||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
/* Dump of GPIO connections. FIXME: Remove useless and macroify. */
|
||||
static grub_uint32_t gpiodump[] = {
|
||||
0xffff0000, 0x2ffdd002, 0xffff0000, 0xffff0000,
|
||||
0x2fffd000, 0xffff0000, 0x1000efff, 0xefff1000,
|
||||
0x3ffbc004, 0xffff0000, 0xffff0000, 0xffff0000,
|
||||
0x3ffbc004, 0x3ffbc004, 0xffff0000, 0x00000000,
|
||||
0xffff0000, 0xffff0000, 0x3ffbc004, 0x3f9bc064,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0xffff0000, 0xffff0000, 0xffff0000, 0xffff0000,
|
||||
0xffff0000, 0xffff0000, 0x0000ffff, 0xffff0000,
|
||||
0xefff1000, 0xffff0000, 0xffff0000, 0xffff0000,
|
||||
0xefff1000, 0xefff1000, 0xffff0000, 0x00000000,
|
||||
0xffff0000, 0xffff0000, 0xefff1000, 0xffff0000,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0x00000000, 0x50000000, 0x00000000, 0x00000000,
|
||||
};
|
||||
|
||||
static inline void
|
||||
set_io_space (grub_pci_device_t dev, int num, grub_uint16_t start,
|
||||
grub_uint16_t len)
|
||||
|
@ -277,17 +258,6 @@ set_p2d (grub_pci_device_t dev, int num, int dest, grub_uint32_t start)
|
|||
void
|
||||
grub_cs5536_init_geode (grub_pci_device_t dev)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* Make sure GPIO is where we expect it to be. */
|
||||
grub_cs5536_write_msr (dev, GRUB_CS5536_MSR_GPIO_BAR,
|
||||
GRUB_CS5536_LBAR_TURN_ON | GRUB_CS5536_LBAR_GPIO);
|
||||
|
||||
/* Setup GPIO. */
|
||||
for (i = 0; i < (int) ARRAY_SIZE (gpiodump); i++)
|
||||
((volatile grub_uint32_t *) (GRUB_MACHINE_PCI_IO_BASE
|
||||
+ GRUB_CS5536_LBAR_GPIO)) [i] = gpiodump[i];
|
||||
|
||||
/* Enable more BARs. */
|
||||
grub_cs5536_write_msr (dev, GRUB_CS5536_MSR_IRQ_MAP_BAR,
|
||||
GRUB_CS5536_LBAR_TURN_ON | GRUB_CS5536_LBAR_IRQ_MAP);
|
||||
|
@ -299,11 +269,25 @@ grub_cs5536_init_geode (grub_pci_device_t dev)
|
|||
GRUB_CS5536_LBAR_TURN_ON | GRUB_CS5536_LBAR_PM);
|
||||
|
||||
/* Setup DIVIL. */
|
||||
grub_cs5536_write_msr (dev, GRUB_CS5536_MSR_DIVIL_LEG_IO,
|
||||
GRUB_CS5536_MSR_DIVIL_LEG_IO_MODE_X86
|
||||
| GRUB_CS5536_MSR_DIVIL_LEG_IO_F_REMAP
|
||||
| GRUB_CS5536_MSR_DIVIL_LEG_IO_RTC_ENABLE0
|
||||
| GRUB_CS5536_MSR_DIVIL_LEG_IO_RTC_ENABLE1);
|
||||
switch (grub_arch_machine)
|
||||
{
|
||||
case GRUB_ARCH_MACHINE_YEELOONG:
|
||||
grub_cs5536_write_msr (dev, GRUB_CS5536_MSR_DIVIL_LEG_IO,
|
||||
GRUB_CS5536_MSR_DIVIL_LEG_IO_MODE_X86
|
||||
| GRUB_CS5536_MSR_DIVIL_LEG_IO_F_REMAP
|
||||
| GRUB_CS5536_MSR_DIVIL_LEG_IO_RTC_ENABLE0
|
||||
| GRUB_CS5536_MSR_DIVIL_LEG_IO_RTC_ENABLE1);
|
||||
break;
|
||||
case GRUB_ARCH_MACHINE_FULOONG:
|
||||
grub_cs5536_write_msr (dev, GRUB_CS5536_MSR_DIVIL_LEG_IO,
|
||||
GRUB_CS5536_MSR_DIVIL_LEG_IO_UART2_COM3
|
||||
| GRUB_CS5536_MSR_DIVIL_LEG_IO_UART1_COM1
|
||||
| GRUB_CS5536_MSR_DIVIL_LEG_IO_MODE_X86
|
||||
| GRUB_CS5536_MSR_DIVIL_LEG_IO_F_REMAP
|
||||
| GRUB_CS5536_MSR_DIVIL_LEG_IO_RTC_ENABLE0
|
||||
| GRUB_CS5536_MSR_DIVIL_LEG_IO_RTC_ENABLE1);
|
||||
break;
|
||||
}
|
||||
grub_cs5536_write_msr (dev, GRUB_CS5536_MSR_DIVIL_IRQ_MAPPER_PRIMARY_MASK,
|
||||
(~GRUB_CS5536_DIVIL_LPC_INTERRUPTS) & 0xffff);
|
||||
grub_cs5536_write_msr (dev, GRUB_CS5536_MSR_DIVIL_IRQ_MAPPER_LPC_MASK,
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
#include <grub/dl.h>
|
||||
#include <grub/pci.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/mm_private.h>
|
||||
#include <grub/cache.h>
|
||||
|
||||
GRUB_MOD_LICENSE ("GPLv3+");
|
||||
|
||||
|
@ -28,17 +30,24 @@ GRUB_MOD_LICENSE ("GPLv3+");
|
|||
struct grub_pci_dma_chunk *
|
||||
grub_memalign_dma32 (grub_size_t align, grub_size_t size)
|
||||
{
|
||||
return grub_memalign (align, size);
|
||||
void *ret = grub_memalign (align, size);
|
||||
if (!ret)
|
||||
return 0;
|
||||
grub_arch_sync_dma_caches (ret, size);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* FIXME: evil. */
|
||||
void
|
||||
grub_dma_free (struct grub_pci_dma_chunk *ch)
|
||||
{
|
||||
grub_size_t size = (((struct grub_mm_header *) ch) - 1)->size * GRUB_MM_ALIGN;
|
||||
grub_arch_sync_dma_caches (ch, size);
|
||||
grub_free (ch);
|
||||
}
|
||||
/* #endif */
|
||||
|
||||
#ifdef GRUB_MACHINE_MIPS_YEELOONG
|
||||
#ifdef GRUB_MACHINE_MIPS_LOONGSON
|
||||
volatile void *
|
||||
grub_dma_get_virt (struct grub_pci_dma_chunk *ch)
|
||||
{
|
||||
|
@ -101,13 +110,13 @@ grub_pci_iterate (grub_pci_iteratefunc_t hook)
|
|||
continue;
|
||||
}
|
||||
|
||||
#ifdef GRUB_MACHINE_MIPS_YEELOONG
|
||||
#ifdef GRUB_MACHINE_MIPS_LOONGSON
|
||||
/* Skip ghosts. */
|
||||
if (id == GRUB_YEELOONG_OHCI_PCIID
|
||||
&& dev.function == GRUB_YEELOONG_OHCI_GHOST_FUNCTION)
|
||||
if (id == GRUB_LOONGSON_OHCI_PCIID
|
||||
&& dev.function == GRUB_LOONGSON_OHCI_GHOST_FUNCTION)
|
||||
continue;
|
||||
if (id == GRUB_YEELOONG_EHCI_PCIID
|
||||
&& dev.function == GRUB_YEELOONG_EHCI_GHOST_FUNCTION)
|
||||
if (id == GRUB_LOONGSON_EHCI_PCIID
|
||||
&& dev.function == GRUB_LOONGSON_EHCI_GHOST_FUNCTION)
|
||||
continue;
|
||||
#endif
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ grub_normal_add_menu_entry (int argc, const char **args, char **classes,
|
|||
if (! menu_sourcecode)
|
||||
return grub_errno;
|
||||
|
||||
if (classes)
|
||||
if (classes && classes[0])
|
||||
{
|
||||
int i;
|
||||
for (i = 0; classes[i]; i++); /* count # of menuentry classes */
|
||||
|
@ -255,7 +255,8 @@ grub_cmd_menuentry (grub_extcmd_context_t ctxt, int argc, char **args)
|
|||
|
||||
if (! ctxt->script)
|
||||
return grub_normal_add_menu_entry (argc, (const char **) args,
|
||||
ctxt->state[0].args, ctxt->state[1].arg,
|
||||
(ctxt->state[0].set ? ctxt->state[0].args
|
||||
: NULL), ctxt->state[1].arg,
|
||||
ctxt->state[2].arg, 0,
|
||||
ctxt->state[3].arg,
|
||||
ctxt->extcmd->cmd->name[0] == 's');
|
||||
|
|
|
@ -160,18 +160,23 @@ grub_atapi_identify (struct grub_ata_device *dev)
|
|||
|
||||
grub_ata_regset (dev, GRUB_ATA_REG_DISK, 0xE0 | dev->device << 4);
|
||||
grub_ata_wait ();
|
||||
if (grub_ata_check_ready (dev))
|
||||
if ((grub_ata_regget (dev, GRUB_ATA_REG_STATUS) & GRUB_ATA_STATUS_BUSY)
|
||||
&& grub_ata_wait_not_busy (dev, dev->present ? GRUB_ATA_TOUT_DEV_INIT
|
||||
: GRUB_ATA_TOUT_STD))
|
||||
{
|
||||
grub_free (info);
|
||||
dev->present = 0;
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
grub_ata_regset (dev, GRUB_ATA_REG_CMD, GRUB_ATA_CMD_IDENTIFY_PACKET_DEVICE);
|
||||
grub_ata_wait ();
|
||||
|
||||
if (grub_ata_wait_drq (dev, 0, GRUB_ATA_TOUT_STD))
|
||||
if (grub_ata_wait_drq (dev, 0, dev->present ? GRUB_ATA_TOUT_DEV_INIT
|
||||
: GRUB_ATA_TOUT_STD))
|
||||
{
|
||||
grub_free (info);
|
||||
dev->present = 0;
|
||||
return grub_errno;
|
||||
}
|
||||
grub_ata_pio_read (dev, info, GRUB_DISK_SECTOR_SIZE);
|
||||
|
@ -258,8 +263,11 @@ grub_ata_identify (struct grub_ata_device *dev)
|
|||
|
||||
grub_ata_regset (dev, GRUB_ATA_REG_DISK, 0xE0 | dev->device << 4);
|
||||
grub_ata_wait ();
|
||||
if (grub_ata_check_ready (dev))
|
||||
if ((grub_ata_regget (dev, GRUB_ATA_REG_STATUS) & GRUB_ATA_STATUS_BUSY)
|
||||
&& grub_ata_wait_not_busy (dev, dev->present ? GRUB_ATA_TOUT_DEV_INIT
|
||||
: GRUB_ATA_TOUT_STD))
|
||||
{
|
||||
dev->present = 0;
|
||||
grub_free (info);
|
||||
return grub_errno;
|
||||
}
|
||||
|
@ -267,7 +275,8 @@ grub_ata_identify (struct grub_ata_device *dev)
|
|||
grub_ata_regset (dev, GRUB_ATA_REG_CMD, GRUB_ATA_CMD_IDENTIFY_DEVICE);
|
||||
grub_ata_wait ();
|
||||
|
||||
if (grub_ata_wait_drq (dev, 0, GRUB_ATA_TOUT_STD))
|
||||
if (grub_ata_wait_drq (dev, 0, dev->present ? GRUB_ATA_TOUT_DEV_INIT
|
||||
: GRUB_ATA_TOUT_STD))
|
||||
{
|
||||
grub_free (info);
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
|
@ -280,13 +289,18 @@ grub_ata_identify (struct grub_ata_device *dev)
|
|||
return grub_atapi_identify (dev);
|
||||
|
||||
else if (sts == 0x00)
|
||||
/* No device, return error but don't print message. */
|
||||
return GRUB_ERR_UNKNOWN_DEVICE;
|
||||
|
||||
{
|
||||
dev->present = 0;
|
||||
/* No device, return error but don't print message. */
|
||||
return GRUB_ERR_UNKNOWN_DEVICE;
|
||||
}
|
||||
else
|
||||
/* Other Error. */
|
||||
return grub_error (GRUB_ERR_UNKNOWN_DEVICE,
|
||||
"device cannot be identified");
|
||||
{
|
||||
dev->present = 0;
|
||||
/* Other Error. */
|
||||
return grub_error (GRUB_ERR_UNKNOWN_DEVICE,
|
||||
"device cannot be identified");
|
||||
}
|
||||
}
|
||||
|
||||
grub_ata_pio_read (dev, info, GRUB_DISK_SECTOR_SIZE);
|
||||
|
@ -381,6 +395,7 @@ grub_ata_device_initialize (int port, int device, int addr, int addr2)
|
|||
dev->device = device;
|
||||
dev->ioaddress = addr + GRUB_MACHINE_PCI_IO_BASE;
|
||||
dev->ioaddress2 = addr2 + GRUB_MACHINE_PCI_IO_BASE;
|
||||
dev->present = 1;
|
||||
dev->next = NULL;
|
||||
|
||||
/* Register the device. */
|
||||
|
|
|
@ -316,10 +316,7 @@ load_font_index (grub_file_t file, grub_uint32_t sect_length, struct
|
|||
return 1;
|
||||
font->bmp_idx = grub_malloc (0x10000 * sizeof (grub_uint16_t));
|
||||
if (!font->bmp_idx)
|
||||
{
|
||||
grub_free (font->char_index);
|
||||
return 1;
|
||||
}
|
||||
return 1;
|
||||
grub_memset (font->bmp_idx, 0xff, 0x10000 * sizeof (grub_uint16_t));
|
||||
|
||||
|
||||
|
@ -494,7 +491,7 @@ grub_font_load (const char *filename)
|
|||
#endif
|
||||
|
||||
/* Allocate the font object. */
|
||||
font = (grub_font_t) grub_malloc (sizeof (struct grub_font));
|
||||
font = (grub_font_t) grub_zalloc (sizeof (struct grub_font));
|
||||
if (!font)
|
||||
goto fail;
|
||||
|
||||
|
@ -640,6 +637,11 @@ grub_font_load (const char *filename)
|
|||
return 0;
|
||||
|
||||
fail:
|
||||
if (file)
|
||||
grub_file_close (file);
|
||||
if (font)
|
||||
font->file = 0;
|
||||
|
||||
free_font (font);
|
||||
return 1;
|
||||
}
|
||||
|
@ -799,6 +801,7 @@ free_font (grub_font_t font)
|
|||
grub_free (font->name);
|
||||
grub_free (font->family);
|
||||
grub_free (font->char_index);
|
||||
grub_free (font->bmp_idx);
|
||||
grub_free (font);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,11 @@ loadfont_command (grub_command_t cmd __attribute__ ((unused)),
|
|||
|
||||
while (argc--)
|
||||
if (grub_font_load (*args++) != 0)
|
||||
return GRUB_ERR_BAD_FONT;
|
||||
{
|
||||
if (!grub_errno)
|
||||
return grub_error (GRUB_ERR_BAD_FONT, "invalid font");
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
|
|
@ -626,7 +626,7 @@ grub_dl_load_file (const char *filename)
|
|||
return 0;
|
||||
}
|
||||
|
||||
mod->ref_count = 0;
|
||||
mod->ref_count--;
|
||||
return mod;
|
||||
}
|
||||
|
||||
|
@ -683,8 +683,7 @@ grub_dl_unload (grub_dl_t mod)
|
|||
{
|
||||
depn = dep->next;
|
||||
|
||||
if (! grub_dl_unref (dep->mod))
|
||||
grub_dl_unload (dep->mod);
|
||||
grub_dl_unload (dep->mod);
|
||||
|
||||
grub_free (dep);
|
||||
}
|
||||
|
|
|
@ -53,8 +53,8 @@ grub_module_iterate (int (*hook) (struct grub_module_header *header))
|
|||
}
|
||||
}
|
||||
|
||||
/* This is actualy platform-independant but used only on yeeloong and sparc. */
|
||||
#if defined (GRUB_MACHINE_MIPS_YEELOONG) || defined (GRUB_MACHINE_SPARC64)
|
||||
/* This is actualy platform-independant but used only on loongson and sparc. */
|
||||
#if defined (GRUB_MACHINE_MIPS_LOONGSON) || defined (GRUB_MACHINE_SPARC64)
|
||||
grub_addr_t
|
||||
grub_modules_get_end (void)
|
||||
{
|
||||
|
|
|
@ -8,3 +8,38 @@ FUNCTION (grub_cpu_flush_cache)
|
|||
FUNCTION (grub_arch_sync_caches)
|
||||
#include "cache_flush.S"
|
||||
j $ra
|
||||
|
||||
FUNCTION (grub_arch_sync_dma_caches)
|
||||
move $t2, $a0
|
||||
addu $t3, $a0, $a1
|
||||
srl $t2, $t2, 5
|
||||
sll $t2, $t2, 5
|
||||
addu $t3, $t3, 0x1f
|
||||
srl $t3, $t3, 5
|
||||
sll $t3, $t3, 5
|
||||
move $t0, $t2
|
||||
subu $t1, $t3, $t2
|
||||
1:
|
||||
cache 1, 0($t0)
|
||||
addiu $t1, $t1, 0xffff
|
||||
bne $t1, $zero, 1b
|
||||
addiu $t0, $t0, 0x1
|
||||
sync
|
||||
move $t0, $t2
|
||||
subu $t1, $t3, $t2
|
||||
2:
|
||||
cache 0, 0($t0)
|
||||
addiu $t1, $t1, 0xffff
|
||||
bne $t1, $zero, 2b
|
||||
addiu $t0, $t0, 0x1
|
||||
sync
|
||||
move $t0, $t2
|
||||
subu $t1, $t3, $t2
|
||||
2:
|
||||
cache 23, 0($t0)
|
||||
addiu $t1, $t1, 0xffff
|
||||
bne $t1, $zero, 2b
|
||||
addiu $t0, $t0, 0x1
|
||||
sync
|
||||
|
||||
jr $ra
|
|
@ -34,6 +34,7 @@
|
|||
#include <grub/cpu/memory.h>
|
||||
|
||||
extern void grub_video_sm712_init (void);
|
||||
extern void grub_video_sis315pro_init (void);
|
||||
extern void grub_video_init (void);
|
||||
extern void grub_bitmap_init (void);
|
||||
extern void grub_font_init (void);
|
||||
|
@ -64,7 +65,7 @@ init_pci (void)
|
|||
/* FIXME: autoscan for BARs and devices. */
|
||||
switch (pciid)
|
||||
{
|
||||
case GRUB_YEELOONG_OHCI_PCIID:
|
||||
case GRUB_LOONGSON_OHCI_PCIID:
|
||||
addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0);
|
||||
grub_pci_write (addr, 0x5025000);
|
||||
addr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND);
|
||||
|
@ -76,7 +77,7 @@ init_pci (void)
|
|||
addr = grub_pci_make_address (dev, GRUB_PCI_REG_STATUS);
|
||||
grub_pci_write_word (addr, 0x0200 | GRUB_PCI_STATUS_CAPABILITIES);
|
||||
break;
|
||||
case GRUB_YEELOONG_EHCI_PCIID:
|
||||
case GRUB_LOONGSON_EHCI_PCIID:
|
||||
addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0);
|
||||
grub_pci_write (addr, 0x5026000);
|
||||
addr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND);
|
||||
|
@ -148,7 +149,7 @@ grub_machine_init (void)
|
|||
if (err)
|
||||
grub_fatal ("Couldn't init SMBus: %s\n", grub_errmsg);
|
||||
|
||||
/* Yeeloong has only one memory slot. */
|
||||
/* Yeeloong and Fuloong have only one memory slot. */
|
||||
err = grub_cs5536_read_spd (smbbase, GRUB_SMB_RAM_START_ADDR, &spd);
|
||||
if (err)
|
||||
grub_fatal ("Couldn't read SPD: %s\n", grub_errmsg);
|
||||
|
@ -187,12 +188,14 @@ grub_machine_init (void)
|
|||
relies on a working heap. */
|
||||
grub_video_init ();
|
||||
grub_video_sm712_init ();
|
||||
grub_video_sis315pro_init ();
|
||||
grub_bitmap_init ();
|
||||
grub_font_init ();
|
||||
grub_gfxterm_init ();
|
||||
|
||||
grub_keylayouts_init ();
|
||||
grub_at_keyboard_init ();
|
||||
if (grub_arch_machine == GRUB_ARCH_MACHINE_YEELOONG)
|
||||
grub_at_keyboard_init ();
|
||||
|
||||
grub_terminfo_init ();
|
||||
grub_serial_init ();
|
||||
|
@ -208,10 +211,28 @@ grub_machine_fini (void)
|
|||
void
|
||||
grub_halt (void)
|
||||
{
|
||||
grub_outb (grub_inb (GRUB_CPU_LOONGSON_GPIOCFG)
|
||||
& ~GRUB_CPU_LOONGSON_SHUTDOWN_GPIO, GRUB_CPU_LOONGSON_GPIOCFG);
|
||||
|
||||
grub_millisleep (1500);
|
||||
switch (grub_arch_machine)
|
||||
{
|
||||
case GRUB_ARCH_MACHINE_FULOONG:
|
||||
{
|
||||
grub_pci_device_t dev;
|
||||
grub_port_t p;
|
||||
if (grub_cs5536_find (&dev))
|
||||
{
|
||||
p = (grub_cs5536_read_msr (dev, GRUB_CS5536_MSR_GPIO_BAR)
|
||||
& GRUB_CS5536_LBAR_ADDR_MASK) + GRUB_MACHINE_PCI_IO_BASE;
|
||||
grub_outl ((1 << 13), p + 4);
|
||||
grub_outl ((1 << 29), p);
|
||||
grub_millisleep (5000);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case GRUB_ARCH_MACHINE_YEELOONG:
|
||||
grub_outb (grub_inb (GRUB_CPU_LOONGSON_GPIOCFG)
|
||||
& ~GRUB_CPU_YEELOONG_SHUTDOWN_GPIO, GRUB_CPU_LOONGSON_GPIOCFG);
|
||||
grub_millisleep (1500);
|
||||
break;
|
||||
}
|
||||
|
||||
grub_printf ("Shutdown failed\n");
|
||||
grub_refresh ();
|
|
@ -20,6 +20,7 @@
|
|||
#include <grub/symbol.h>
|
||||
#include <grub/offsets.h>
|
||||
#include <grub/machine/memory.h>
|
||||
#include <grub/machine/kernel.h>
|
||||
#include <grub/offsets.h>
|
||||
|
||||
#define BASE_ADDR 8
|
||||
|
@ -35,7 +36,7 @@ start:
|
|||
bal cont
|
||||
nop
|
||||
|
||||
. = _start + GRUB_KERNEL_MIPS_YEELOONG_TOTAL_MODULE_SIZE
|
||||
. = _start + GRUB_KERNEL_MIPS_LOONGSON_TOTAL_MODULE_SIZE
|
||||
total_module_size:
|
||||
.long 0
|
||||
|
||||
|
@ -52,25 +53,28 @@ VARIABLE(grub_prefix)
|
|||
. = _start + GRUB_KERNEL_MACHINE_PREFIX_END
|
||||
VARIABLE (grub_arch_cpuclock)
|
||||
.long 0
|
||||
#ifdef GRUB_MACHINE_MIPS_YEELOONG
|
||||
#ifdef GRUB_MACHINE_MIPS_LOONGSON
|
||||
VARIABLE (grub_arch_busclock)
|
||||
.long 0
|
||||
VARIABLE (grub_arch_memsize)
|
||||
.long 0
|
||||
VARIABLE (grub_arch_highmemsize)
|
||||
.long 0
|
||||
VARIABLE (grub_arch_machine)
|
||||
.long GRUB_ARCH_MACHINE_FULOONG
|
||||
#endif
|
||||
cont:
|
||||
/* Save our base. */
|
||||
move $s0, $ra
|
||||
|
||||
#ifdef GRUB_MACHINE_MIPS_YEELOONG
|
||||
#ifdef GRUB_MACHINE_MIPS_LOONGSON
|
||||
lui $t1, %hi(grub_arch_busclock)
|
||||
addiu $t1, %lo(grub_arch_busclock)
|
||||
sw $s2, 0($t1)
|
||||
sw $s3, 4($t1)
|
||||
sw $s4, 8($t1)
|
||||
sw $s5, 12($t1)
|
||||
sw $s7, 16($t1)
|
||||
#endif
|
||||
|
||||
/* Move the modules out of BSS. */
|
||||
|
|
|
@ -311,11 +311,13 @@ grub_memalign (grub_size_t align, grub_size_t size)
|
|||
count++;
|
||||
goto again;
|
||||
|
||||
#if 0
|
||||
case 1:
|
||||
/* Unload unneeded modules. */
|
||||
grub_dl_unload_unneeded ();
|
||||
count++;
|
||||
goto again;
|
||||
#endif
|
||||
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -33,15 +33,14 @@ GRUB_MOD_LICENSE ("GPLv3+");
|
|||
/* For frequencies. */
|
||||
#include <grub/machine/time.h>
|
||||
|
||||
#ifdef GRUB_MACHINE_MIPS_YEELOONG
|
||||
|
||||
#ifdef GRUB_MACHINE_MIPS_LOONGSON
|
||||
#include <grub/pci.h>
|
||||
|
||||
/* This can be detected on runtime from PMON, but:
|
||||
a) it wouldn't work when GRUB is the firmware
|
||||
and
|
||||
b) for now we only support Yeeloong anyway. */
|
||||
#define LOONGSON_MACHTYPE "machtype=lemote-yeeloong-2f-8.9inches"
|
||||
const char loongson_machtypes[][60] =
|
||||
{
|
||||
[GRUB_ARCH_MACHINE_YEELOONG] = "machtype=lemote-yeeloong-2f-8.9inches",
|
||||
[GRUB_ARCH_MACHINE_FULOONG] = "machtype=lemote-fuloong-2f-unknown"
|
||||
};
|
||||
#endif
|
||||
|
||||
static grub_dl_t my_mod;
|
||||
|
@ -55,7 +54,7 @@ static grub_uint8_t *playground;
|
|||
static grub_addr_t target_addr, entry_addr;
|
||||
static int linux_argc;
|
||||
static grub_off_t argv_off;
|
||||
#ifdef GRUB_MACHINE_MIPS_YEELOONG
|
||||
#ifdef GRUB_MACHINE_MIPS_LOONGSON
|
||||
static grub_off_t envp_off;
|
||||
#endif
|
||||
static grub_off_t rd_addr_arg_off, rd_size_arg_off;
|
||||
|
@ -70,7 +69,7 @@ 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_YEELOONG
|
||||
#ifdef GRUB_MACHINE_MIPS_LOONGSON
|
||||
state.gpr[6] = target_addr + envp_off;
|
||||
#else
|
||||
state.gpr[6] = 0;
|
||||
|
@ -213,7 +212,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
|||
grub_uint32_t *linux_argv;
|
||||
char *linux_args;
|
||||
grub_err_t err;
|
||||
#ifdef GRUB_MACHINE_MIPS_YEELOONG
|
||||
#ifdef GRUB_MACHINE_MIPS_LOONGSON
|
||||
char *linux_envs;
|
||||
grub_uint32_t *linux_envp;
|
||||
#endif
|
||||
|
@ -238,7 +237,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
|||
|
||||
/* For arguments. */
|
||||
linux_argc = argc;
|
||||
#ifdef LOONGSON_MACHTYPE
|
||||
#ifdef GRUB_MACHINE_MIPS_LOONGSON
|
||||
linux_argc++;
|
||||
#endif
|
||||
/* Main arguments. */
|
||||
|
@ -253,8 +252,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
|||
/* Normal arguments. */
|
||||
for (i = 1; i < argc; i++)
|
||||
size += ALIGN_UP (grub_strlen (argv[i]) + 1, 4);
|
||||
#ifdef LOONGSON_MACHTYPE
|
||||
size += ALIGN_UP (sizeof (LOONGSON_MACHTYPE), 4);
|
||||
#ifdef GRUB_MACHINE_MIPS_LOONGSON
|
||||
size += ALIGN_UP (sizeof (loongson_machtypes[0]), 4);
|
||||
#endif
|
||||
|
||||
/* rd arguments. */
|
||||
|
@ -293,14 +292,20 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
|||
linux_argv++;
|
||||
linux_args += ALIGN_UP (sizeof ("a0"), 4);
|
||||
|
||||
#ifdef LOONGSON_MACHTYPE
|
||||
/* In Loongson platform, it is the responsibility of the bootloader/firmware
|
||||
to supply the OS kernel with machine type information. */
|
||||
grub_memcpy (linux_args, LOONGSON_MACHTYPE, sizeof (LOONGSON_MACHTYPE));
|
||||
*linux_argv = (grub_uint8_t *) linux_args - (grub_uint8_t *) playground
|
||||
+ target_addr;
|
||||
linux_argv++;
|
||||
linux_args += ALIGN_UP (sizeof (LOONGSON_MACHTYPE), 4);
|
||||
#ifdef GRUB_MACHINE_MIPS_LOONGSON
|
||||
{
|
||||
unsigned mtype = grub_arch_machine;
|
||||
if (mtype >= ARRAY_SIZE (loongson_machtypes))
|
||||
mtype = 0;
|
||||
/* In Loongson platform, it is the responsibility of the bootloader/firmware
|
||||
to supply the OS kernel with machine type information. */
|
||||
grub_memcpy (linux_args, loongson_machtypes[mtype],
|
||||
sizeof (loongson_machtypes[mtype]));
|
||||
*linux_argv = (grub_uint8_t *) linux_args - (grub_uint8_t *) playground
|
||||
+ target_addr;
|
||||
linux_argv++;
|
||||
linux_args += ALIGN_UP (sizeof (loongson_machtypes[mtype]), 4);
|
||||
}
|
||||
#endif
|
||||
|
||||
for (i = 1; i < argc; i++)
|
||||
|
@ -327,7 +332,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
|||
|
||||
extra = linux_args;
|
||||
|
||||
#ifdef GRUB_MACHINE_MIPS_YEELOONG
|
||||
#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);
|
||||
|
|
|
@ -111,12 +111,12 @@ static const struct
|
|||
{0x38, GRUB_KEYBOARD_KEY_RIGHT_ALT},
|
||||
{0x47, GRUB_KEYBOARD_KEY_HOME},
|
||||
{0x48, GRUB_KEYBOARD_KEY_UP},
|
||||
{0x49, GRUB_KEYBOARD_KEY_NPAGE},
|
||||
{0x49, GRUB_KEYBOARD_KEY_PPAGE},
|
||||
{0x4b, GRUB_KEYBOARD_KEY_LEFT},
|
||||
{0x4d, GRUB_KEYBOARD_KEY_RIGHT},
|
||||
{0x4f, GRUB_KEYBOARD_KEY_END},
|
||||
{0x50, GRUB_KEYBOARD_KEY_DOWN},
|
||||
{0x51, GRUB_KEYBOARD_KEY_PPAGE},
|
||||
{0x51, GRUB_KEYBOARD_KEY_NPAGE},
|
||||
{0x52, GRUB_KEYBOARD_KEY_INSERT},
|
||||
{0x53, GRUB_KEYBOARD_KEY_DELETE},
|
||||
};
|
||||
|
@ -259,7 +259,7 @@ grub_keyboard_controller_write (grub_uint8_t c)
|
|||
grub_outb (c, KEYBOARD_REG_DATA);
|
||||
}
|
||||
|
||||
#if !defined (GRUB_MACHINE_MIPS_YEELOONG) && !defined (GRUB_MACHINE_QEMU)
|
||||
#if !defined (GRUB_MACHINE_MIPS_LOONGSON) && !defined (GRUB_MACHINE_QEMU)
|
||||
|
||||
static grub_uint8_t
|
||||
grub_keyboard_controller_read (void)
|
||||
|
@ -332,7 +332,7 @@ set_scancodes (void)
|
|||
return;
|
||||
}
|
||||
|
||||
#if !(defined (GRUB_MACHINE_MIPS_YEELOONG) || defined (GRUB_MACHINE_QEMU))
|
||||
#if !(defined (GRUB_MACHINE_MIPS_LOONGSON) || defined (GRUB_MACHINE_QEMU))
|
||||
current_set = 1;
|
||||
return;
|
||||
#endif
|
||||
|
@ -569,7 +569,7 @@ grub_keyboard_controller_init (struct grub_term_input *term __attribute__ ((unus
|
|||
keyboard_controller_wait_until_ready ();
|
||||
grub_inb (KEYBOARD_REG_DATA);
|
||||
}
|
||||
#if defined (GRUB_MACHINE_MIPS_YEELOONG) || defined (GRUB_MACHINE_QEMU)
|
||||
#if defined (GRUB_MACHINE_MIPS_LOONGSON) || defined (GRUB_MACHINE_QEMU)
|
||||
grub_keyboard_controller_orig = 0;
|
||||
grub_keyboard_orig_set = 2;
|
||||
#else
|
||||
|
|
|
@ -37,7 +37,8 @@ static const grub_port_t serial_hw_io_addr[] = GRUB_MACHINE_SERIAL_PORTS;
|
|||
|
||||
/* Convert speed to divisor. */
|
||||
static unsigned short
|
||||
serial_get_divisor (unsigned int speed)
|
||||
serial_get_divisor (const struct grub_serial_port *port,
|
||||
const struct grub_serial_config *config)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
|
@ -63,13 +64,16 @@ serial_get_divisor (unsigned int speed)
|
|||
|
||||
/* Set the baud rate. */
|
||||
for (i = 0; i < ARRAY_SIZE (divisor_tab); i++)
|
||||
if (divisor_tab[i].speed == speed)
|
||||
/* UART in Yeeloong runs twice the usual rate. */
|
||||
#ifdef GRUB_MACHINE_MIPS_YEELOONG
|
||||
return 2 * divisor_tab[i].div;
|
||||
#else
|
||||
return divisor_tab[i].div;
|
||||
if (divisor_tab[i].speed == config->speed)
|
||||
{
|
||||
/* internal Loongson UART runs twice the usual rate. */
|
||||
#ifdef GRUB_MACHINE_MIPS_LOONGSON
|
||||
if (port->port == 0xbff003f8)
|
||||
return 2 * divisor_tab[i].div;
|
||||
else
|
||||
#endif
|
||||
return divisor_tab[i].div;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -93,7 +97,7 @@ do_real_config (struct grub_serial_port *port)
|
|||
|
||||
port->broken = 0;
|
||||
|
||||
divisor = serial_get_divisor (port->config.speed);
|
||||
divisor = serial_get_divisor (port, &port->config);
|
||||
|
||||
/* Turn off the interrupt. */
|
||||
grub_outb (0, port->port + UART_IER);
|
||||
|
@ -111,8 +115,8 @@ do_real_config (struct grub_serial_port *port)
|
|||
| stop_bits[port->config.stop_bits]);
|
||||
grub_outb (status, port->port + UART_LCR);
|
||||
|
||||
/* In Yeeloong serial port has only 3 wires. */
|
||||
#ifndef GRUB_MACHINE_MIPS_YEELOONG
|
||||
/* On Loongson machines serial port has only 3 wires. */
|
||||
#ifndef GRUB_MACHINE_MIPS_LOONGSON
|
||||
/* Enable the FIFO. */
|
||||
grub_outb (UART_ENABLE_FIFO_TRIGGER1, port->port + UART_FCR);
|
||||
|
||||
|
@ -188,7 +192,7 @@ serial_hw_configure (struct grub_serial_port *port,
|
|||
{
|
||||
unsigned short divisor;
|
||||
|
||||
divisor = serial_get_divisor (config->speed);
|
||||
divisor = serial_get_divisor (port, config);
|
||||
if (divisor == 0)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "bad speed");
|
||||
|
||||
|
|
|
@ -26,6 +26,9 @@
|
|||
#include <grub/extcmd.h>
|
||||
#include <grub/i18n.h>
|
||||
#include <grub/list.h>
|
||||
#ifdef GRUB_MACHINE_MIPS_LOONGSON
|
||||
#include <grub/machine/kernel.h>
|
||||
#endif
|
||||
|
||||
GRUB_MOD_LICENSE ("GPLv3+");
|
||||
|
||||
|
@ -297,18 +300,23 @@ grub_serial_register (struct grub_serial_port *port)
|
|||
port->term_in = in;
|
||||
port->term_out = out;
|
||||
grub_terminfo_output_register (out, "vt100");
|
||||
#ifdef GRUB_MACHINE_MIPS_YEELOONG
|
||||
if (grub_strcmp (port->name, "com0") == 0)
|
||||
#ifdef GRUB_MACHINE_MIPS_LOONGSON
|
||||
if (grub_strcmp (port->name,
|
||||
(grub_arch_machine == GRUB_ARCH_MACHINE_YEELOONG)
|
||||
? "com0" : "com2") == 0)
|
||||
{
|
||||
grub_term_register_input_active ("serial_*", in);
|
||||
grub_term_register_output_active ("serial_*", out);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
grub_term_register_input ("serial_*", in);
|
||||
grub_term_register_output ("serial_*", out);
|
||||
grub_term_register_input_inactive ("serial_*", in);
|
||||
grub_term_register_output_inactive ("serial_*", out);
|
||||
}
|
||||
#else
|
||||
grub_term_register_input ("serial_*", in);
|
||||
grub_term_register_output ("serial_*", out);
|
||||
#endif
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
|
246
grub-core/video/sis315pro.c
Normal file
246
grub-core/video/sis315pro.c
Normal file
|
@ -0,0 +1,246 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2005,2006,2007,2008,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/>.
|
||||
*/
|
||||
|
||||
#define grub_video_render_target grub_video_fbrender_target
|
||||
|
||||
#include <grub/err.h>
|
||||
#include <grub/types.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/video.h>
|
||||
#include <grub/video_fb.h>
|
||||
#include <grub/pci.h>
|
||||
#include <grub/vga.h>
|
||||
|
||||
#define GRUB_SIS315PRO_PCIID 0x03251039
|
||||
#define GRUB_SIS315PRO_TOTAL_MEMORY_SPACE 0x800000
|
||||
|
||||
static struct
|
||||
{
|
||||
struct grub_video_mode_info mode_info;
|
||||
struct grub_video_render_target *render_target;
|
||||
|
||||
grub_uint8_t *ptr;
|
||||
int mapped;
|
||||
grub_uint32_t base;
|
||||
grub_pci_device_t dev;
|
||||
} framebuffer;
|
||||
|
||||
#ifndef TEST
|
||||
static grub_err_t
|
||||
grub_video_sis315pro_video_init (void)
|
||||
{
|
||||
/* Reset frame buffer. */
|
||||
grub_memset (&framebuffer, 0, sizeof(framebuffer));
|
||||
|
||||
return grub_video_fb_init ();
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_video_sis315pro_video_fini (void)
|
||||
{
|
||||
if (framebuffer.mapped)
|
||||
grub_pci_device_unmap_range (framebuffer.dev, framebuffer.ptr,
|
||||
GRUB_SIS315PRO_TOTAL_MEMORY_SPACE);
|
||||
|
||||
return grub_video_fb_fini ();
|
||||
}
|
||||
#endif
|
||||
|
||||
static grub_err_t
|
||||
grub_video_sis315pro_setup (unsigned int width, unsigned int height,
|
||||
unsigned int mode_type,
|
||||
unsigned int mode_mask __attribute__ ((unused)))
|
||||
{
|
||||
int depth;
|
||||
grub_err_t err;
|
||||
int found = 0;
|
||||
|
||||
#ifndef TEST
|
||||
auto int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev, grub_pci_id_t pciid __attribute__ ((unused)));
|
||||
int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev, grub_pci_id_t pciid __attribute__ ((unused)))
|
||||
{
|
||||
grub_pci_address_t addr;
|
||||
grub_uint32_t class;
|
||||
|
||||
addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS);
|
||||
class = grub_pci_read (addr);
|
||||
|
||||
if (((class >> 16) & 0xffff) != GRUB_PCI_CLASS_SUBCLASS_VGA
|
||||
|| pciid != GRUB_SIS315PRO_PCIID)
|
||||
return 0;
|
||||
|
||||
found = 1;
|
||||
|
||||
addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0);
|
||||
framebuffer.base = grub_pci_read (addr);
|
||||
framebuffer.dev = dev;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Decode depth from mode_type. If it is zero, then autodetect. */
|
||||
depth = (mode_type & GRUB_VIDEO_MODE_TYPE_DEPTH_MASK)
|
||||
>> GRUB_VIDEO_MODE_TYPE_DEPTH_POS;
|
||||
|
||||
if ((width != 640 && width != 0) || (height != 400 && height != 0)
|
||||
|| (depth != 8 && depth != 0))
|
||||
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
|
||||
"Only 640x400x8 is supported");
|
||||
|
||||
grub_pci_iterate (find_card);
|
||||
if (!found)
|
||||
return grub_error (GRUB_ERR_IO, "Couldn't find graphics card");
|
||||
#endif
|
||||
/* Fill mode info details. */
|
||||
framebuffer.mode_info.width = 640;
|
||||
framebuffer.mode_info.height = 400;
|
||||
framebuffer.mode_info.mode_type = GRUB_VIDEO_MODE_TYPE_INDEX_COLOR;
|
||||
framebuffer.mode_info.bpp = 8;
|
||||
framebuffer.mode_info.bytes_per_pixel = 1;
|
||||
framebuffer.mode_info.pitch = 640 * 1;
|
||||
framebuffer.mode_info.number_of_colors = 256;
|
||||
framebuffer.mode_info.red_mask_size = 0;
|
||||
framebuffer.mode_info.red_field_pos = 0;
|
||||
framebuffer.mode_info.green_mask_size = 0;
|
||||
framebuffer.mode_info.green_field_pos = 0;
|
||||
framebuffer.mode_info.blue_mask_size = 0;
|
||||
framebuffer.mode_info.blue_field_pos = 0;
|
||||
framebuffer.mode_info.reserved_mask_size = 0;
|
||||
framebuffer.mode_info.reserved_field_pos = 0;
|
||||
#ifndef TEST
|
||||
framebuffer.mode_info.blit_format
|
||||
= grub_video_get_blit_format (&framebuffer.mode_info);
|
||||
#endif
|
||||
|
||||
/* We can safely discard volatile attribute. */
|
||||
#ifndef TEST
|
||||
framebuffer.ptr
|
||||
= (void *) grub_pci_device_map_range (framebuffer.dev,
|
||||
framebuffer.base,
|
||||
GRUB_SIS315PRO_TOTAL_MEMORY_SPACE);
|
||||
#endif
|
||||
framebuffer.mapped = 1;
|
||||
|
||||
#ifndef TEST
|
||||
/* Prevent garbage from appearing on the screen. */
|
||||
grub_memset (framebuffer.ptr, 0,
|
||||
framebuffer.mode_info.height * framebuffer.mode_info.pitch);
|
||||
#endif
|
||||
|
||||
#ifndef TEST
|
||||
err = grub_video_fb_create_render_target_from_pointer (&framebuffer
|
||||
.render_target,
|
||||
&framebuffer.mode_info,
|
||||
framebuffer.ptr);
|
||||
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
err = grub_video_fb_set_active_render_target (framebuffer.render_target);
|
||||
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
/* Copy default palette to initialize emulated palette. */
|
||||
err = grub_video_fb_set_palette (0, GRUB_VIDEO_FBSTD_NUMCOLORS,
|
||||
grub_video_fbstd_colors);
|
||||
#endif
|
||||
return err;
|
||||
}
|
||||
|
||||
#ifndef TEST
|
||||
|
||||
static grub_err_t
|
||||
grub_video_sis315pro_swap_buffers (void)
|
||||
{
|
||||
/* TODO: Implement buffer swapping. */
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_video_sis315pro_set_active_render_target (struct grub_video_render_target *target)
|
||||
{
|
||||
if (target == GRUB_VIDEO_RENDER_TARGET_DISPLAY)
|
||||
target = framebuffer.render_target;
|
||||
|
||||
return grub_video_fb_set_active_render_target (target);
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_video_sis315pro_get_info_and_fini (struct grub_video_mode_info *mode_info,
|
||||
void **framebuf)
|
||||
{
|
||||
grub_memcpy (mode_info, &(framebuffer.mode_info), sizeof (*mode_info));
|
||||
*framebuf = (char *) framebuffer.ptr;
|
||||
|
||||
grub_video_fb_fini ();
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
static struct grub_video_adapter grub_video_sis315pro_adapter =
|
||||
{
|
||||
.name = "SIS315PRO Video Driver",
|
||||
.id = GRUB_VIDEO_DRIVER_SIS315PRO,
|
||||
|
||||
.prio = GRUB_VIDEO_ADAPTER_PRIO_NATIVE,
|
||||
|
||||
.init = grub_video_sis315pro_video_init,
|
||||
.fini = grub_video_sis315pro_video_fini,
|
||||
.setup = grub_video_sis315pro_setup,
|
||||
.get_info = grub_video_fb_get_info,
|
||||
.get_info_and_fini = grub_video_sis315pro_get_info_and_fini,
|
||||
.set_palette = grub_video_fb_set_palette,
|
||||
.get_palette = grub_video_fb_get_palette,
|
||||
.set_viewport = grub_video_fb_set_viewport,
|
||||
.get_viewport = grub_video_fb_get_viewport,
|
||||
.map_color = grub_video_fb_map_color,
|
||||
.map_rgb = grub_video_fb_map_rgb,
|
||||
.map_rgba = grub_video_fb_map_rgba,
|
||||
.unmap_color = grub_video_fb_unmap_color,
|
||||
.fill_rect = grub_video_fb_fill_rect,
|
||||
.blit_bitmap = grub_video_fb_blit_bitmap,
|
||||
.blit_render_target = grub_video_fb_blit_render_target,
|
||||
.scroll = grub_video_fb_scroll,
|
||||
.swap_buffers = grub_video_sis315pro_swap_buffers,
|
||||
.create_render_target = grub_video_fb_create_render_target,
|
||||
.delete_render_target = grub_video_fb_delete_render_target,
|
||||
.set_active_render_target = grub_video_sis315pro_set_active_render_target,
|
||||
.get_active_render_target = grub_video_fb_get_active_render_target,
|
||||
|
||||
.next = 0
|
||||
};
|
||||
|
||||
GRUB_MOD_INIT(video_sis315pro)
|
||||
{
|
||||
grub_video_register (&grub_video_sis315pro_adapter);
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(video_sis315pro)
|
||||
{
|
||||
grub_video_unregister (&grub_video_sis315pro_adapter);
|
||||
}
|
||||
#else
|
||||
int
|
||||
main ()
|
||||
{
|
||||
grub_video_sis315pro_setup (640, 400, 0, 0);
|
||||
}
|
||||
#endif
|
|
@ -94,7 +94,8 @@ enum grub_ata_commands
|
|||
enum grub_ata_timeout_milliseconds
|
||||
{
|
||||
GRUB_ATA_TOUT_STD = 1000, /* 1s standard timeout. */
|
||||
GRUB_ATA_TOUT_DATA = 10000 /* 10s DATA I/O timeout. */
|
||||
GRUB_ATA_TOUT_DATA = 10000, /* 10s DATA I/O timeout. */
|
||||
GRUB_ATA_TOUT_DEV_INIT = 10000, /* Give the device 10s on first try to spinon. */
|
||||
};
|
||||
|
||||
struct grub_ata_device
|
||||
|
@ -128,6 +129,8 @@ struct grub_ata_device
|
|||
/* Set to 0 for ATA, set to 1 for ATAPI. */
|
||||
int atapi;
|
||||
|
||||
int present;
|
||||
|
||||
struct grub_ata_device *next;
|
||||
};
|
||||
|
||||
|
|
|
@ -37,4 +37,14 @@ grub_arch_sync_caches (void *address __attribute__ ((unused)),
|
|||
void EXPORT_FUNC(grub_arch_sync_caches) (void *address, grub_size_t len);
|
||||
#endif
|
||||
|
||||
#ifdef _mips
|
||||
void EXPORT_FUNC(grub_arch_sync_dma_caches) (void *address, grub_size_t len);
|
||||
#else
|
||||
static inline void
|
||||
grub_arch_sync_dma_caches (void *address __attribute__ ((unused)),
|
||||
grub_size_t len __attribute__ ((unused)))
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ! GRUB_CACHE_HEADER */
|
||||
|
|
|
@ -26,9 +26,11 @@
|
|||
#endif
|
||||
|
||||
#define GRUB_CS5536_PCIID 0x208f1022
|
||||
#define GRUB_CS5536_MSR_MAILBOX_ADDR 0xf4
|
||||
#define GRUB_CS5536_MSR_MAILBOX_DATA0 0xf8
|
||||
#define GRUB_CS5536_MSR_MAILBOX_DATA1 0xfc
|
||||
#define GRUB_CS5536_MSR_MAILBOX_CONFIG_ENABLED 0x1
|
||||
#define GRUB_CS5536_MSR_MAILBOX_CONFIG 0xf0
|
||||
#define GRUB_CS5536_MSR_MAILBOX_ADDR 0xf4
|
||||
#define GRUB_CS5536_MSR_MAILBOX_DATA0 0xf8
|
||||
#define GRUB_CS5536_MSR_MAILBOX_DATA1 0xfc
|
||||
#define GRUB_CS5536_MSR_IRQ_MAP_BAR 0x80000008
|
||||
#define GRUB_CS5536_MSR_SMB_BAR 0x8000000b
|
||||
|
||||
|
@ -73,11 +75,15 @@
|
|||
#define GRUB_CS5536_MSR_DIVIL_LEG_IO_RTC_ENABLE1 0x00000002
|
||||
#define GRUB_CS5536_MSR_DIVIL_LEG_IO_MODE_X86 0x10000000
|
||||
#define GRUB_CS5536_MSR_DIVIL_LEG_IO_F_REMAP 0x04000000
|
||||
#define GRUB_CS5536_MSR_DIVIL_LEG_IO_UART1_COM1 0x00070000
|
||||
#define GRUB_CS5536_MSR_DIVIL_LEG_IO_UART2_COM3 0x00500000
|
||||
#define GRUB_CS5536_MSR_DIVIL_IRQ_MAPPER_PRIMARY_MASK 0x80000024
|
||||
#define GRUB_CS5536_MSR_DIVIL_IRQ_MAPPER_LPC_MASK 0x80000025
|
||||
#define GRUB_CS5536_DIVIL_LPC_INTERRUPTS 0x1002
|
||||
#define GRUB_CS5536_MSR_DIVIL_LPC_SERIAL_IRQ_CONTROL 0x8000004e
|
||||
#define GRUB_CS5536_MSR_DIVIL_LPC_SERIAL_IRQ_CONTROL_ENABLE 0x80
|
||||
#define GRUB_CS5536_MSR_DIVIL_UART1_CONF 0x8000003a
|
||||
#define GRUB_CS5536_MSR_DIVIL_UART2_CONF 0x8000003e
|
||||
|
||||
#define GRUB_CS5536_MSR_USB_OHCI_BASE 0x40000008
|
||||
#define GRUB_CS5536_MSR_USB_EHCI_BASE 0x40000009
|
||||
|
|
|
@ -80,6 +80,6 @@
|
|||
#define GRUB_CPU_LOONGSON_PCI_HIT1_SEL_HI 0xbfe00154
|
||||
|
||||
#define GRUB_CPU_LOONGSON_GPIOCFG 0xbfe00120
|
||||
#define GRUB_CPU_LOONGSON_SHUTDOWN_GPIO 1
|
||||
#define GRUB_CPU_YEELOONG_SHUTDOWN_GPIO 1
|
||||
|
||||
#endif
|
||||
|
|
34
include/grub/mips/loongson/kernel.h
Normal file
34
include/grub/mips/loongson/kernel.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* 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>
|
||||
#include <grub/cpu/kernel.h>
|
||||
|
||||
#define GRUB_ARCH_MACHINE_YEELOONG 0
|
||||
#define GRUB_ARCH_MACHINE_FULOONG 1
|
||||
|
||||
#ifndef ASM_FILE
|
||||
|
||||
extern grub_uint32_t EXPORT_VAR (grub_arch_machine);
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* ! GRUB_KERNEL_MACHINE_HEADER */
|
|
@ -24,10 +24,10 @@
|
|||
#include <grub/cpu/io.h>
|
||||
#endif
|
||||
|
||||
#define GRUB_YEELOONG_OHCI_PCIID 0x00351033
|
||||
#define GRUB_YEELOONG_EHCI_PCIID 0x00e01033
|
||||
#define GRUB_YEELOONG_OHCI_GHOST_FUNCTION 4
|
||||
#define GRUB_YEELOONG_EHCI_GHOST_FUNCTION 5
|
||||
#define GRUB_LOONGSON_OHCI_PCIID 0x00351033
|
||||
#define GRUB_LOONGSON_EHCI_PCIID 0x00e01033
|
||||
#define GRUB_LOONGSON_OHCI_GHOST_FUNCTION 4
|
||||
#define GRUB_LOONGSON_EHCI_GHOST_FUNCTION 5
|
||||
|
||||
#define GRUB_PCI_NUM_BUS 1
|
||||
#define GRUB_PCI_NUM_DEVICES 16
|
|
@ -19,11 +19,14 @@
|
|||
#ifndef GRUB_MACHINE_SERIAL_HEADER
|
||||
#define GRUB_MACHINE_SERIAL_HEADER 1
|
||||
|
||||
#define GRUB_MACHINE_SERIAL_DIVISOR_115200 2
|
||||
#define GRUB_MACHINE_SERIAL_PORT 0xbff003f8
|
||||
#define GRUB_MACHINE_SERIAL_PORT0_DIVISOR_115200 2
|
||||
#define GRUB_MACHINE_SERIAL_PORT2_DIVISOR_115200 1
|
||||
#define GRUB_MACHINE_SERIAL_PORT0 0xbff003f8
|
||||
#define GRUB_MACHINE_SERIAL_PORT1 0xbfd003f8
|
||||
#define GRUB_MACHINE_SERIAL_PORT2 0xbfd002f8
|
||||
|
||||
#ifndef ASM_FILE
|
||||
#define GRUB_MACHINE_SERIAL_PORTS { GRUB_MACHINE_SERIAL_PORT }
|
||||
#define GRUB_MACHINE_SERIAL_PORTS { GRUB_MACHINE_SERIAL_PORT0, GRUB_MACHINE_SERIAL_PORT1, GRUB_MACHINE_SERIAL_PORT2 }
|
||||
#else
|
||||
#endif
|
||||
|
|
@ -1 +0,0 @@
|
|||
#include <grub/cpu/kernel.h>
|
|
@ -100,16 +100,16 @@
|
|||
#define GRUB_KERNEL_POWERPC_IEEE1275_LINK_ALIGN 4
|
||||
#define GRUB_KERNEL_POWERPC_IEEE1275_LINK_ADDR 0x200000
|
||||
|
||||
#define GRUB_KERNEL_MIPS_YEELOONG_LINK_ADDR 0x80200000
|
||||
#define GRUB_KERNEL_MIPS_LOONGSON_LINK_ADDR 0x80200000
|
||||
|
||||
#define GRUB_KERNEL_MIPS_YEELOONG_LINK_ALIGN 32
|
||||
#define GRUB_KERNEL_MIPS_LOONGSON_LINK_ALIGN 32
|
||||
|
||||
#define GRUB_KERNEL_MIPS_YEELOONG_COMPRESSED_SIZE 0x8
|
||||
#define GRUB_KERNEL_MIPS_YEELOONG_UNCOMPRESSED_SIZE 0xc
|
||||
#define GRUB_KERNEL_MIPS_LOONGSON_COMPRESSED_SIZE 0x8
|
||||
#define GRUB_KERNEL_MIPS_LOONGSON_UNCOMPRESSED_SIZE 0xc
|
||||
|
||||
#define GRUB_KERNEL_MIPS_YEELOONG_TOTAL_MODULE_SIZE 0x08
|
||||
#define GRUB_KERNEL_MIPS_YEELOONG_PREFIX 0x0c
|
||||
#define GRUB_KERNEL_MIPS_YEELOONG_PREFIX_END 0x54
|
||||
#define GRUB_KERNEL_MIPS_LOONGSON_TOTAL_MODULE_SIZE 0x08
|
||||
#define GRUB_KERNEL_MIPS_LOONGSON_PREFIX 0x0c
|
||||
#define GRUB_KERNEL_MIPS_LOONGSON_PREFIX_END 0x54
|
||||
|
||||
#define GRUB_KERNEL_MIPS_ARC_LINK_ADDR 0x8a000000
|
||||
|
||||
|
@ -155,7 +155,7 @@
|
|||
|
||||
#define GRUB_KERNEL_POWERPC_IEEE1275_MOD_ALIGN 0x1000
|
||||
|
||||
#define GRUB_KERNEL_MIPS_YEELOONG_MOD_ALIGN 0x1
|
||||
#define GRUB_KERNEL_MIPS_LOONGSON_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
|
||||
|
|
|
@ -102,7 +102,7 @@ grub_serial_config_defaults (struct grub_serial_port *port)
|
|||
{
|
||||
struct grub_serial_config config =
|
||||
{
|
||||
#ifdef GRUB_MACHINE_MIPS_YEELOONG
|
||||
#ifdef GRUB_MACHINE_MIPS_LOONGSON
|
||||
.speed = 115200,
|
||||
#else
|
||||
.speed = 9600,
|
||||
|
|
|
@ -248,6 +248,14 @@ grub_term_register_input (const char *name __attribute__ ((unused)),
|
|||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
grub_term_register_input_inactive (const char *name __attribute__ ((unused)),
|
||||
grub_term_input_t term)
|
||||
{
|
||||
grub_list_push (GRUB_AS_LIST_P (&grub_term_inputs_disabled),
|
||||
GRUB_AS_LIST (term));
|
||||
}
|
||||
|
||||
static inline void
|
||||
grub_term_register_input_active (const char *name __attribute__ ((unused)),
|
||||
grub_term_input_t term)
|
||||
|
@ -272,6 +280,14 @@ grub_term_register_output (const char *name __attribute__ ((unused)),
|
|||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
grub_term_register_output_inactive (const char *name __attribute__ ((unused)),
|
||||
grub_term_output_t term)
|
||||
{
|
||||
grub_list_push (GRUB_AS_LIST_P (&grub_term_outputs_disabled),
|
||||
GRUB_AS_LIST (term));
|
||||
}
|
||||
|
||||
static inline void
|
||||
grub_term_register_output_active (const char *name __attribute__ ((unused)),
|
||||
grub_term_output_t term)
|
||||
|
|
|
@ -211,7 +211,8 @@ typedef enum grub_video_driver_id
|
|||
GRUB_VIDEO_DRIVER_VGA,
|
||||
GRUB_VIDEO_DRIVER_CIRRUS,
|
||||
GRUB_VIDEO_DRIVER_BOCHS,
|
||||
GRUB_VIDEO_DRIVER_SDL
|
||||
GRUB_VIDEO_DRIVER_SDL,
|
||||
GRUB_VIDEO_DRIVER_SIS315PRO,
|
||||
} grub_video_driver_id_t;
|
||||
|
||||
typedef enum grub_video_adapter_prio
|
||||
|
|
|
@ -554,13 +554,13 @@ fi
|
|||
|
||||
case "${target_cpu}-${platform}" in
|
||||
sparc64-ieee1275) mkimage_target=sparc64-ieee1275-raw ;;
|
||||
mips-yeeloong) mkimage_target=mipsel-yeeloong-elf ;;
|
||||
mips-loongson) mkimage_target=mipsel-loongson-elf ;;
|
||||
*) mkimage_target="${target_cpu}-${platform}" ;;
|
||||
esac
|
||||
|
||||
case "${target_cpu}-${platform}" in
|
||||
i386-efi | x86_64-efi) imgext=efi ;;
|
||||
mips-yeeloong | i386-coreboot | i386-multiboot | i386-ieee1275 \
|
||||
mips-loongson | i386-coreboot | i386-multiboot | i386-ieee1275 \
|
||||
| powerpc-ieee1275) imgext=elf ;;
|
||||
*) imgext=img ;;
|
||||
esac
|
||||
|
@ -569,7 +569,7 @@ esac
|
|||
"$grub_mkimage" ${config_opt} -d "${pkglibdir}" -O ${mkimage_target} --output="${grubdir}/core.${imgext}" --prefix="${prefix_drive}${relative_grubdir}" $modules || exit 1
|
||||
|
||||
# Backward-compatibility kludges
|
||||
if [ "${target_cpu}-${platform}" = "mips-yeeloong" ]; then
|
||||
if [ "${target_cpu}-${platform}" = "mips-loongson" ]; then
|
||||
cp "${grubdir}/core.${imgext}" "${bootdir}"/grub.elf
|
||||
elif [ "${target_cpu}-${platform}" = "i386-ieee1275" ] || [ "${target_cpu}-${platform}" = "powerpc-ieee1275" ]; then
|
||||
cp "${grubdir}/core.${imgext}" "${grubdir}/grub"
|
||||
|
|
|
@ -58,14 +58,15 @@ typedef enum {
|
|||
|
||||
struct image_target_desc
|
||||
{
|
||||
const char *name;
|
||||
const char *dirname;
|
||||
const char *names[6];
|
||||
grub_size_t voidp_sizeof;
|
||||
int bigendian;
|
||||
enum {
|
||||
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_MIPS_ARC
|
||||
IMAGE_LOONGSON_ELF, IMAGE_QEMU, IMAGE_PPC, IMAGE_YEELOONG_FLASH,
|
||||
IMAGE_FULOONG_FLASH, IMAGE_I386_PC_PXE, IMAGE_MIPS_ARC
|
||||
} id;
|
||||
enum
|
||||
{
|
||||
|
@ -92,7 +93,8 @@ struct image_target_desc
|
|||
struct image_target_desc image_targets[] =
|
||||
{
|
||||
{
|
||||
.name = "i386-coreboot",
|
||||
.dirname = "i386-coreboot",
|
||||
.names = { "i386-coreboot", NULL },
|
||||
.voidp_sizeof = 4,
|
||||
.bigendian = 0,
|
||||
.id = IMAGE_COREBOOT,
|
||||
|
@ -114,7 +116,8 @@ struct image_target_desc image_targets[] =
|
|||
.mod_align = GRUB_KERNEL_I386_COREBOOT_MOD_ALIGN
|
||||
},
|
||||
{
|
||||
.name = "i386-multiboot",
|
||||
.dirname = "i386-multiboot",
|
||||
.names = { "i386-multiboot", NULL},
|
||||
.voidp_sizeof = 4,
|
||||
.bigendian = 0,
|
||||
.id = IMAGE_COREBOOT,
|
||||
|
@ -136,7 +139,8 @@ struct image_target_desc image_targets[] =
|
|||
.mod_align = GRUB_KERNEL_I386_COREBOOT_MOD_ALIGN
|
||||
},
|
||||
{
|
||||
.name = "i386-pc",
|
||||
.dirname = "i386-pc",
|
||||
.names = { "i386-pc", NULL },
|
||||
.voidp_sizeof = 4,
|
||||
.bigendian = 0,
|
||||
.id = IMAGE_I386_PC,
|
||||
|
@ -154,7 +158,8 @@ struct image_target_desc image_targets[] =
|
|||
.link_addr = GRUB_KERNEL_I386_PC_LINK_ADDR
|
||||
},
|
||||
{
|
||||
.name = "i386-pc-pxe",
|
||||
.dirname = "i386-pc",
|
||||
.names = { "i386-pc-pxe", NULL },
|
||||
.voidp_sizeof = 4,
|
||||
.bigendian = 0,
|
||||
.id = IMAGE_I386_PC_PXE,
|
||||
|
@ -172,7 +177,8 @@ struct image_target_desc image_targets[] =
|
|||
.link_addr = GRUB_KERNEL_I386_PC_LINK_ADDR
|
||||
},
|
||||
{
|
||||
.name = "i386-efi",
|
||||
.dirname = "i386-efi",
|
||||
.names = { "i386-efi", NULL },
|
||||
.voidp_sizeof = 4,
|
||||
.bigendian = 0,
|
||||
.id = IMAGE_EFI,
|
||||
|
@ -194,7 +200,8 @@ struct image_target_desc image_targets[] =
|
|||
.install_bsd_part = TARGET_NO_FIELD,
|
||||
},
|
||||
{
|
||||
.name = "i386-ieee1275",
|
||||
.dirname = "i386-ieee1275",
|
||||
.names = { "i386-ieee1275", NULL },
|
||||
.voidp_sizeof = 4,
|
||||
.bigendian = 0,
|
||||
.id = IMAGE_I386_IEEE1275,
|
||||
|
@ -216,7 +223,8 @@ struct image_target_desc image_targets[] =
|
|||
.link_align = 4,
|
||||
},
|
||||
{
|
||||
.name = "i386-qemu",
|
||||
.dirname = "i386-qemu",
|
||||
.names = { "i386-qemu", NULL },
|
||||
.voidp_sizeof = 4,
|
||||
.bigendian = 0,
|
||||
.id = IMAGE_QEMU,
|
||||
|
@ -234,7 +242,8 @@ struct image_target_desc image_targets[] =
|
|||
.link_addr = GRUB_KERNEL_I386_QEMU_LINK_ADDR
|
||||
},
|
||||
{
|
||||
.name = "x86_64-efi",
|
||||
.dirname = "x86_64-efi",
|
||||
.names = { "x86_64-efi", NULL },
|
||||
.voidp_sizeof = 8,
|
||||
.bigendian = 0,
|
||||
.id = IMAGE_EFI,
|
||||
|
@ -256,49 +265,75 @@ struct image_target_desc image_targets[] =
|
|||
.install_bsd_part = TARGET_NO_FIELD,
|
||||
},
|
||||
{
|
||||
.name = "mipsel-yeeloong-flash",
|
||||
.dirname = "mips-loongson",
|
||||
.names = { "mipsel-yeeloong-flash", NULL },
|
||||
.voidp_sizeof = 4,
|
||||
.bigendian = 0,
|
||||
.id = IMAGE_YEELOONG_FLASH,
|
||||
.flags = PLATFORM_FLAGS_DECOMPRESSORS,
|
||||
.prefix = GRUB_KERNEL_MIPS_YEELOONG_PREFIX,
|
||||
.prefix_end = GRUB_KERNEL_MIPS_YEELOONG_PREFIX_END,
|
||||
.prefix = GRUB_KERNEL_MIPS_LOONGSON_PREFIX,
|
||||
.prefix_end = GRUB_KERNEL_MIPS_LOONGSON_PREFIX_END,
|
||||
.raw_size = 0,
|
||||
.total_module_size = GRUB_KERNEL_MIPS_YEELOONG_TOTAL_MODULE_SIZE,
|
||||
.total_module_size = GRUB_KERNEL_MIPS_LOONGSON_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_YEELOONG_LINK_ADDR,
|
||||
.link_addr = GRUB_KERNEL_MIPS_LOONGSON_LINK_ADDR,
|
||||
.elf_target = EM_MIPS,
|
||||
.link_align = GRUB_KERNEL_MIPS_YEELOONG_LINK_ALIGN,
|
||||
.link_align = GRUB_KERNEL_MIPS_LOONGSON_LINK_ALIGN,
|
||||
.default_compression = COMPRESSION_NONE
|
||||
},
|
||||
{
|
||||
.name = "mipsel-yeeloong-elf",
|
||||
.dirname = "mips-loongson",
|
||||
.names = { "mipsel-fuloong-flash", NULL },
|
||||
.voidp_sizeof = 4,
|
||||
.bigendian = 0,
|
||||
.id = IMAGE_YEELOONG_ELF,
|
||||
.id = IMAGE_FULOONG_FLASH,
|
||||
.flags = PLATFORM_FLAGS_DECOMPRESSORS,
|
||||
.prefix = GRUB_KERNEL_MIPS_YEELOONG_PREFIX,
|
||||
.prefix_end = GRUB_KERNEL_MIPS_YEELOONG_PREFIX_END,
|
||||
.prefix = GRUB_KERNEL_MIPS_LOONGSON_PREFIX,
|
||||
.prefix_end = GRUB_KERNEL_MIPS_LOONGSON_PREFIX_END,
|
||||
.raw_size = 0,
|
||||
.total_module_size = GRUB_KERNEL_MIPS_YEELOONG_TOTAL_MODULE_SIZE,
|
||||
.total_module_size = GRUB_KERNEL_MIPS_LOONGSON_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_YEELOONG_LINK_ADDR,
|
||||
.link_addr = GRUB_KERNEL_MIPS_LOONGSON_LINK_ADDR,
|
||||
.elf_target = EM_MIPS,
|
||||
.link_align = GRUB_KERNEL_MIPS_YEELOONG_LINK_ALIGN,
|
||||
.link_align = GRUB_KERNEL_MIPS_LOONGSON_LINK_ALIGN,
|
||||
.default_compression = COMPRESSION_NONE
|
||||
},
|
||||
{
|
||||
.name = "powerpc-ieee1275",
|
||||
.dirname = "mips-loongson",
|
||||
.names = { "mipsel-loongson-elf", "mipsel-yeeloong-elf",
|
||||
"mipsel-fuloong-elf", NULL },
|
||||
.voidp_sizeof = 4,
|
||||
.bigendian = 0,
|
||||
.id = IMAGE_LOONGSON_ELF,
|
||||
.flags = PLATFORM_FLAGS_DECOMPRESSORS,
|
||||
.prefix = GRUB_KERNEL_MIPS_LOONGSON_PREFIX,
|
||||
.prefix_end = GRUB_KERNEL_MIPS_LOONGSON_PREFIX_END,
|
||||
.raw_size = 0,
|
||||
.total_module_size = GRUB_KERNEL_MIPS_LOONGSON_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_LOONGSON_LINK_ADDR,
|
||||
.elf_target = EM_MIPS,
|
||||
.link_align = GRUB_KERNEL_MIPS_LOONGSON_LINK_ALIGN,
|
||||
.default_compression = COMPRESSION_NONE
|
||||
},
|
||||
{
|
||||
.dirname = "powerpc-ieee1275",
|
||||
.names = { "powerpc-ieee1275", NULL },
|
||||
.voidp_sizeof = 4,
|
||||
.bigendian = 1,
|
||||
.id = IMAGE_PPC,
|
||||
|
@ -320,7 +355,8 @@ struct image_target_desc image_targets[] =
|
|||
.link_align = 4
|
||||
},
|
||||
{
|
||||
.name = "sparc64-ieee1275-raw",
|
||||
.dirname = "sparc64-ieee1275",
|
||||
.names = { "sparc64-ieee1275-raw", NULL },
|
||||
.voidp_sizeof = 8,
|
||||
.bigendian = 1,
|
||||
.id = IMAGE_SPARC64_RAW,
|
||||
|
@ -338,7 +374,8 @@ struct image_target_desc image_targets[] =
|
|||
.link_addr = GRUB_KERNEL_SPARC64_IEEE1275_LINK_ADDR
|
||||
},
|
||||
{
|
||||
.name = "sparc64-ieee1275-aout",
|
||||
.dirname = "sparc64-ieee1275",
|
||||
.names = { "sparc64-ieee1275-aout", NULL },
|
||||
.voidp_sizeof = 8,
|
||||
.bigendian = 1,
|
||||
.id = IMAGE_SPARC64_AOUT,
|
||||
|
@ -356,7 +393,8 @@ struct image_target_desc image_targets[] =
|
|||
.link_addr = GRUB_KERNEL_SPARC64_IEEE1275_LINK_ADDR
|
||||
},
|
||||
{
|
||||
.name = "mips-arc",
|
||||
.dirname = "mips-arc",
|
||||
.names = {"mips-arc", NULL},
|
||||
.voidp_sizeof = 4,
|
||||
.bigendian = 1,
|
||||
.id = IMAGE_MIPS_ARC,
|
||||
|
@ -821,10 +859,10 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
|||
decompress_size = grub_util_get_image_size (decompress_path);
|
||||
decompress_img = grub_util_read_image (decompress_path);
|
||||
|
||||
*((grub_uint32_t *) (decompress_img + GRUB_KERNEL_MIPS_YEELOONG_COMPRESSED_SIZE))
|
||||
*((grub_uint32_t *) (decompress_img + GRUB_KERNEL_MIPS_LOONGSON_COMPRESSED_SIZE))
|
||||
= grub_host_to_target32 (core_size);
|
||||
|
||||
*((grub_uint32_t *) (decompress_img + GRUB_KERNEL_MIPS_YEELOONG_UNCOMPRESSED_SIZE))
|
||||
*((grub_uint32_t *) (decompress_img + GRUB_KERNEL_MIPS_LOONGSON_UNCOMPRESSED_SIZE))
|
||||
= grub_host_to_target32 (kernel_size + total_module_size);
|
||||
|
||||
full_size = core_size + decompress_size;
|
||||
|
@ -1184,29 +1222,48 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
|||
}
|
||||
break;
|
||||
case IMAGE_YEELOONG_FLASH:
|
||||
case IMAGE_FULOONG_FLASH:
|
||||
{
|
||||
char *rom_img;
|
||||
size_t rom_size;
|
||||
char *boot_path, *boot_img;
|
||||
size_t boot_size;
|
||||
grub_uint8_t context[GRUB_MD_SHA512->contextsize];
|
||||
/* fwstart.img is the only part which can't be testes by using *-elf
|
||||
target. Check it against the checksum. This checksum is obtained with
|
||||
sha512sum utility after compiling on Gnewsense.
|
||||
*/
|
||||
const grub_uint8_t fwstart_good_hash[] =
|
||||
{
|
||||
0x9f, 0x7f, 0x79, 0x47, 0x68, 0x91, 0x61, 0xb3,
|
||||
0x16, 0x7b, 0xf0, 0x27, 0x1c, 0xf7, 0xaf, 0x05,
|
||||
0x6c, 0xc1, 0x6f, 0xd2, 0xe7, 0xd1, 0xe9, 0xec,
|
||||
0x08, 0x87, 0xe5, 0xc8, 0x29, 0xa2, 0x5b, 0x84,
|
||||
0xf8, 0xa6, 0xec, 0x08, 0xf7, 0xcb, 0x7b, 0x6c,
|
||||
0xfe, 0x01, 0xfd, 0x5d, 0xba, 0xbf, 0x0d, 0x0f,
|
||||
0x2e, 0xef, 0xed, 0x7b, 0xfe, 0xc9, 0x4a, 0x85,
|
||||
0xcf, 0xac, 0x20, 0xd7, 0x01, 0xc5, 0xc5, 0x9c
|
||||
/* fwstart.img is the only part which can't be tested by using *-elf
|
||||
target. Check it against the checksum. */
|
||||
const grub_uint8_t yeeloong_fwstart_good_hash[512 / 8] =
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
/* None yet. */
|
||||
const grub_uint8_t fuloong_fwstart_good_hash[512 / 8] =
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
const grub_uint8_t *fwstart_good_hash;
|
||||
|
||||
if (image_target->id == IMAGE_FULOONG_FLASH)
|
||||
{
|
||||
fwstart_good_hash = fuloong_fwstart_good_hash;
|
||||
boot_path = grub_util_get_path (dir, "fwstart_fuloong.img");
|
||||
}
|
||||
else
|
||||
{
|
||||
fwstart_good_hash = yeeloong_fwstart_good_hash;
|
||||
boot_path = grub_util_get_path (dir, "fwstart.img");
|
||||
}
|
||||
|
||||
boot_path = grub_util_get_path (dir, "fwstart.img");
|
||||
boot_size = grub_util_get_image_size (boot_path);
|
||||
boot_img = grub_util_read_image (boot_path);
|
||||
|
||||
|
@ -1308,7 +1365,7 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
|||
core_size = program_size + sizeof (*head) + sizeof (*section);
|
||||
}
|
||||
break;
|
||||
case IMAGE_YEELOONG_ELF:
|
||||
case IMAGE_LOONGSON_ELF:
|
||||
case IMAGE_PPC:
|
||||
case IMAGE_COREBOOT:
|
||||
case IMAGE_I386_IEEE1275:
|
||||
|
@ -1321,7 +1378,7 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
|||
int header_size, footer_size = 0;
|
||||
int phnum = 1;
|
||||
|
||||
if (image_target->id != IMAGE_YEELOONG_ELF)
|
||||
if (image_target->id != IMAGE_LOONGSON_ELF)
|
||||
phnum += 2;
|
||||
|
||||
if (note)
|
||||
|
@ -1356,7 +1413,7 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
|||
|
||||
/* No section headers. */
|
||||
ehdr->e_shoff = grub_host_to_target32 (0);
|
||||
if (image_target->id == IMAGE_YEELOONG_ELF)
|
||||
if (image_target->id == IMAGE_LOONGSON_ELF)
|
||||
ehdr->e_shentsize = grub_host_to_target16 (0);
|
||||
else
|
||||
ehdr->e_shentsize = grub_host_to_target16 (sizeof (Elf32_Shdr));
|
||||
|
@ -1369,7 +1426,7 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
|||
phdr->p_offset = grub_host_to_target32 (header_size);
|
||||
phdr->p_flags = grub_host_to_target32 (PF_R | PF_W | PF_X);
|
||||
|
||||
if (image_target->id == IMAGE_YEELOONG_ELF)
|
||||
if (image_target->id == IMAGE_LOONGSON_ELF)
|
||||
target_addr = ALIGN_UP (image_target->link_addr
|
||||
+ kernel_size + total_module_size, 32);
|
||||
else
|
||||
|
@ -1378,12 +1435,12 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
|||
phdr->p_vaddr = grub_host_to_target32 (target_addr);
|
||||
phdr->p_paddr = grub_host_to_target32 (target_addr);
|
||||
phdr->p_align = grub_host_to_target32 (align > image_target->link_align ? align : image_target->link_align);
|
||||
if (image_target->id == IMAGE_YEELOONG_ELF)
|
||||
if (image_target->id == IMAGE_LOONGSON_ELF)
|
||||
ehdr->e_flags = grub_host_to_target32 (0x1000 | EF_MIPS_NOREORDER
|
||||
| EF_MIPS_PIC | EF_MIPS_CPIC);
|
||||
else
|
||||
ehdr->e_flags = 0;
|
||||
if (image_target->id == IMAGE_YEELOONG_ELF)
|
||||
if (image_target->id == IMAGE_LOONGSON_ELF)
|
||||
{
|
||||
phdr->p_filesz = grub_host_to_target32 (core_size);
|
||||
phdr->p_memsz = grub_host_to_target32 (core_size);
|
||||
|
@ -1498,12 +1555,12 @@ usage (int status)
|
|||
char *ptr;
|
||||
unsigned i;
|
||||
for (i = 0; i < ARRAY_SIZE (image_targets); i++)
|
||||
format_len += strlen (image_targets[i].name) + 2;
|
||||
format_len += strlen (image_targets[i].names[0]) + 2;
|
||||
ptr = formats = xmalloc (format_len);
|
||||
for (i = 0; i < ARRAY_SIZE (image_targets); i++)
|
||||
{
|
||||
strcpy (ptr, image_targets[i].name);
|
||||
ptr += strlen (image_targets[i].name);
|
||||
strcpy (ptr, image_targets[i].names[0]);
|
||||
ptr += strlen (image_targets[i].names[0]);
|
||||
*ptr++ = ',';
|
||||
*ptr++ = ' ';
|
||||
}
|
||||
|
@ -1573,10 +1630,12 @@ main (int argc, char *argv[])
|
|||
|
||||
case 'O':
|
||||
{
|
||||
unsigned i;
|
||||
unsigned i, j;
|
||||
for (i = 0; i < ARRAY_SIZE (image_targets); i++)
|
||||
if (strcmp (optarg, image_targets[i].name) == 0)
|
||||
image_target = &image_targets[i];
|
||||
for (j = 0; image_targets[i].names[j]
|
||||
&& j < ARRAY_SIZE (image_targets[i].names); j++)
|
||||
if (strcmp (optarg, image_targets[i].names[j]) == 0)
|
||||
image_target = &image_targets[i];
|
||||
if (!image_target)
|
||||
{
|
||||
printf ("unknown target format %s\n", optarg);
|
||||
|
@ -1671,29 +1730,11 @@ main (int argc, char *argv[])
|
|||
|
||||
if (!dir)
|
||||
{
|
||||
const char *last;
|
||||
last = strchr (image_target->name, '-');
|
||||
if (last)
|
||||
last = strchr (last + 1, '-');
|
||||
if (!last)
|
||||
last = image_target->name + strlen (image_target->name);
|
||||
dir = xmalloc (sizeof (GRUB_PKGLIBROOTDIR) + (last - image_target->name)
|
||||
+ 1);
|
||||
dir = xmalloc (sizeof (GRUB_PKGLIBROOTDIR)
|
||||
+ grub_strlen (image_target->dirname) + 1);
|
||||
memcpy (dir, GRUB_PKGLIBROOTDIR, sizeof (GRUB_PKGLIBROOTDIR) - 1);
|
||||
*(dir + sizeof (GRUB_PKGLIBROOTDIR) - 1) = '/';
|
||||
if (strncmp (image_target->name, "mipsel-yeeloong",
|
||||
last - image_target->name) == 0)
|
||||
{
|
||||
memcpy (dir + sizeof (GRUB_PKGLIBROOTDIR), "mips-yeeloong",
|
||||
sizeof ("mips-yeeloong"));
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy (dir + sizeof (GRUB_PKGLIBROOTDIR), image_target->name,
|
||||
last - image_target->name);
|
||||
*(dir + sizeof (GRUB_PKGLIBROOTDIR) + (last - image_target->name))
|
||||
= 0;
|
||||
}
|
||||
strcpy (dir + sizeof (GRUB_PKGLIBROOTDIR), image_target->dirname);
|
||||
}
|
||||
|
||||
generate_image (dir, prefix ? : DEFAULT_DIRECTORY, fp,
|
||||
|
|
|
@ -79,11 +79,12 @@ Report bugs to <%s>.\n", program_name, PACKAGE_BUGREPORT);
|
|||
#define BSS_SECTION 4
|
||||
#define MODNAME_SECTION 5
|
||||
#define MODDEPS_SECTION 6
|
||||
#define SYMTAB_SECTION 7
|
||||
#define STRTAB_SECTION 8
|
||||
#define MODLICENSE_SECTION 7
|
||||
#define SYMTAB_SECTION 8
|
||||
#define STRTAB_SECTION 9
|
||||
|
||||
#define REL_SECTION 9
|
||||
#define MAX_SECTIONS 12
|
||||
#define REL_SECTION 10
|
||||
#define MAX_SECTIONS 16
|
||||
|
||||
#define STRTAB_BLOCK 256
|
||||
|
||||
|
@ -96,7 +97,7 @@ int num_sections;
|
|||
grub_uint32_t offset;
|
||||
|
||||
static int
|
||||
insert_string (char *name)
|
||||
insert_string (const char *name)
|
||||
{
|
||||
int len, result;
|
||||
|
||||
|
@ -124,6 +125,8 @@ write_section_data (FILE* fp, char *image,
|
|||
{
|
||||
int *section_map;
|
||||
int i;
|
||||
char *pe_strtab = (image + pe_chdr->symtab_offset
|
||||
+ pe_chdr->num_symbols * sizeof (struct grub_pe32_symbol));
|
||||
|
||||
section_map = xmalloc ((pe_chdr->num_sections + 1) * sizeof (int));
|
||||
section_map[0] = 0;
|
||||
|
@ -131,31 +134,42 @@ write_section_data (FILE* fp, char *image,
|
|||
for (i = 0; i < pe_chdr->num_sections; i++, pe_shdr++)
|
||||
{
|
||||
grub_uint32_t idx;
|
||||
const char *name = pe_shdr->name;
|
||||
|
||||
if (! strcmp (pe_shdr->name, ".text"))
|
||||
if (name[0] == '/' && isdigit (name[1]))
|
||||
{
|
||||
char t[sizeof (pe_shdr->name) + 1];
|
||||
memcpy (t, name, sizeof (pe_shdr->name));
|
||||
t[sizeof (pe_shdr->name)] = 0;
|
||||
name = pe_strtab + atoi (t + 1);
|
||||
}
|
||||
|
||||
if (! strcmp (name, ".text"))
|
||||
{
|
||||
idx = TEXT_SECTION;
|
||||
shdr[idx].sh_flags = SHF_ALLOC | SHF_EXECINSTR;
|
||||
}
|
||||
else if (! strcmp (pe_shdr->name, ".rdata"))
|
||||
else if (! strcmp (name, ".rdata"))
|
||||
{
|
||||
idx = RDATA_SECTION;
|
||||
shdr[idx].sh_flags = SHF_ALLOC;
|
||||
}
|
||||
else if (! strcmp (pe_shdr->name, ".data"))
|
||||
else if (! strcmp (name, ".data"))
|
||||
{
|
||||
idx = DATA_SECTION;
|
||||
shdr[idx].sh_flags = SHF_ALLOC | SHF_WRITE;
|
||||
}
|
||||
else if (! strcmp (pe_shdr->name, ".bss"))
|
||||
else if (! strcmp (name, ".bss"))
|
||||
{
|
||||
idx = BSS_SECTION;
|
||||
shdr[idx].sh_flags = SHF_ALLOC | SHF_WRITE;
|
||||
}
|
||||
else if (! strcmp (pe_shdr->name, ".modname"))
|
||||
else if (! strcmp (name, ".modname"))
|
||||
idx = MODNAME_SECTION;
|
||||
else if (! strcmp (pe_shdr->name, ".moddeps"))
|
||||
else if (! strcmp (name, ".moddeps"))
|
||||
idx = MODDEPS_SECTION;
|
||||
else if (strcmp (name, ".module_license") == 0)
|
||||
idx = MODLICENSE_SECTION;
|
||||
else
|
||||
{
|
||||
section_map[i + 1] = -1;
|
||||
|
@ -181,14 +195,14 @@ write_section_data (FILE* fp, char *image,
|
|||
|
||||
if (pe_shdr->relocations_offset)
|
||||
{
|
||||
char name[5 + strlen (pe_shdr->name)];
|
||||
char relname[5 + strlen (name)];
|
||||
|
||||
if (num_sections >= MAX_SECTIONS)
|
||||
grub_util_error ("too many sections");
|
||||
|
||||
sprintf (name, ".rel%s", pe_shdr->name);
|
||||
sprintf (relname, ".rel%s", name);
|
||||
|
||||
shdr[num_sections].sh_name = insert_string (name);
|
||||
shdr[num_sections].sh_name = insert_string (relname);
|
||||
shdr[num_sections].sh_link = i;
|
||||
shdr[num_sections].sh_info = idx;
|
||||
|
||||
|
@ -197,7 +211,7 @@ write_section_data (FILE* fp, char *image,
|
|||
num_sections++;
|
||||
}
|
||||
else
|
||||
shdr[idx].sh_name = insert_string (pe_shdr->name);
|
||||
shdr[idx].sh_name = insert_string (name);
|
||||
}
|
||||
|
||||
return section_map;
|
||||
|
|
|
@ -98,6 +98,10 @@ EOF
|
|||
EOF
|
||||
fi
|
||||
|
||||
cat << EOF
|
||||
insmod gzio
|
||||
EOF
|
||||
|
||||
if [ x$dirname = x/ ]; then
|
||||
if [ -z "${prepare_root_cache}" ]; then
|
||||
prepare_root_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE} | sed -e "s/^/\t/")"
|
||||
|
|
Loading…
Reference in a new issue