grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Module support for the PPC


From: Marco Gerards
Subject: Module support for the PPC
Date: Sun, 19 Dec 2004 21:17:19 +0000
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux)

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  <address@hidden>

        * genmk.rb: Handle the `Program' class in the main loop.  Written
        by Johan Rydberg <address@hidden>.
        (Program): New class.
        * boot/powerpc/ieee1275/cmain.c: Include <grub/machine/ieee1275.h>
        instead of "grub/machine/ieee1275.h".  Include <grub/kernel.h>
        instead of "grub/kernel.h".  Include <grub/machine/init.h>.
        (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/machine/init.h>.
        (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
        <address@hidden>.
        * 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 += address@hidden #{objs_str}
+MOSTLYCLEANFILES += #{deps_str}
+
address@hidden: #{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 <alloca.h>
 #include <stdint.h>
 
-#include "grub/machine/ieee1275.h"
-#include "grub/kernel.h"
+#include <grub/machine/ieee1275.h>
+#include <grub/kernel.h>
+#include <grub/machine/init.h>
 
 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 <grub/disk.h>
 #include <grub/mm.h>
 #include <grub/machine/ieee1275.h>
+#include <grub/machine/init.h>
 
 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 <grub/err.h>
 #include <grub/types.h>
 
-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 <grub/setjmp.h>
 #include <grub/env.h>
 #include <grub/misc.h>
-
-void grub_ofdisk_init (void);
-void grub_console_init (void);
-
+#include <grub/machine/init.h>
+#include <grub/machine/time.h>
 
 /* 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)
 {





reply via email to

[Prev in Thread] Current Thread [Next in Thread]