Hallo!
This is my second try to load the BeOS kernel from grub. It worked on my
computer, but if I ommit the "debugging output" in the function
beos_boot in the file asm.S then it doesn't. Can anybody help or explain
why?
For testing you can download the kernel Zbeos from
<ftp://pc-fricke.math-inf.uni-greifswald.de/pub/beos/>, there is also
the BeOS loader from DOS (loadbeos.com) and its disassembler output
(loadbeos.lst).

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    Thu Sep  7 10:50:04 2000
@@ -1676,6 +1676,51 @@
 
 
 /*
+ * 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 */
+
+       /* copy kernel */
+       movl    $BEOS_KERNEL_SIZE, %ecx
+       movl    (%ecx), %ecx
+       addl    $3, %ecx
+       shrl    $2, %ecx
+       movl    $BEOS_STAGING_AREA, %esi
+       movl    $BEOS_KERNEL, %edi
+
+       rep
+       movsl
+
+       call    EXT_C(prot_to_real)
+       .code16
+
+       movw    $0xb800, %ax
+       movw    %ax, %es
+
+       movb    $0x40, %es:0
+       
+       mov     $0x1000, %ax
+       mov     %ax, %ds
+
+       mov     %ds:0x2a6, %al
+       mov     %al, %es:2
+       mov     %ds:0x2a7, %al
+       mov     %al, %es:4
+
+       xor     %sp, %sp
+       /* jump to start */
+       .byte   0xea,  0x00, 0x01, 0x00, 0x10
+
+       .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   Tue Sep  5 11:26:46 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);
+      kernel_size = grub_read ((char *) BEOS_STAGING_AREA, -1);
+      printf("   [BeOS, size=0x%x]\n", kernel_size);
+      grub_close();
+      *((int *) BEOS_KERNEL_SIZE) = kernel_size;
+      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 Thu Sep  7 09:23:49 2000
@@ -166,6 +166,17 @@
 #define CL_OFFSET       RAW_ADDR (0x90022)
 
 /*
+ *  BeOS stuff
+ */
+ 
+#define BEOS_STAGING_AREA       RAW_ADDR (0x100100)
+#define BEOS_KERNEL_SIZE        RAW_ADDR (0x100000)
+#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 +588,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 +690,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