booting problem ...

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Andrew

booting problem ...

Post by Andrew »

Hi,
i've recently started to experience very wierd problem with my OS. i'll try to describe what happens that you would be able to help me :)
so, when kernel reaches 64000 bytes or 125 sectors long everything is fine and it does what it should, but when i uncomment one line (set Floppy buffer some value) of my code and kernel becomes 64032 bytes or 126 sectors os boots but then everything hangs right at the start of the kernel. when i uncomment one more line (which works with that buffer) and kernel is 64096 bytes or 126 sectors long - os will not even boot. well i thought that it was smth with my code, so i tried "printf" function, but got the same result.
what i think is that the problem is in the bootsector this is how i read from the floppy :

Code: Select all

read:
  xor ax, ax
  mov dl, [drive]
  int 0x13
  jc read

; read first 17 + 18 sectors of kernel
; we have 575 KB

  mov ax, 0xFA0
  mov es, ax
  mov bx, 0x600
  mov ah, 0x2
  mov al, 17
  mov cx, 0x0002
  mov dh, 0
  int 0x13
  
  mov ax, 0x11F8
  mov es,ax
  mov bx, 0x280
  mov ah, 0x2
  mov al, 18
  mov cx, 0x0001
  mov dh, 1
  int 0x13
  
;********************************
  
  mov si, 7 ; read n * 18 sectors of kernel, also change ecx
  
  mov ax, 0x11F8
  push ax
  mov bx, 0x280
  mov ch, 0x1     ; track
  xor dh, dh
  
cycle:
  pop ax
  add ax, 0x1F4
  mov es, ax
  push ax
  add bx, 0x4C0  ; offset
  mov ah, 0x2 
  mov al, 18      ; 18 sectors
  mov cl, 0x1     ; from first sector
  int 0x13
 
  cmp dh, 1
  je trackDone
  inc dh
  dec si
  jmp cycleDone
trackDone:
  dec dh
  inc ch
  dec si
cycleDone:
  cmp si, 0
  jne cycle
    
;************************************  
  pop ax
  jc read
i posted this part of the code, cause i think that maybe this is where the problem hides ..... i dunno. :(
if not, i attached all bootsector.
any help would be appreciated. thank you in advance.

[attachment deleted by admin]
Curufir

Re:booting problem ...

Post by Curufir »

Well all the memory segment:offsets check out (Although I can't for the life of me see why you'd want to alter both the segment and the offset. It would be far simpler just to change the segment and leave bx at some fixed value (eg 0).

Think I've got an idea about the problem though. Can you drop in some code to check the return status of the BIOS disk read (Which should be there already I might add, assuming you ever want to run it on real hardware). In particular I'm curious about the value of AH if there is an error. I got this sneaking feeling that somewhere along the line you've tried to do a read that crosses a dma page.
Andrew

Re:booting problem ...

Post by Andrew »

Curufir wrote: I got this sneaking feeling that somewhere along the line you've tried to do a read that crosses a dma page.
hmm, and what is the address of the DMA page ?
Ozguxxx

Re:booting problem ...

Post by Ozguxxx »

Hey, I might be wrong but your are crossing 640KByte border (A0000h) which is not a very good thing. I think after that border upto 1Meg is full of dangerous areas of video memory, rom(is that correct?, etc), choosing base something lower might help or getting completely outof first 1 Meg will be useful. I hope this helps, good luck.
Andrejus

Re:booting problem ...

Post by Andrejus »

Hi,

no we dont't cross 640KB border !

We write to 0x10000, and I think 0xa0000 - 0x10000 > 64KB :), so it is impossible to cross 0xa0000.

If we have 125 everything is OK (6 iterations with 18 sectors + 1 iteration with 17), but if code grows to 126 or more, our OS crashes. Even if we add some simple printf in 'main' function.

???
Ozguxxx

Re:booting problem ...

Post by Ozguxxx »

Well, sorry :P, but in your code there is a comment like:

; read first 17 + 18 sectors of kernel
; to 0x10000, next bomb at 0x9FC00
; we have 575 KB

well, I think I have misunderstood comment, what does 'bombing at 0x9fc00' mean? I am not sure but holy source (salut Pype!) says me that your problem is in a stack overflow or overwriting...
Andrejus

Re:booting problem ...

Post by Andrejus »

I scan memory from 0x500 to 0xa0000 and for my great wonder I found some reserved chunks of memory :)
0x9FC00 is the nearest one.

Thanks Curufir, I think we cross dma.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:booting problem ...

Post by Pype.Clicker »

Andrejus wrote: Thanks Curufir, I think we cross dma.
i'm a bit surprised here, i thought the BIOS functions were able to deal with DMA barriers with less problems than this ...
Post Reply