Brendan wrote:
Hi,
alexeikom wrote:
Brendan wrote:
I'd assume that your code is "buggy"....
Hi! I thought that either but then I checked it on real machine and it worked.
So you're saying that your code is buggy, but the bug depends on something that might be different on different computers (like CPU features, or memory map, or timing, or the presence or absence of certain devices, or the initial contents of uninitialised RAM, or the initial contents of registers when BIOS passes control to your code, or how the firmware happens to use part of its BDA or EBDA that gets accidentally corrupted, or....), and so it's only a problem on some computers (e.g. Bochs and possibly millions of others) and not other computers (e.g. one real computer)?
My suggestion would be to test on Bochs using something like this:
Code:
mov ax,[0x046C]
sti
.wait:
hlt
cmp [0x046C],ax
je .wait
The idea is that you put this as early as possible in your boot code and see if it waits forever, then shift it somewhere else and see if it waits forever, and keep shifting it like that using a kind of binary search pattern (e.g. each time, shift it to approximately half-way between where it was working last and where it stopped working last) to find the point in your code immediately before it stops working.
Cheers,
Brendan
Hi! Thanks for a great suggestion. I did the check and the code suggested by you worked everywhere! I then compared it to my code:
Code:
push es
push ax
xor ax,ax
mov es,ax
mov ax,[es:0x046C]
inc ax
comp:
cmp ax,[es:0x046C]
jae comp
pop ax
pop es
ret
You have sti in your code. But I didn't issue cli. So who did? Apparently, cli is issued when I call int 0x1A with AX=0xB101 (check PCI BIOS availability) or AX=0xB103 (find PCI class code). Perhaps more functions related to PCI do that. When I put sti right after their execution, everything works fine!