OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 12:14 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Wrong code for testing the A20 line? Disable A20 in Bochs?
PostPosted: Wed Feb 06, 2019 8:00 pm 
Offline

Joined: Wed Oct 31, 2018 6:15 am
Posts: 18
Hello,

First of all, I'd like to ask whether it's possible to disable A20 on Bochs. I tried running this code to make sure it's disabled, but my test function (please see below) still reports it's enabled:
Code:
    mov ax, 0x2400
    int 0x15
    out 0xee,al


Secondly, I'd like to ask whether I did something wrong in implementing my code for testing the A20 line. It is based on the recommendation here (@osdev):
Quote:
Before enabling the A20 with any of the methods described below it is better to test whether the A20 address line was already enabled by the BIOS. This can be achieved by comparing, at boot time in real mode, the bootsector identifier (0xAA55) located at address 0000:7DFE with the value 1 MiB higher which is at address FFFF:7E0E. When the two values are different it means that the A20 is already enabled otherwise if the values are identical it must be ruled out that this is not by mere chance. Therefore the bootsector identifier needs to be changed, for instance by rotating it left by 8 bits, and again compared to the 16 bits word at FFFF:7E0E. When they are still the same then the A20 address line is disabled otherwise it is enabled.

This is a link to my code: https://i.imgur.com/micAq3A.png


Top
 Profile  
 
 Post subject: Re: Wrong code for testing the A20 line? Disable A20 in Boch
PostPosted: Thu Feb 07, 2019 7:43 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
PhantomR wrote:
First of all, I'd like to ask whether it's possible to disable A20 on Bochs.

It depends on how your copy of Bochs was built. Support for the A20 gate is a compile-time option, so it may not be compiled into your copy of Bochs.

PhantomR wrote:
This is a link to my code: https://i.imgur.com/micAq3A.png

Why is this an image?

Code:
ror byte [es:0x7DFE], 8

I don't think this instruction will do what you want.


Top
 Profile  
 
 Post subject: Re: Wrong code for testing the A20 line? Disable A20 in Boch
PostPosted: Fri Feb 08, 2019 8:10 pm 
Offline

Joined: Wed Oct 31, 2018 6:15 am
Posts: 18
Well, I wouldn't know how it was built since I just used the Windows binaries on their website :). But it's good to know that's a compile option.
EDIT: Actually, I was just reading a log file and noticed this, indicating it is supported. But is disabling it supported?
Code:
00000000000i[      ] Bochs x86 Emulator 2.6.9
00000000000i[      ]   Built from SVN snapshot on April 9, 2017
00000000000i[      ] Compiled on Apr 17 2017 at 19:10:43
00000000000i[      ] System configuration
00000000000i[      ]   processors: 1 (cores=1, HT threads=1)
00000000000i[      ]   A20 line support: yes
00000000000i[      ] IPS is set to 4000000
00000000000i[      ] CPU configuration


Here's a pastebin of my code. Sorry for the image. https://pastebin.com/6B22Wbh3

Regarding the ror instruction, may I ask why?

Thank you! :)


Top
 Profile  
 
 Post subject: Re: Wrong code for testing the A20 line? Disable A20 in Boch
PostPosted: Sat Feb 09, 2019 2:50 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
PhantomR wrote:
Actually, I was just reading a log file and noticed this, indicating it is supported. But is disabling it supported?

Yep. Wouldn't make much sense otherwise.

PhantomR wrote:
Regarding the ror instruction, may I ask why?

You're rotating a byte by 8 bits.

Out of curiosity, what does your test code report if you run it before you try to disable A20? (If you're not using a bootloader like GRUB, A20 will already be disabled.)


Top
 Profile  
 
 Post subject: Re: Wrong code for testing the A20 line? Disable A20 in Boch
PostPosted: Sat Feb 09, 2019 9:24 am 
Offline

Joined: Wed Oct 31, 2018 6:15 am
Posts: 18
Oh, my God! Stupid me, my test function actually reported the A20 line to be disabled if the words at addresses 0x7DFE and 0xFFFF:0x7E0E (which translates to 0x107DFE) are DIFFERENT, which means exactly the opposite.

THANK YOU SO MUCH! It works now.. the only thing I had to change were the two jumps: "jne .not_enabled" into "je .not_enabled".

Octocontrabass wrote:
Out of curiosity, what does your test code report if you run it before you try to disable A20? (If you're not using a bootloader like GRUB, A20 will already be disabled.)

It reported it's NOT enabled, when in fact it was. This is without me touching A20 before running the test. Howerver, I was actually trying to disable A20 before running the test, which (because the test function was doing exactly the opposite) lead it to report that A20 was enabled and so the attempts of enabling it were skipped.

Strangely enough, Bochs has the A20 line enabled by default, although I am using my own bootloader, not GRUB. Do you know why this happens? I actually remember encountering the same issue during my first attempt of writing an "OS".


Also, I really laughed when I read the reason why you said my ror was wrong, haha! That should have been word.. lol, I was rotating an 8-bit value 8 times..


Top
 Profile  
 
 Post subject: Re: Wrong code for testing the A20 line? Disable A20 in Boch
PostPosted: Sat Feb 09, 2019 12:07 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
PhantomR wrote:
Strangely enough, Bochs has the A20 line enabled by default, although I am using my own bootloader, not GRUB. Do you know why this happens?

It might be a good idea to check your bootloader in case it enables A20 and you've forgotten about it. I know I've forgotten most of what goes on in my bootloaders! Other than that, maybe Bochs has changed since the last time I messed with A20 in it? Although I think that would be considered a bug by the developers, since Bochs is supposed to emulate something resembling real hardware (from the mid-to-late 90s).


Top
 Profile  
 
 Post subject: Re: Wrong code for testing the A20 line? Disable A20 in Boch
PostPosted: Mon Feb 11, 2019 8:27 pm 
Offline

Joined: Wed Oct 31, 2018 6:15 am
Posts: 18
I really can't see any such place in my code. I even tried checking with the code snippet provided on the OSDEV wiki A20 page, but it still reported the line as being enabled by default.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: DotBot [Bot], Octocontrabass, SemrushBot [Bot] and 99 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group