Hallo!
I tried to add the capability to load a BeOS kernel. Unfortunately, in
the programmer manual there is a lot written about the boot sector but
nothing about loading a kernel. So I read the sources again and again
and tried some changes (see diff file included). There are two problems:

1. In "grub" (i.e. the command line tool) the BeOS kernel will be loaded
and the right size is indicated. But starting with "stage2" (i.e. real
boot) and typing "kernel = /boot/kernel/Zbeos" the loading is aborted
with an error message (sorry, I forgot the exact phrase) and typing it
once again the computer makes immediately a hard reset.

2. I don't know how to identify ("signature") a BeOS kernel. I didn't
find any kind of appropriate data in the header -- it all seems to be
code, except the loading message which I used to identify the kernel,
but this can change. (A free evaluation of BeOS is available from
<http://www.be.com/products/freebeos/>, from there I have the kernel and
the loader [BeOS is loaded from DOS via "loadbeos.com", which loads the
kernel to cs:0100 and jumps to cs:0100]).

Best wishes                           Jan
diff -urN grub-0.5.95.org/grub/asmstub.c grub-0.5.95/grub/asmstub.c
--- grub-0.5.95.org/grub/asmstub.c      Sat May 20 23:35:20 2000
+++ grub-0.5.95/grub/asmstub.c  Sun Sep  3 19:22:22 2000
@@ -633,6 +633,14 @@
 }
 
 
+/* For BeOS kernels. */
+void
+beos_boot (void)
+{
+  stop ();
+}
+
+
 /* booting a multiboot executable */
 void
 multi_boot (int start, int mbi)
diff -urN grub-0.5.95.org/stage2/asm.S grub-0.5.95/stage2/asm.S
--- grub-0.5.95.org/stage2/asm.S        Sat Jun  3 08:08:05 2000
+++ grub-0.5.95/stage2/asm.S    Sun Sep  3 19:16:27 2000
@@ -1676,6 +1676,26 @@
 
 
 /*
+ * beos_boot()
+ *
+ * Does some funky things, then jumps to the
+ * entry point of the BeOS setup code.
+ */
+
+ENTRY(beos_boot)
+       /* don't worry about saving anything, we're committed at this point */
+       cld     /* forward copying */
+
+       call    EXT_C(prot_to_real)
+       .code16
+
+       /* jump to start */
+       ljmp    $0x1000, $0x100
+
+       .code32
+
+
+/*
  * multi_boot(int start, int mbi)
  *
  *  This starts a kernel in the manner expected of the multiboot standard.
diff -urN grub-0.5.95.org/stage2/boot.c grub-0.5.95/stage2/boot.c
--- grub-0.5.95.org/stage2/boot.c       Fri May  5 00:15:20 2000
+++ grub-0.5.95/stage2/boot.c   Sun Sep  3 20:39:21 2000
@@ -317,6 +317,19 @@
       else
        errnum = ERR_WONT_FIT;
     }
+  else if ((*((unsigned short *) (buffer + BOOTSEC_SIG_OFFSET))
+           == BOOTSEC_SIGNATURE)
+          && (!grub_memcmp(buffer + BEOS_SIG_OFFSET, BEOS_SIGNATURE, 
+BEOS_SIG_LENGTH)))
+    {
+      int kernel_size;
+      
+      grub_seek (0);
+/*      cur_addr = BEOS_KERNEL;  */
+      kernel_size = grub_read ((char *) BEOS_KERNEL, -1);
+      printf("   [BeOS, size=0x%x]\n", kernel_size);
+      grub_close();
+      return KERNEL_TYPE_BEOS;
+    }
   else                         /* no recognizable format */
     errnum = ERR_EXEC_FORMAT;
 
diff -urN grub-0.5.95.org/stage2/builtins.c grub-0.5.95/stage2/builtins.c
--- grub-0.5.95.org/stage2/builtins.c   Thu Jun  1 08:26:52 2000
+++ grub-0.5.95/stage2/builtins.c       Sun Sep  3 19:04:07 2000
@@ -213,6 +213,11 @@
       big_linux_boot ();
       break;
 
+    case KERNEL_TYPE_BEOS:
+      /* BeOS */
+      beos_boot();
+      break;
+      
     case KERNEL_TYPE_CHAINLOADER:
       /* Chainloader */
       
diff -urN grub-0.5.95.org/stage2/shared.h grub-0.5.95/stage2/shared.h
--- grub-0.5.95.org/stage2/shared.h     Tue May 30 17:58:09 2000
+++ grub-0.5.95/stage2/shared.h Sun Sep  3 19:06:09 2000
@@ -166,6 +166,15 @@
 #define CL_OFFSET       RAW_ADDR (0x90022)
 
 /*
+ *  BeOS stuff
+ */
+ 
+#define BEOS_SIG_OFFSET                0x1a6
+#define BEOS_SIG_LENGTH                14
+#define BEOS_SIGNATURE         "Be Boot Loader"
+#define BEOS_KERNEL             RAW_ADDR (0x10100)
+
+/*
  *  General disk stuff
  */
 
@@ -577,6 +586,9 @@
 /* do some funky stuff, then boot bzImage linux */
 void big_linux_boot (void) __attribute__ ((noreturn));
 
+/* do some funky stuff, then boot BeOS */
+void beos_boot (void) __attribute__ ((noreturn));
+
 /* booting a multiboot executable */
 void multi_boot (int start, int mbi) __attribute__ ((noreturn));
 
@@ -676,6 +688,7 @@
   KERNEL_TYPE_BIG_LINUX,       /* Big Linux.  */
   KERNEL_TYPE_FREEBSD,         /* FreeBSD.  */
   KERNEL_TYPE_NETBSD,          /* NetBSD.  */
+  KERNEL_TYPE_BEOS,            /* BeOS.  */
   KERNEL_TYPE_CHAINLOADER      /* Chainloader.  */
 }
 kernel_t;

Reply via email to