Received: from mailman by lists.gnu.org with archive (Exim 4.33) id 1Cg8cw-00040u-4J for mharc-grub-devel@gnu.org; Sun, 19 Dec 2004 16:30:06 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1Cg8ct-00040E-HF for grub-devel@gnu.org; Sun, 19 Dec 2004 16:30:03 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1Cg8cr-0003zV-Ic for grub-devel@gnu.org; Sun, 19 Dec 2004 16:30:02 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1Cg8cq-0003z6-V1 for grub-devel@gnu.org; Sun, 19 Dec 2004 16:30:01 -0500 Received: from [145.74.66.11] (helo=mail-cn.han.nl) by monty-python.gnu.org with esmtp (Exim 4.34) id 1Cg8Rx-0005Vg-7R for grub-devel@gnu.org; Sun, 19 Dec 2004 16:18:45 -0500 Received: from vscan-ca.han.nl (mars.han.nl [145.74.129.116]) by mail-cn.han.nl (Postfix) with ESMTP id BE3E899BA for ; Sun, 19 Dec 2004 22:18:14 +0100 (CET) Received: from mail-cn.han.nl ([145.74.66.51]) by vscan-ca.han.nl (mars.han.nl [145.74.129.116]) (amavisd-new, port 10024) with LMTP id 22661-01-63 for ; Sun, 19 Dec 2004 22:18:10 +0100 (CET) Received: from mail1.han.nl (mail1.han.nl [145.74.103.11]) by mail-cn.han.nl (Postfix) with ESMTP id ACD0F9138 for ; Sun, 19 Dec 2004 22:18:10 +0100 (CET) Received: from marco.marco-g.com (mgerards.xs4all.nl [82.92.27.129]) by mail1.han.nl (Postfix) with ESMTP id 980D6C04C for ; Sun, 19 Dec 2004 22:18:09 +0100 (CET) Mail-Copies-To: metgerards@student.han.nl To: grub-devel@gnu.org From: Marco Gerards Date: Sun, 19 Dec 2004 21:17:19 +0000 Message-ID: <87r7lm0yzk.fsf@marco.marco-g.com> User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new (2.2.0) at vscan-ca.han.nl Subject: Module support for the PPC X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Dec 2004 21:30:03 -0000 Hi, Here is a patch to add module loading support to the PPC. There is still a small problem with the alignment, but perhaps Timothy's patch will fix that, I have not tried that yet. After this patch is committed grubof will be really minimal and will be able to load modules. With the upcoming patch from Hollis it will be possible to add a note section and extra modules to it. Although this patch is not fully tested yet and there are still problems, I still want to commit it ASAP because this makes it easier for us all to debug and develop GRUB 2 for the PPC. There might be some problems that I caused for the PC port because I moved around some code, but that will all be solved before I commit the patch. I just want to send this patch in this evening so it can be reviewed. One thing that will seem a bit funny is grub/include/powerpc/libgcc.h. This file contains all symbols from libgcc (that is where they come from, right) that are included in grubof. Or would it be better to remove this and link every module to libgcc? Please let me know what you think about it. Thanks, Marco 2004-12-19 Marco Gerards * genmk.rb: Handle the `Program' class in the main loop. Written by Johan Rydberg . (Program): New class. * boot/powerpc/ieee1275/cmain.c: Include instead of "grub/machine/ieee1275.h". Include instead of "grub/kernel.h". Include . (help_arch): Function removed. * conf/powerpc-ieee1275.rmk (grubof_HEADERS): Add `powerpc/libgcc.h' and `loader.h'. (pkgdata_PROGRAMS): New variable. (sbin_UTILITIES): Variable removed. (grub_emu_SOURCES): Added kern/powerpc/cache.S. (grubof_SOURCES): Variable re-defined so it only includes the core functionality. (grubof_CFLAGS): Remove `-DGRUBOF'. (pkgdata_MODULES, fshelp_mod_SOURCES, fshelp_mod_CFLAGS, (fat_mod_SOURCES, fat_mod_CFLAGS, ext2_mod_SOURCES) (ext2_mod_CFLAGS, ufs_mod_SOURCES, ufs_mod_CFLAGS) (minix_mod_SOURCES, minix_mod_CFLAGS, hfs_mod_SOURCES) (hfs_mod_CFLAGS, jfs_mod_SOURCES, jfs_mod_CFLAGS) (iso9660_mod_SOURCES, iso9660_mod_CFLAGS, _linux_mod_SOURCES) (_linux_mod_CFLAGS, linux_mod_SOURCES, linux_mod_CFLAGS) (normal_mod_SOURCES, normal_mod_CFLAGS, normal_mod_ASFLAGS) (hello_mod_SOURCES, hello_mod_CFLAGS, boot_mod_SOURCES) (boot_mod_CFLAGS, terminal_mod_SOURCES, terminal_mod_CFLAGS) (ls_mod_SOURCES, ls_mod_CFLAGS, cmp_mod_SOURCES, cmp_mod_CFLAGS) (cat_mod_SOURCES, cat_mod_CFLAGS, font_mod_SOURCES) (font_mod_CFLAGS, amiga_mod_SOURCES, amiga_mod_CFLAGS) (apple_mod_SOURCES, apple_mod_CFLAGS, pc_mod_SOURCES) (pc_mod_CFLAGS): New variables. * disk/powerpc/ieee1275/ofdisk.c: Include . (grub_ofdisk_iterate): Add a prototype for `dev_iterate'. * include/grub/dl.h (grub_arch_dl_sync_caches): New prototype. * include/grub/loader.h (grub_os_area_addr, grub_os_area_size): Moved from here... * include/grub/i386/pc/init.h (grub_os_area_addr) (rub_os_area_size): ... to here. * include/grub/powerpc/ieee1275/ieee1275.h (grub_ieee1275_entry_fn): Export symbol. * include/grub/powerpc/ieee1275/init.h: New file. * include/grub/powerpc/libgcc.h: Likewise. * kern/powerpc/cache.S: Likewise. Written by Hollis Blanchard . * kern/dl.c (grub_dl_flush_cache): New function. (grub_dl_load_core): Call `grub_dl_flush_cache' to flush the cache for this module. * kern/powerpc/ieee1275/init.c (grub_ofdisk_init) (grub_console_init): Removed prototypes. (grub_machine_init): Don't initialize the modules anymore. * kern/powerpc/ieee1275/openfw.c (grub_map): Make the function static. Index: genmk.rb =================================================================== RCS file: /cvsroot/grub/grub2/genmk.rb,v retrieving revision 1.8 diff -u -p -r1.8 genmk.rb --- genmk.rb 4 Apr 2004 13:45:59 -0000 1.8 +++ genmk.rb 19 Dec 2004 21:15:01 -0000 @@ -205,9 +205,55 @@ MOSTLYCLEANFILES += #{deps_str} end end +class Program + def initialize(dir, name) + @dir = dir + @name = name + end + attr_reader :dir, :name + + def rule(sources) + prefix = @name.to_var + objs = sources.collect do |src| + raise "unknown source file `#{src}'" if /\.[cS]$/ !~ src + prefix + '-' + src.to_obj + end + objs_str = objs.join(' '); + deps = objs.collect {|obj| obj.suffix('d')} + deps_str = deps.join(' '); + + "CLEANFILES += #{@name} #{objs_str} +MOSTLYCLEANFILES += #{deps_str} + +#{@name}: #{objs_str} + $(BUILD_CC) -o $@ $^ $(BUILD_LDFLAGS) $(#{prefix}_LDFLAGS) + +" + objs.collect_with_index do |obj, i| + src = sources[i] + fake_obj = File.basename(src).suffix('o') + dep = deps[i] + dir = File.dirname(src) + + "#{obj}: #{src} + $(CC) -I#{dir} -I$(srcdir)/#{dir} $(CPPFLAGS) $(CFLAGS) -DGRUB_UTIL=1 $(#{prefix}_CFLAGS) -c -o $@ $< + +#{dep}: #{src} + set -e; \ + $(CC) -I#{dir} -I$(srcdir)/#{dir} $(CPPFLAGS) $(CFLAGS) -DGRUB_UTIL=1 $(#{prefix}_CFLAGS) -M $< \ + | sed 's,#{Regexp.quote(fake_obj)}[ :]*,#{obj} $@ : ,g' > $@; \ + [ -s $@ ] || rm -f $@ + +-include #{dep} + +" + end.join('') + end +end + images = [] utils = [] pmodules = [] +programs = [] cont = false s = nil @@ -245,6 +291,11 @@ while l = gets Utility.new(prefix, util) end + when 'PROGRAMS' + programs += args.split(/\s+/).collect do |util| + Program.new(prefix, util) + end + when 'SOURCES' if img = images.detect() {|i| i.name.to_var == prefix} print img.rule(args.split(/\s+/)) @@ -252,6 +303,8 @@ while l = gets print pmod.rule(args.split(/\s+/)) elsif util = utils.detect() {|u| u.name.to_var == prefix} print util.rule(args.split(/\s+/)) + elsif program = programs.detect() {|u| u.name.to_var == prefix} + print program.rule(args.split(/\s+/)) end end end Index: boot/powerpc/ieee1275/cmain.c =================================================================== RCS file: /cvsroot/grub/grub2/boot/powerpc/ieee1275/cmain.c,v retrieving revision 1.4 diff -u -p -r1.4 cmain.c --- boot/powerpc/ieee1275/cmain.c 29 Oct 2004 02:45:14 -0000 1.4 +++ boot/powerpc/ieee1275/cmain.c 19 Dec 2004 21:15:01 -0000 @@ -21,8 +21,9 @@ #include #include -#include "grub/machine/ieee1275.h" -#include "grub/kernel.h" +#include +#include +#include struct module_info { @@ -38,15 +39,6 @@ intptr_t (*grub_ieee1275_entry_fn) (void grub_uint32_t grub_ieee1275_flags; -/* Return a help text for this architecture. */ -const char * -help_arch (void) -{ - /* No special information. */ - return ""; -} - - /* Setup the argument vector and pass control over to the main function. */ void Index: conf/powerpc-ieee1275.rmk =================================================================== RCS file: /cvsroot/grub/grub2/conf/powerpc-ieee1275.rmk,v retrieving revision 1.16 diff -u -p -r1.16 powerpc-ieee1275.rmk --- conf/powerpc-ieee1275.rmk 19 Dec 2004 20:35:06 -0000 1.16 +++ conf/powerpc-ieee1275.rmk 19 Dec 2004 21:15:01 -0000 @@ -11,7 +11,7 @@ DEFSYMFILES += kernel_syms.lst grubof_HEADERS = arg.h boot.h device.h disk.h dl.h elf.h env.h err.h \ file.h fs.h kernel.h misc.h mm.h net.h rescue.h symbol.h \ - term.h types.h machine/biosdisk.h \ + term.h types.h machine/biosdisk.h powerpc/libgcc.h loader.h \ partition.h pc_partition.h machine/time.h machine/ieee1275.h grubof_symlist.c: $(addprefix include/grub/,$(grubof_HEADERS)) gensymlist.sh @@ -20,8 +20,10 @@ grubof_symlist.c: $(addprefix include/gr kernel_syms.lst: $(addprefix include/grub/,$(grubof_HEADERS)) genkernsyms.sh sh $(srcdir)/genkernsyms.sh $(filter %h,$^) > $@ +# Programs +pkgdata_PROGRAMS = grubof + # Utilities. -sbin_UTILITIES = grubof bin_UTILITIES = grub-emu noinst_UTILITIES = genmoddep @@ -36,23 +38,20 @@ grub_emu_SOURCES = kern/main.c kern/devi normal/arg.c kern/partition.c \ util/console.c util/grub-emu.c util/misc.c util/i386/pc/getroot.c \ kern/env.c commands/ls.c \ - commands/terminal.c commands/boot.c commands/cmp.c commands/cat.c + commands/terminal.c commands/boot.c commands/cmp.c commands/cat.c \ + kern/powerpc/cache.S grub_emu_LDFLAGS = -lncurses grubof_SOURCES = boot/powerpc/ieee1275/crt0.S boot/powerpc/ieee1275/cmain.c \ boot/powerpc/ieee1275/ieee1275.c kern/main.c kern/device.c \ - kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c fs/fshelp.c \ + kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \ kern/misc.c kern/mm.c kern/loader.c kern/rescue.c kern/term.c \ kern/powerpc/ieee1275/init.c term/powerpc/ieee1275/ofconsole.c \ - kern/powerpc/ieee1275/openfw.c fs/ext2.c fs/ufs.c fs/minix.c fs/hfs.c \ - fs/jfs.c normal/cmdline.c normal/command.c normal/main.c normal/menu.c \ - disk/powerpc/ieee1275/ofdisk.c partmap/amiga.c partmap/pc.c \ - partmap/apple.c kern/partition.c \ - kern/env.c normal/arg.c loader/powerpc/ieee1275/linux.c \ - loader/powerpc/ieee1275/linux_normal.c commands/boot.c \ - normal/powerpc/setjmp.S kern/powerpc/dl.c grubof_symlist.c + kern/powerpc/ieee1275/openfw.c disk/powerpc/ieee1275/ofdisk.c \ + kern/partition.c kern/env.c kern/powerpc/dl.c grubof_symlist.c \ + kern/powerpc/cache.S grubof_HEADERS = grub/powerpc/ieee1275/ieee1275.h -grubof_CFLAGS = $(COMMON_CFLAGS) -DGRUBOF +grubof_CFLAGS = $(COMMON_CFLAGS) grubof_ASFLAGS = $(COMMON_ASFLAGS) grubof_LDFLAGS = -nostdlib -static-libgcc -lgcc -Wl,-N,-S,-Ttext,0x200000,-Bstatic @@ -60,3 +59,92 @@ grubof_LDFLAGS = -nostdlib -static-libgc genmoddep_SOURCES = util/genmoddep.c # Modules. +pkgdata_MODULES = _linux.mod linux.mod fat.mod ufs.mod ext2.mod minix.mod \ + hfs.mod jfs.mod normal.mod hello.mod font.mod \ + boot.mod cmp.mod cat.mod terminal.mod fshelp.mod amiga.mod apple.mod pc.mod + +# For fshelp.mod. +fshelp_mod_SOURCES = fs/fshelp.c +fshelp_mod_CFLAGS = $(COMMON_CFLAGS) + +# For fat.mod. +fat_mod_SOURCES = fs/fat.c +fat_mod_CFLAGS = $(COMMON_CFLAGS) + +# For ext2.mod. +ext2_mod_SOURCES = fs/ext2.c +ext2_mod_CFLAGS = $(COMMON_CFLAGS) + +# For ufs.mod. +ufs_mod_SOURCES = fs/ufs.c +ufs_mod_CFLAGS = $(COMMON_CFLAGS) + +# For minix.mod. +minix_mod_SOURCES = fs/minix.c +minix_mod_CFLAGS = $(COMMON_CFLAGS) + +# For hfs.mod. +hfs_mod_SOURCES = fs/hfs.c +hfs_mod_CFLAGS = $(COMMON_CFLAGS) + +# For jfs.mod. +jfs_mod_SOURCES = fs/jfs.c +jfs_mod_CFLAGS = $(COMMON_CFLAGS) + +# For iso9660.mod. +iso9660_mod_SOURCES = fs/iso9660.c +iso9660_mod_CFLAGS = $(COMMON_CFLAGS) + +# For _linux.mod. +_linux_mod_SOURCES = loader/powerpc/ieee1275/linux.c +_linux_mod_CFLAGS = $(COMMON_CFLAGS) + +# For linux.mod. +linux_mod_SOURCES = loader/powerpc/ieee1275/linux_normal.c +linux_mod_CFLAGS = $(COMMON_CFLAGS) + +# For normal.mod. +normal_mod_SOURCES = normal/cmdline.c normal/command.c normal/main.c \ + normal/menu.c normal/arg.c normal/powerpc/setjmp.S +normal_mod_CFLAGS = $(COMMON_CFLAGS) +normal_mod_ASFLAGS = $(COMMON_ASFLAGS) + +# For hello.mod. +hello_mod_SOURCES = hello/hello.c +hello_mod_CFLAGS = $(COMMON_CFLAGS) + +# For boot.mod. +boot_mod_SOURCES = commands/boot.c +boot_mod_CFLAGS = $(COMMON_CFLAGS) + +# For terminal.mod. +terminal_mod_SOURCES = commands/terminal.c +terminal_mod_CFLAGS = $(COMMON_CFLAGS) + +# For ls.mod. +ls_mod_SOURCES = commands/ls.c +ls_mod_CFLAGS = $(COMMON_CFLAGS) + +# For cmp.mod. +cmp_mod_SOURCES = commands/cmp.c +cmp_mod_CFLAGS = $(COMMON_CFLAGS) + +# For cat.mod. +cat_mod_SOURCES = commands/cat.c +cat_mod_CFLAGS = $(COMMON_CFLAGS) + +# For font.mod. +font_mod_SOURCES = font/manager.c +font_mod_CFLAGS = $(COMMON_CFLAGS) + +# For amiga.mod +amiga_mod_SOURCES = partmap/amiga.c +amiga_mod_CFLAGS = $(COMMON_CFLAGS) + +# For apple.mod +apple_mod_SOURCES = partmap/apple.c +apple_mod_CFLAGS = $(COMMON_CFLAGS) + +# For pc.mod +pc_mod_SOURCES = partmap/pc.c +pc_mod_CFLAGS = $(COMMON_CFLAGS) Index: disk/powerpc/ieee1275/ofdisk.c =================================================================== RCS file: /cvsroot/grub/grub2/disk/powerpc/ieee1275/ofdisk.c,v retrieving revision 1.5 diff -u -p -r1.5 ofdisk.c --- disk/powerpc/ieee1275/ofdisk.c 15 Oct 2004 20:04:28 -0000 1.5 +++ disk/powerpc/ieee1275/ofdisk.c 19 Dec 2004 21:15:01 -0000 @@ -22,10 +22,13 @@ #include #include #include +#include static int grub_ofdisk_iterate (int (*hook) (const char *name)) { + auto int dev_iterate (struct grub_ieee1275_devalias *alias); + int dev_iterate (struct grub_ieee1275_devalias *alias) { if (! grub_strcmp (alias->type, "block")) Index: include/grub/dl.h =================================================================== RCS file: /cvsroot/grub/grub2/include/grub/dl.h,v retrieving revision 1.6 diff -u -p -r1.6 dl.h --- include/grub/dl.h 4 Apr 2004 13:46:00 -0000 1.6 +++ include/grub/dl.h 19 Dec 2004 21:15:02 -0000 @@ -85,6 +85,7 @@ grub_err_t EXPORT_FUNC(grub_dl_register_ void *EXPORT_FUNC(grub_dl_resolve_symbol) (const char *name); int grub_arch_dl_check_header (void *ehdr, grub_size_t size); +void grub_arch_dl_sync_caches (void *address, grub_size_t len); grub_err_t grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr); #endif /* ! GRUB_DL_H */ Index: include/grub/loader.h =================================================================== RCS file: /cvsroot/grub/grub2/include/grub/loader.h,v retrieving revision 1.6 diff -u -p -r1.6 loader.h --- include/grub/loader.h 10 Sep 2004 20:31:55 -0000 1.6 +++ include/grub/loader.h 19 Dec 2004 21:15:02 -0000 @@ -26,9 +26,6 @@ #include #include -extern grub_addr_t EXPORT_VAR(grub_os_area_addr); -extern grub_size_t EXPORT_VAR(grub_os_area_size); - int EXPORT_FUNC(grub_loader_is_loaded) (void); void EXPORT_FUNC(grub_loader_set) (grub_err_t (*boot) (void), grub_err_t (*unload) (void)); Index: include/grub/i386/pc/init.h =================================================================== RCS file: /cvsroot/grub/grub2/include/grub/i386/pc/init.h,v retrieving revision 1.4 diff -u -p -r1.4 init.h --- include/grub/i386/pc/init.h 4 Apr 2004 13:46:01 -0000 1.4 +++ include/grub/i386/pc/init.h 19 Dec 2004 21:15:02 -0000 @@ -27,6 +27,9 @@ extern grub_size_t EXPORT_VAR(grub_lower_mem); extern grub_size_t EXPORT_VAR(grub_upper_mem); +extern grub_addr_t EXPORT_VAR(grub_os_area_addr); +extern grub_size_t EXPORT_VAR(grub_os_area_size); + /* Get the memory size in KB. If EXTENDED is zero, return conventional memory, otherwise return extended memory. */ grub_uint16_t grub_get_memsize (int extended); Index: include/grub/powerpc/libgcc.h =================================================================== RCS file: include/grub/powerpc/libgcc.h diff -N include/grub/powerpc/libgcc.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ include/grub/powerpc/libgcc.h 19 Dec 2004 21:15:02 -0000 @@ -0,0 +1,42 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2004 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 2 of the License, or + * (at your option) any later version. + * + * This program 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, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +void EXPORT_FUNC (memset) (void); +void EXPORT_FUNC (__adddf3) (void); +void EXPORT_FUNC (__addsf3) (void); +void EXPORT_FUNC (__ashldi3) (void); +void EXPORT_FUNC (__bss_start) (void); +void EXPORT_FUNC (__extendsfdf2) (void); +void EXPORT_FUNC (__fixunsdfsi) (void); +void EXPORT_FUNC (__floatsidf) (void); +void EXPORT_FUNC (__floatsisf) (void); +void EXPORT_FUNC (__lshrdi3) (void); +void EXPORT_FUNC (__make_dp) (void); +void EXPORT_FUNC (__make_fp) (void); +void EXPORT_FUNC (__muldf3) (void); +void EXPORT_FUNC (__pack_d) (void); +void EXPORT_FUNC (__pack_f) (void); +void EXPORT_FUNC (__subdf3) (void); +void EXPORT_FUNC (__subsf3) (void); +void EXPORT_FUNC (__thenan_df) (void); +void EXPORT_FUNC (__thenan_sf) (void); +void EXPORT_FUNC (__trampoline_setup) (void); +void EXPORT_FUNC (__truncdfsf2) (void); +void EXPORT_FUNC (__unpack_d) (void); +void EXPORT_FUNC (__unpack_f) (void); Index: include/grub/powerpc/ieee1275/ieee1275.h =================================================================== RCS file: /cvsroot/grub/grub2/include/grub/powerpc/ieee1275/ieee1275.h,v retrieving revision 1.9 diff -u -p -r1.9 ieee1275.h --- include/grub/powerpc/ieee1275/ieee1275.h 29 Oct 2004 02:45:14 -0000 1.9 +++ include/grub/powerpc/ieee1275/ieee1275.h 19 Dec 2004 21:15:02 -0000 @@ -39,7 +39,7 @@ struct grub_ieee1275_mem_region unsigned int size; }; -extern intptr_t (*grub_ieee1275_entry_fn) (void *); +extern intptr_t(* EXPORT_VAR(grub_ieee1275_entry_fn)) (void *); #ifndef IEEE1275_CALL_ENTRY_FN #define IEEE1275_CALL_ENTRY_FN(args) (*grub_ieee1275_entry_fn) (args) Index: include/grub/powerpc/ieee1275/init.h =================================================================== RCS file: include/grub/powerpc/ieee1275/init.h diff -N include/grub/powerpc/ieee1275/init.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ include/grub/powerpc/ieee1275/init.h 19 Dec 2004 21:15:02 -0000 @@ -0,0 +1,28 @@ +/* ieee1275.h - Access the Open Firmware client interface. */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2004 Free Software Foundation, Inc. + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef GRUB_INIT_MACHINE_HEADER +#define GRUB_INIT_MACHINE_HEADER 1 + +void cmain (uint32_t r3, uint32_t r4 __attribute__((unused)), uint32_t r5); +void grub_ofdisk_init (void); +void grub_console_init (void); + +#endif /* ! GRUB_INIT_MACHINE_HEADER */ Index: kern/dl.c =================================================================== RCS file: /cvsroot/grub/grub2/kern/dl.c,v retrieving revision 1.7 diff -u -p -r1.7 dl.c --- kern/dl.c 4 Apr 2004 13:46:01 -0000 1.7 +++ kern/dl.c 19 Dec 2004 21:15:02 -0000 @@ -479,6 +479,20 @@ grub_dl_unref (grub_dl_t mod) return --mod->ref_count; } +static void +grub_dl_flush_cache (grub_dl_t mod) +{ + grub_dl_segment_t seg; + grub_dl_segment_t segn; + + for (seg = mod->segment; seg; seg = segn) + { + segn = seg->next; + grub_free (seg->addr); + grub_arch_dl_sync_caches (seg->addr, seg->size); + } +} + /* Load a module from core memory. */ grub_dl_t grub_dl_load_core (void *addr, grub_size_t size) @@ -515,6 +529,8 @@ grub_dl_load_core (void *addr, grub_size return 0; } + grub_dl_flush_cache (mod); + grub_dl_call_init (mod); if (grub_dl_add (mod)) Index: kern/powerpc/cache.S =================================================================== RCS file: kern/powerpc/cache.S diff -N kern/powerpc/cache.S --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ kern/powerpc/cache.S 19 Dec 2004 21:15:02 -0000 @@ -0,0 +1,45 @@ +/* cache.S - Flush the processor cache for a specific region. */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2004 Free Software Foundation, Inc. + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#define CACHE_LINE_BYTES 32 + + .text + + .align 2 + .globl grub_arch_dl_sync_caches +grub_arch_dl_sync_caches: + /* Force the dcache lines to memory. */ + li 5, 0 +1: dcbst 5, 3 + addi 5, 5, CACHE_LINE_BYTES + cmpw 5, 4 + blt 1b + sync /* Force all dcbsts to complete. */ + + /* Invalidate the icache lines. */ + li 5, 0 +1: icbi 5, 3 + addi 5, 5, CACHE_LINE_BYTES + cmpw 5, 4 + blt 1b + sync /* Force all icbis to complete. */ + isync /* Discard partially executed instructions that were + loaded from the invalid icache. */ + blr Index: kern/powerpc/ieee1275/init.c =================================================================== RCS file: /cvsroot/grub/grub2/kern/powerpc/ieee1275/init.c,v retrieving revision 1.10 diff -u -p -r1.10 init.c --- kern/powerpc/ieee1275/init.c 19 Dec 2004 20:35:06 -0000 1.10 +++ kern/powerpc/ieee1275/init.c 19 Dec 2004 21:15:02 -0000 @@ -29,10 +29,8 @@ #include #include #include - -void grub_ofdisk_init (void); -void grub_console_init (void); - +#include +#include /* XXX: Modules are not yet supported. */ grub_addr_t grub_end_addr = -1; @@ -73,14 +71,6 @@ grub_machine_init (void) /* XXX: Loadable modules are not supported. */ grub_env_set ("prefix", ""); - grub_ext2_init (); - grub_normal_init (); - grub_boot_init (); - grub_linux_init (); - grub_linux_normal_init (); - grub_pc_partition_map_init (); - grub_amiga_partition_map_init (); - grub_apple_partition_map_init (); grub_ofdisk_init (); } Index: kern/powerpc/ieee1275/openfw.c =================================================================== RCS file: /cvsroot/grub/grub2/kern/powerpc/ieee1275/openfw.c,v retrieving revision 1.5 diff -u -p -r1.5 openfw.c --- kern/powerpc/ieee1275/openfw.c 16 Nov 2004 21:59:11 -0000 1.5 +++ kern/powerpc/ieee1275/openfw.c 19 Dec 2004 21:15:03 -0000 @@ -144,7 +144,7 @@ grub_devalias_iterate (int (*hook) (stru } /* Call the "map" method of /chosen/mmu. */ -int +static int grub_map (grub_addr_t phys, grub_addr_t virt, grub_uint32_t size, grub_uint8_t mode) {