Commits

prabirshrestha  committed 623e7a4

load 0-63 sectors

  • Participants
  • Parent commits ae0b214

Comments (0)

Files changed (2)

File src/boot/x86/boot.s

     jmp hang
 
 read_fdd:
-     # display A
+  # display A
   mov ah,0x0E 
   mov bh,0x00 
   mov al,65
   int 0x10
 
-  # Reset disk system.
-  # Jump to bootFailure on error.
-  mov  dl, iBootDrive  # drive to reset
-  xor  ax, ax          # subfunction 0
-  int  0x13            # call interrupt 13h
-  jc   bootFailure     # display error message if carry set (error)  
+  mResetFddSystem
+
+  # Set ES:BX to STAGE2_SEGMENT:STAGE2_OFFSET
+  mov     bx,     STAGE2_SEGMENT
+  mov     es,     bx
+  mov     bx,     STAGE2_OFFSET
   
   mov ax,0x1000 # When we read the sector, we are going to read address 0x1000
   mov es,ax   #Set ES with 0x1000
 
-floppy:
-  mov ah,0x2  #2 = Read floppy
-  mov al,0x1  #Reading one sector
-  mov ch,0x0  #Track 1 *0 = 1*
-  mov cl,0x2  #Sector 2, track 1
-  mov dh,0x0  #Head 1
-  mov dl,0x0  #Drive = 0 (Floppy)
-  int 0x13
-  jc floppy #If carry flag was set, try again
-
-jmp 0x1000:0000 #Jump to 0x1000, start of second program
-
+# Try to read the sectors.
+read_floppy_sectors:
+    mov     ah,     0x02            # Read sectors.
+    mov     al,     STAGE2_SECTORS  # Sectors 0 .. 63.
+    mov     ch,     0               # Cylinder 0.
+    mov     cl,     2               # Sector 2.
+    mov     dh,     0               # Head 0.
+    mov     dl,     [iBootDrive]        # Use the BIOS device.
+    int     0x13
+    jc read_floppy_sectors # If carry flag was set, try again (todo: retry)
+
+start_stage_1_5:
+  jmp STAGE2_OFFSET:STAGE2_SEGMENT # Jump to the start of second program
 
 # using combination of cli/hlt/jmp can create better efficient power saving
 # infinite loops then just using jmp

File src/boot/x86/boot1_5.s

 
 hang:
     jmp hang
-
-.fill (512-(.-stage1_5)), 1, 0  # Pad with nulls up to 510 bytes (exclude boot magic)