Page 1 of 1

Do I need to use the second dwords in int 15h in 32bit?

Posted: Sat Apr 16, 2011 12:27 pm
by shedokan
I'm trying to use int 15h ax = 0xE820, but I see everything is in qwords, so do I need to use the second word in base address and length?

Because from what I understand it was done to support 64bit aswell, but I am not going to use 64bit.

Thanks.

Re: Do I need to use the second dwords in int 15h in 32bit?

Posted: Sat Apr 16, 2011 4:34 pm
by Owen
...If you don't know it, how are you going to discard records for memory above the 4GB barrier?

(And you're assuming you never support PAE)

Re: Do I need to use the second dwords in int 15h in 32bit?

Posted: Sun Apr 17, 2011 3:11 am
by shedokan
But on an 32bit architecture I can't even address locations higher than 4Gb(without using segmentation I think), so why would I need to even care about those?

Thanks.

Re: Do I need to use the second dwords in int 15h in 32bit?

Posted: Sun Apr 17, 2011 3:58 am
by Combuster
Because you don't want to use ram from 0G to 4G when its actually from 4G to 8G?

Re: Do I need to use the second dwords in int 15h in 32bit?

Posted: Sun Apr 17, 2011 5:06 am
by Brendan
Hi,
shedokan wrote:But on an 32bit architecture I can't even address locations higher than 4Gb(without using segmentation I think), so why would I need to even care about those?
"32-bit architecture" mostly just means the general purpose registers are 32-bit (although different people use different terminology, depending on what mood they're in and what they're trying to sell). It doesn't mean that physical addresses can't be something completely different.

80x86 has supported 36-bit physical addresses since the original Pentium CPUs were released in 1993.


Cheers,

Brendan

Re: Do I need to use the second dwords in int 15h in 32bit?

Posted: Sun Apr 17, 2011 12:51 pm
by shedokan
So what is the maximum values a 32bit bios will give me?
Because it's impossible to manage all the memory as if it was 64bit on a 32bit processor(or is it?).

Thanks.

PS: by 32bit and 64bit I mean the values I can pass to the processor as addresses, so a 32bit processor with GDT and paging will have a limit of addressable memory of the max value a 32bit register can hold.

Re: Do I need to use the second dwords in int 15h in 32bit?

Posted: Sun Apr 17, 2011 2:42 pm
by Combuster
If there's memory above 4G, you won't access it with legacy paging or without paging at all - it will just be wasted. You still have to check the full 64 bits to see if they actually fall within your "inferior" scheme, and discard what you can't use.

Re: Do I need to use the second dwords in int 15h in 32bit?

Posted: Mon Apr 18, 2011 12:56 am
by shedokan
But is it possible for a computer with only 32bit instructions to have more than 4gb memory? And if so what is the max this kind of computer could have?

And I am fine with my OS not being supported on processors that support 64bit instructions, I don't have that kind of computer so there's no real way for me to test it without bochs and that would also be too much work wasted(for now).

Thanks.

Re: Do I need to use the second dwords in int 15h in 32bit?

Posted: Mon Apr 18, 2011 1:22 am
by Combuster
shedokan wrote:So no matter what I do the computer can still have more memory than I would support?
shedokan wrote:I am not going to use 64bit.
It's not a matter of what you do, it's a matter of what you refuse to do. No paging gives 32 bits of physical addresses. Legacy paging gives 32 bits. PAE gives 36. PSE36 gives 36. Long mode gives the full width of the address bus. You just make your choice. You have all the keywords to get the necessary information from the manuals.
If for instance I have a coumputer with 8gb ram is there a possibility that drivers will be put in the area after 4gb?
Drivers (or modules in general) are your code. Your actions put them somewhere, whether directly or by your choice of bootloader.

Re: Do I need to use the second dwords in int 15h in 32bit?

Posted: Mon Apr 18, 2011 3:51 am
by shedokan
Thanks all, I think I get everything about memory spport, it's up to what I support because 64bit processors have backwards compability right?(I take it from Long mode which has to be enabled for 64bit support and before it is enabled it's in 32bit or real mode)

Drivers (or modules in general) are your code. Your actions put them somewhere, whether directly or by your choice of bootloader.
What you say contradicts this from Memory_Map(x86):
start: C000000 (sometimes)
end: FFFFFFF
size: 4000000
region/exception: various (unusable except by drivers)
description: PnP NVRAM?, LAPIC, BIOS, ...
and:
There are likely to be regions of it that contain memory mapped hardware, that nothing but a device driver should ever access
From these two examples it looks to me as if the drivers or something else but me put them there.


So what is right here?

Thanks

Re: Do I need to use the second dwords in int 15h in 32bit?

Posted: Mon Apr 18, 2011 5:25 am
by Brendan
Hi,
shedokan wrote:What you say contradicts this from Memory_Map(x86):
start: C000000 (sometimes)
end: FFFFFFF
size: 4000000
region/exception: various (unusable except by drivers)
description: PnP NVRAM?, LAPIC, BIOS, ...
and:
There are likely to be regions of it that contain memory mapped hardware, that nothing but a device driver should ever access
From these two examples it looks to me as if the drivers or something else but me put them there.

So what is right here?
That table has so many errors it's not funny - consider the differences between "C000000", "0x0C000000" and "0xC0000000" for a start.

What the table is trying to say is that the area from <somewhere> (e.g. maybe 0xC0000000, but it depends on motherboard, devices present, etc) to 0xFFFFFFFF is reserved for memory mapped PCI devices (e.g. the video card's display memory) and the motherboard/chipset's use (e.g. HPET, IO APIC, local APICs, firmware/ROM, etc); and therefore this area shouldn't be touched (except by the device drivers for the devices that happen to be mapped into this area).

The device drivers themselves need to be in RAM, not in the area reserved for memory mapped devices, even though they (may) access the devices via. the the area reserved for memory mapped devices.

Note to others: I'm about to mess with that table, and the comments above probably refer to the old wiki page and not the (future) new page - use the "history" tab to see what it was beforehand.



Cheers,

Brendan

Re: Do I need to use the second dwords in int 15h in 32bit?

Posted: Mon Apr 18, 2011 5:29 am
by Owen
Combuster wrote:
shedokan wrote:So no matter what I do the computer can still have more memory than I would support?
shedokan wrote:I am not going to use 64bit.
It's not a matter of what you do, it's a matter of what you refuse to do. No paging gives 32 bits of physical addresses. Legacy paging gives 32 bits. PAE gives 36. PSE36 gives 36. Long mode gives the full width of the address bus. You just make your choice. You have all the keywords to get the necessary information from the manuals.
PAE also gives you the full width of the address bus (Remember that long mode paging is PAE paging, 'just more')

PSE36 gives you more address bits to play with as well these days (Though not the full architecturally defined 52-bits)
shedokan wrote:Thanks all, I think I get everything about memory spport, it's up to what I support because 64bit processors have backwards compability right?(I take it from Long mode which has to be enabled for 64bit support and before it is enabled it's in 32bit or real mode)
AMD64 CPUs start in real mode, just like legacy IA-32 ones.
shedokan wrote:
Drivers (or modules in general) are your code. Your actions put them somewhere, whether directly or by your choice of bootloader.
What you say contradicts this from Memory_Map(x86):
start: C000000 (sometimes)
end: FFFFFFF
size: 4000000
region/exception: various (unusable except by drivers)
description: PnP NVRAM?, LAPIC, BIOS, ...
and:
There are likely to be regions of it that contain memory mapped hardware, that nothing but a device driver should ever access
From these two examples it looks to me as if the drivers or something else but me put them there.


So what is right here?

Thanks
You are confusing drivers and devices. Drivers are pieces of code that you (or somebody else) writes for your operating system (or some multi-operating system standard). Devices are pieces of hardware which will be put (initially, at least) wherever the BIOS wants to put them.

There are some conventions as to where devices go (Generally, unless they fall into one of the <1MB legacy holes, just below the 4GB barrier). You can relocate them if the BIOS screws up their placement... but in general, BIOSes these days put them in reasonable places. Even if you use long mode or PAE to access more than 32-bits of addressing, you probably should not move them above 4GB (Because not all devices support >32-bit addressing, even if the device you're moving does, it prevents another device from performing DMA directly into its onboard memory if said other device does not support >32-bit addressing {Direct device to device DMA is rarely used but is not non-existant. A relatively common use of it is transferring images directly from a TV card's decoder to the GPU's texture RAM})

Re: Do I need to use the second dwords in int 15h in 32bit?

Posted: Mon Apr 18, 2011 5:32 am
by jal
Brendan wrote:I'm about to mess with that table
+1


JAL

Re: Do I need to use the second dwords in int 15h in 32bit?

Posted: Mon Apr 18, 2011 8:26 am
by shedokan
So it is possible to relocate the device's memory if the BIOS puts it somewhere I don't like, great that's what I wanted to know aswell.

Wer'e going a bit offtopic but I wanted to ask this one last question, how can I know where the BIOS put the devices(will it show up on one of the methods of "Detecting Memory (x86)"?

Thanks, you all helped me understand a lot more than I even asked(about processor states and all).

PS: I know what drivers and devices are, but it still showed my point.