[haiku-commits] r38951 - haiku/trunk/src/system/boot/platform/amiga_m68k

  • From: revol@xxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 12 Oct 2010 01:33:02 +0200 (CEST)

Author: mmu_man
Date: 2010-10-12 01:33:01 +0200 (Tue, 12 Oct 2010)
New Revision: 38951
Changeset: http://dev.haiku-os.org/changeset/38951

Modified:
   haiku/trunk/src/system/boot/platform/amiga_m68k/shell.S
   haiku/trunk/src/system/boot/platform/amiga_m68k/start.cpp
Log:
Adapt the putx routine from atari code to update the string for the alert with 
a code. Use it to indicate remaining sectors to read on error.
It seems DoIO() fails after 6 sectors. Could it have something to do with side 
handling ? I hope I won't have to dig trackdisk.device specific stuff...
Anyway even with 6 sectors read, the boot code now calls _start() successfully. 
Use _floppy_err_alert() to assert this until the copying is fixed.


Modified: haiku/trunk/src/system/boot/platform/amiga_m68k/shell.S
===================================================================
--- haiku/trunk/src/system/boot/platform/amiga_m68k/shell.S     2010-10-11 
19:58:46 UTC (rev 38950)
+++ haiku/trunk/src/system/boot/platform/amiga_m68k/shell.S     2010-10-11 
23:33:01 UTC (rev 38951)
@@ -71,8 +71,11 @@
 
 floppy_start:
        // save some regs just in case
-       //movem.l               %d1-%d7/%a0-%a6,-(%sp)
+       movem.l         %d1-%d7/%a0-%a6,-(%sp)
 
+       // save the provided IOReq pointer
+       lea             sBootIOReq(%pc),%a2
+       move.l  %a1,(%a2)
 
        // seems like a6 is already set to ExecBase when called from the ROM ?
        move.l  4.w,%a6 // exec base
@@ -89,21 +92,77 @@
 //     beq.s   _floppy_err
 //     move.l  %d0,(%a2)
 
+       // needed to display alerts
        lea     intname_boot(%pc),%a1
        jsr     _LVOOldOpenLibrary(%a6)
        tst.l   %d0
-       beq.s   _floppy_err
+       beq             _floppy_err
        lea     IntuitionBase(%pc),%a2
        move.l  %d0,(%a2)
 
-       // allocate absolute memory to put the bootloader
+       // allocate absolute memory to put the stack & bootloader at,
+       // just to make sure AmigaOS won't write there.
        
+       move.l  
#(AMIGA_ZBEOS_STACK_END-AMIGA_ZBEOS_STACK_BASE+AMIGA_ZBEOS_MAX),%d0
+       move.l  #AMIGA_ZBEOS_STACK_BASE,%a1
+       jsr             _LVOAllocAbs(%a6)
+       tst.l   %d0
+       beq.s   _floppy_err_alert
+       
+       //lea           alert_extra(%pc),%a2
+       //addq.b        #1,(%a2)
+       move.l  #0xdeadbeef,%d0
+       bsr             putx
 
+       // copy haiku_loader to AMIGA_ZBEOS_BASE
+       
 
-       jsr             _display_alert
 
-       bra _floppy_err
+       lea             sBootIOReq,%a1
+       move.l  (%a1),%a1
+       move    #CMD_READ,28(%a1)                               //io_Command
+       //move.l        #0x200,%d0
+       //XXX
+       //mulu  sNumSectors,%d0
+       //move.l        %d0,36(%a1)                             //io_Length
+       move.l  #0x200,36(%a1)                          //io_Length
+       move.l  #AMIGA_ZBEOS_BASE,40(%a1)       //io_Data
+       move.l  #0,44(%a1)                                      //io_Offset
+       move.w  sNumSectors,%d2
 
+next_sector:
+       move.w  %d2,%d0
+       bsr             putx
+
+       move.l  %a1,-(%sp)
+       jsr             _LVODoIO(%a6)
+       move.l  (%sp)+,%a1
+       
+       tst.l   %d0
+       bne     _floppy_err_alert
+       
+       add.l   #0x200,40(%a1)                  //io_Data
+       add.l   #0x200,44(%a1)                  //io_Offset
+       //subq.w        #1,sNumSectors
+       subq.w  #1,%d2
+       bne             next_sector
+
+       move.l  #0xf100f100,%d0
+       bsr             putx
+
+       //lea           alert_extra(%pc),%a2
+       //move.b        #'F',(%a2)
+
+//     move.l
+//     cmp.l   32(%a1),36(%a1)
+//     blt.s   _floppy_err_alert
+
+       //lea           alert_extra(%pc),%a2
+       //addq.b        #1,(%a2)
+
+       bra.s   floppy_done
+       
+
 //_continue:
 //     lea     dosname_boot(%pc),%a1
 //     move.l  4.w,%a6 // exec base
@@ -119,67 +178,79 @@
 //     moveq   #0,%d0
 //     rts
 
-_floppy_err:
-       // pop up saved regs
-       //movem.l               (%sp)+,%d1-%d7/%a0-%a6
-       moveq   #-1,%d0
-       rts
-
-
-_display_alert:
-       //move.l        %a6,-(%sp)
+GLOBAL(_floppy_err_alert):
        lea             IntuitionBase(%pc),%a6
        move.l  (%a6),%a6
        lea             alert_data(%pc),%a0
        moveq   #0,%d0
-       move.l  #40,%d1
+       move.l  #30,%d1
        jsr             _LVODisplayAlert(%a6)
-       //move.l        (%sp)+,%a6
+       
+_floppy_err:
+       // pop up saved regs
+       movem.l         (%sp)+,%d1-%d7/%a0-%a6
+       moveq   #-1,%d0
        rts
 
 
 
 
 
+
        
-       // ATARI
-#if 0
-
-       lea             label_floppy,%a0
-       bsr             puts
-       //bra floppy_start
-
-       // no interrupt
-       //or.w          #0x0700,%sr
-
-       //XXX: check for enough RAM
-
-       // load the rest
-       //move.w                sNumSectors,%d2
-       // load at base + this code.
-       //move.l                #(ATARI_ZBEOS_BASE+512),%a2
-       //move.l                %a2,%d0
-       //bsr putx
-       bsr                     load_sectors
-       tst.w                   %d0
-       bne                     load_failed
 floppy_done:
        // setup stack
-       move.l          #ATARI_ZBEOS_STACK_END,%sp
-       //jmp                   ATARI_ZBEOS_BASE+512
+       move.l          #AMIGA_ZBEOS_STACK_END,%sp
+       //jmp                   AMIGA_ZBEOS_BASE+512
 
-       move.b          #ATARI_BOOT_DRVAPI_FLOPPY,ATARI_ZBEOS_BASE + 
gBootDriveAPI - _bs_entry 
-       move.w          TOSVAR_bootdev,%d0
+       //move.w                TOSVAR_bootdev,%d0
        // XXX:  use uint16 ??
-       move.b          %d0,ATARI_ZBEOS_BASE + gBootDriveID - _bs_entry 
-       move.b          #1,ATARI_ZBEOS_BASE + gBootedFromImage - _bs_entry 
+       //move.b                %d0,AMIGA_ZBEOS_BASE + gBootDriveID - _bs_entry 
+       move.b          #1,AMIGA_ZBEOS_BASE + gBootedFromImage - _bs_entry 
+       // XXX: copy the rest !
 
-       lea             msg_j1,%a0
-       bsr             puts
+       move.b          #'S',AMIGA_ZBEOS_BASE + alert_extra - _bs_entry 
+       // Copy open library handles
+       move.l          SysBase(%pc),AMIGA_ZBEOS_BASE + SysBase - _bs_entry 
+       move.l          IntuitionBase(%pc),AMIGA_ZBEOS_BASE + IntuitionBase - 
_bs_entry 
+
        move.l          #0,%d0
 
+       // jump to C++ code
        jmp             _start
 
+
+putx:
+       movem.l %d0-%d2/%a0-%a2,-(%sp)
+       lea             alert_extra(%pc),%a2
+       move.l  #8-1,%d2
+       move.l  %d0,%d1
+putxloop:
+       move.l  %d1,%d0
+       lsl.l   #4,%d1
+       //swap  %d0
+       //lsr.l #8,%d0
+       //lsr.l #4,%d0
+       rol.l   #4,%d0
+       and.l   #0x0f,%d0
+       cmp.b   #9,%d0
+       ble     putx0
+       add.b   #'a'-'0'-10,%d0
+       //bra   putxdisp
+putx0:
+       add.b   #'0',%d0
+putxdisp:
+       move.b  %d0,(%a2)+
+       dbf     %d2,putxloop
+//     bsr     putcrlf
+       movem.l (%sp)+,%d0-%d2/%a0-%a2
+       rts
+
+
+       // ATARI
+#if 0
+
+
 load_failed:
        //bra                   _exit
 
@@ -355,30 +426,6 @@
 
 
 
-putx:
-       movem.l %d0-%d2/%a0-%a2,-(%sp)
-       move.l  #8-1,%d2
-       move.l  %d0,%d1
-putxloop:
-       move.l  %d1,%d0
-       lsl.l   #4,%d1
-       //swap  %d0
-       //lsr.l #8,%d0
-       //lsr.l #4,%d0
-       rol.l   #4,%d0
-       and.l   #0x0f,%d0
-       cmp.b   #9,%d0
-       ble     putx0
-       add.b   #'a'-'0'-10,%d0
-       //bra   putxdisp
-putx0:
-       add.b   #'0',%d0
-putxdisp:
-       bsr     putc
-       dbf     %d2,putxloop
-       bsr     putcrlf
-       movem.l (%sp)+,%d0-%d2/%a0-%a2
-       rts
        
 
 puts:
@@ -446,8 +493,11 @@
        // 0x180 is the allowed maximum, as the zipped TAR with the
        // kernel and the boot module might start at offset 192 kB
        //.word 0x0300 //0x0180
-       .word   BOOT_ARCHIVE_IMAGE_OFFSET*2
+       .word   6//BOOT_ARCHIVE_IMAGE_OFFSET*2
 
+sBootIOReq:
+       .long   0
+
 dosname_boot:
        .ascii  "dos.library"
        .byte   0
@@ -461,7 +511,7 @@
        .byte   12
        .ascii  "Error loading Haiku: "
 alert_extra:
-       .ascii  "0\0"
+       .ascii  "XXXXXXXX\0"
        .byte   0
 
 GLOBAL(SysBase):

Modified: haiku/trunk/src/system/boot/platform/amiga_m68k/start.cpp
===================================================================
--- haiku/trunk/src/system/boot/platform/amiga_m68k/start.cpp   2010-10-11 
19:58:46 UTC (rev 38950)
+++ haiku/trunk/src/system/boot/platform/amiga_m68k/start.cpp   2010-10-11 
23:33:01 UTC (rev 38951)
@@ -117,10 +117,13 @@
        while (true) {}
 }
 
+extern "C" void _floppy_err_alert();
 
 extern "C" void
 _start(void)
 {
+_floppy_err_alert();
+       panic("plop");
        stage2_args args;
 
        //asm("cld");                   // Ain't nothing but a GCC thang.


Other related posts:

  • » [haiku-commits] r38951 - haiku/trunk/src/system/boot/platform/amiga_m68k - revol