How do i detect memory mapped devices
How do i detect memory mapped devices
I need to know what parts of memory I can use without interfering with those devices(like the video card)
Re:How do i detect memory mapped devices
yeah, id be intrested in knowing this as well.. also can this memory be paged out?
Re:How do i detect memory mapped devices
neowert: I've just answered this question in the other thread you started. Please don't start another one.
eliscool: How would you intend to "page out" a piece of hardware? Paging out refers to writing a page of memory to disk so that the page can be re-used for something else; when the original data are needed, the new data are paged out and the old data are paged in. The memory ranges of memory-mapped devices (e.g. the VGA frame buffer) don't describe user data but a window into the hardware.
eliscool: How would you intend to "page out" a piece of hardware? Paging out refers to writing a page of memory to disk so that the page can be re-used for something else; when the original data are needed, the new data are paged out and the old data are paged in. The memory ranges of memory-mapped devices (e.g. the VGA frame buffer) don't describe user data but a window into the hardware.
Re:How do i detect memory mapped devices
I mean, like if the VGA buffer starts @ 0xb8000 or something in RAM, does this get paged out? like the memory from 0xb8000 -> END_OF_BUFFER? what do you mean "window into the hardware? or do I have this wrong somehow?
Re:How do i detect memory mapped devices
I don't know what you mean by "paged out". Could you re-phrase, please?
When I say "window onto hardware", I mean that when you write to the video buffer you talk directly to the video memory on the video card, instead of some RAM inside the computer. As another example, the APIC registers are memory-mapped. You get a region of memory where each DWORD has a different function. Instead of communicating with the APIC using IN and OUT, you read and write memory addresses.
When I say "window onto hardware", I mean that when you write to the video buffer you talk directly to the video memory on the video card, instead of some RAM inside the computer. As another example, the APIC registers are memory-mapped. You get a region of memory where each DWORD has a different function. Instead of communicating with the APIC using IN and OUT, you read and write memory addresses.
Re:How do i detect memory mapped devices
so in and out is actually used for a different 'memory' space?
Re:How do i detect memory mapped devices
I think maybe you're mixing up address space and physical memory here.
The computer makes memory addresses by putting a combination of 1's and 0's on the 20 address lines. So it can produce addresses in the range 0->4gb. This is the address space of the machine, or address range I think I heard it called once. This bears no relation to the actual amount of memory you have in your machine.
What a memory mapped device does is arrange to have operations on a certain section of the address space directed to its own memory or registers.
So, for example, in the case of the VGA card the 64k area starting 0xB8000 in the address space corresponds to some actual video memory (Tim explained that already). So when you try to read/write to the address 0xB8000 the motherboard recognises the pattern on the 20 address lines and fools the processor into thinking that the video RAM is at that place in the address space and the processor treats it as though it were any other piece of RAM. This lets you read/write directly to the video RAM directly. The actual addresses that get mapped are beyond your control (It's done through electronics I think, not software).
Hope that's helpful, maybe someone else can explain better, or at least correct it if it is wrong.
Curufir
The computer makes memory addresses by putting a combination of 1's and 0's on the 20 address lines. So it can produce addresses in the range 0->4gb. This is the address space of the machine, or address range I think I heard it called once. This bears no relation to the actual amount of memory you have in your machine.
What a memory mapped device does is arrange to have operations on a certain section of the address space directed to its own memory or registers.
So, for example, in the case of the VGA card the 64k area starting 0xB8000 in the address space corresponds to some actual video memory (Tim explained that already). So when you try to read/write to the address 0xB8000 the motherboard recognises the pattern on the 20 address lines and fools the processor into thinking that the video RAM is at that place in the address space and the processor treats it as though it were any other piece of RAM. This lets you read/write directly to the video RAM directly. The actual addresses that get mapped are beyond your control (It's done through electronics I think, not software).
Hope that's helpful, maybe someone else can explain better, or at least correct it if it is wrong.
Curufir
Re:How do i detect memory mapped devices
Right, except that 20 address lines only give you 1MB (2[sup]20[/sup] = 1 megabyte). For 4GB you need 32 address lines. Pentium Pro and later processors use a 36-bit address line which can access 64GB.
Re:How do i detect memory mapped devices
Thanks curufir, that really cleared it up... one more thing though, so its not possible to use/access that actual physical RAM located at 0xB8000 since its mapped to the vid card?
Re:How do i detect memory mapped devices
No, accessing the video RAM is fine. That's the point: the video card decodes memory accesses between A0000 and BFFFF and directs them to its own on-board memory.
Re:How do i detect memory mapped devices
Ok eliscool, I read your post, went away, and then figured out what you might be getting at. It's a guess to your meaning so if I'm not getting it then please correct me.
What I think you're asking is this.
If my computer has 1mb of RAM in it, and 64k of the address space around 0XB8000 is mapped as the video RAM what has happened to the 64k of computer RAM? Do you simply lose the 64k because you access the video RAM instead of the computer RAM?
I think the answer to that is no, you don't lose 64k of computer RAM. What should happen is that the motherboard will magically shift the memory around so that effectively the 64k that can't be used because the video RAM is mapped there appears at the end of the computer memory. So you have all the memory mapped devices in the address space and then fill up the holes with the computer's memory.
The reason I say think this is what occurs is because I took a look around and couldn't find any definitive answers to the question anywhere. The reason I say it isn't wasted is because back in the good old days of the 8086 64k of memory was entirely too much to just throw away, a solution which involved being able to memory map without losing RAM would have been found. So this is more a logical argument than anything definitive. If someone knows the truth of it then hopefully they can correct this.
Curufir
What I think you're asking is this.
If my computer has 1mb of RAM in it, and 64k of the address space around 0XB8000 is mapped as the video RAM what has happened to the 64k of computer RAM? Do you simply lose the 64k because you access the video RAM instead of the computer RAM?
I think the answer to that is no, you don't lose 64k of computer RAM. What should happen is that the motherboard will magically shift the memory around so that effectively the 64k that can't be used because the video RAM is mapped there appears at the end of the computer memory. So you have all the memory mapped devices in the address space and then fill up the holes with the computer's memory.
The reason I say think this is what occurs is because I took a look around and couldn't find any definitive answers to the question anywhere. The reason I say it isn't wasted is because back in the good old days of the 8086 64k of memory was entirely too much to just throw away, a solution which involved being able to memory map without losing RAM would have been found. So this is more a logical argument than anything definitive. If someone knows the truth of it then hopefully they can correct this.
Curufir
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:How do i detect memory mapped devices
That seems to be too magical to my knowledge of computers ...Curufir wrote:
The reason I say think this is what occurs is because I took a look around and couldn't find any definitive answers to the question anywhere. The reason I say it isn't wasted is because back in the good old days of the 8086 64k of memory was entirely too much to just throw away, a solution which involved being able to memory map without losing RAM would have been found. So this is more a logical argument than anything definitive. If someone knows the truth of it then hopefully they can correct this.
Curufir
1. when you had a 8086, only the first 640K of the address space could receive RAM, the memory above was used for BIOS ROM (Fxxx), video ROM (Cxxxx), video RAM (Axxx & Bxxx). The remaining area (Dxxx & Exxx) were left empty for other extension cards such as the EMM card, etc.
2. when the first 286 appeared with their small MB of extended memory, it wasn't rare to see a computer with 2048+640 Kb of memory, which makes me believe that there was still no main RAM under the classic area ...
3. with the 486 (or maybe already in 386, can't remember ...), the "shadow ram" appeared : as we had +8Mb of memory organised in 2 banks of 4MB chunks, it became plain silly to still keep a separate 640KB memory chip : large chips were cheaper and the physical RAM under the ROM areas was filled with a copy of the rom at boot time (RAM has definitively a faster read access than ROM therefore, imho, these system waste the 128KB of physical memory that should be at Axxx & Bxxx ...
The other reason i think it works this way is that the "filling the gaps" scheme you propose would require a complete remapping of the addresses, and i don't beleive such a chip could be done quickly enough ...
Now there is a simple way to know who's true : just pick a box that claims to have 32Mb of memory and try to access 0x00200001 ... if you can't write into it and if it reads as 0x00400000, then there is no gap filling and the video ram is hiding 128K of physical ram
Note that there
Re:How do i detect memory mapped devices
Well I did say I was working on logic . I get what you're saying, but I don't think the electronics has to be any more or less complicated than that which you're already using to map the video ram onto the address space. Seeing as you already know the areas that are reserved for all these things then making the real ram flow around them becomes a lot simpler.
I'm actually kinda curious as to what the real answer is now. Throwing away the ram mapped to video, the io ports etc just seems extremely wasteful. Then again, as you said, is it really worth the extra complexity to get it back? Hmm, wonder if it would show up on a memory map.
Curufir
I'm actually kinda curious as to what the real answer is now. Throwing away the ram mapped to video, the io ports etc just seems extremely wasteful. Then again, as you said, is it really worth the extra complexity to get it back? Hmm, wonder if it would show up on a memory map.
Curufir
Re:How do i detect memory mapped devices
Ok, it was bugging me so I hit the research trail. There's loads of faqs/lectures telling you what memory mapped devices are/do, but not a whole heck of a lot telling you what happens to the physical memory.
Here's what I managed to pick out of the chaos.
Pype.Clicker is right, you lose the memory that's assigned to the memory mapped devices, it's gone, forget it ever existed.
Some processors, including some intel processors, have a seperate IO address space, so you don't lose anything because of the IO devices.
Some of the older OS used a technique of searching for the holes in memory mapping in the 384k aread at the top of the first megabyte, and then reclaimed unused holes for themselves (This pretty much killed the idea that motherboards were memory mapping without losing memory).
So basically Pype got it right, but in my defense I was thinking logically and the people who let you lose the RAM designed the A20 address line...enough said ;D
Curufir
Here's what I managed to pick out of the chaos.
Pype.Clicker is right, you lose the memory that's assigned to the memory mapped devices, it's gone, forget it ever existed.
Some processors, including some intel processors, have a seperate IO address space, so you don't lose anything because of the IO devices.
Some of the older OS used a technique of searching for the holes in memory mapping in the 384k aread at the top of the first megabyte, and then reclaimed unused holes for themselves (This pretty much killed the idea that motherboards were memory mapping without losing memory).
So basically Pype got it right, but in my defense I was thinking logically and the people who let you lose the RAM designed the A20 address line...enough said ;D
Curufir