Hello, I was wondering if there is any way to test the A20 in C, not assembly like in the Wiki. Could tell me on how do detect whether or not the A20 line/gate has been enabled?
Thanks
Testing the A20 in C
-
- Posts: 7
- Joined: Sun Jul 14, 2013 8:58 pm
Testing the A20 in C
Last edited by Someone256 on Sat Aug 24, 2013 3:10 am, edited 1 time in total.
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Testing the A20 in C
Yes, it's possible. No, we do not spoonfeed code - that's your exercise.
Re: Testing the A20 in C
volatile int test=0, *ptr=(int*)((int)&test+0x100000);
return *ptr==0&&(test=1)&&*ptr==1;
return *ptr==0&&(test=1)&&*ptr==1;
Last edited by nbdd0121 on Sun Aug 25, 2013 5:15 am, edited 1 time in total.
Re: Testing the A20 in C
This may get false alarm if the compiler decided that test is irreverent and remove it, or reorder to test ptr before setting test=0.nbdd0121 wrote:int test=0, *ptr=(int*)((int)&test+0x100000);
return *ptr==0&&(test=1)&&*ptr==1;
A better way is to scan the memory map for usable region, and write proper code to ensure compiler don't get confused.
Re: Testing the A20 in C
I just modifies 'test' to be volatile. I didn't test the code, but I am quite sure if you set -O0 it works.bluemoon wrote: This may get false alarm if the compiler decided that test is irreverent and remove it, or reorder to test ptr before setting test=0.
A better way is to scan the memory map for usable region, and write proper code to ensure compiler don't get confused.