flat assembler
Message board for the users of flat assembler.
Index
> OS Construction > How to find existence of memory? Goto page 1, 2 Next |
Author |
|
crc 03 Mar 2004, 16:00
There is a lot of detailed information here: http://www.mega-tokyo.com/osfaq2/index.php/How%20do%20I%20determine%20the%20amount%20of%20RAM%3F.
|
|||
03 Mar 2004, 16:00 |
|
anton 13 May 2004, 13:31
You may get memory map using PNP BIOS (It presented as system device).
|
|||
13 May 2004, 13:31 |
|
Gomer73 13 May 2004, 18:28
Looked at the program to probe for memory.
Since it was mainly in asm, it is too bad he didn't make it all in asm, would have been easier to understand. |
|||
13 May 2004, 18:28 |
|
f0dder 13 May 2004, 21:19
does't really matter if there's asm or C there - you should directly probe the memory, it's not very healthy if you accidentally hit memory mapped devices.
|
|||
13 May 2004, 21:19 |
|
Gomer73 13 May 2004, 22:08
Can you give some examples?
Are you talking about stuff that would be above the 1meg area? Otherwise you could just start at 1 meg and have no worries. |
|||
13 May 2004, 22:08 |
|
f0dder 14 May 2004, 01:23
Yes, the 'interesting' memory-mapped stuff will be way above 1meg. I guess it depends on BIOS setting - if you have the bios "pnp resources" set to "pnp os" (the names of both these items may vary), then resources might not be assigned to PCI devices by the BIOS. But as we all should know, especially older BIOSes did things "their own way".
I might just be talking out my a$$, but I think the best thing is to test for extensions, and eventually fall back to the old "max 64meg" way of getting amount of memory in the system - if the BIOS is old enough to not detect more memory than that, there's a very good chance the system doesn't have more memory. For the very few borderline cases, you could always supply some argument to your kernel to specify the real amount of memory. Better keep it safe for the majory of systems, and require the people with "weird hardware" to do some extra fiddling - they should be used to it anyway |
|||
14 May 2004, 01:23 |
|
Gomer73 14 May 2004, 23:55
I see what you mean, here is a memory map of my computer, first number is decimal, second number is hex.
Base: 0, 0 Size: 654,336, 9FC00 Type: 1, 1 Base: 654,336, 9FC00 Size: 1,024, 400 Type: 2, 2 Base: 983,040, F0000 Size: 65,536, 10000 Type: 2, 2 Base: 1,048,576, 100000 Size: 133,156,864, 7EFD000 Type: 1, 1 Base: 134,205,440, 7FFD000 Size: 8,192, 2000 Type: 3, 3 Base: 134,213,632, 7FFF000 Size: 4,096, 1000 Type: 4, 4 Base: 4,294,901,760, FFFF0000 Size: 65,536, 10000 Type: 2, 2 The last two sections of memory would be not good if I overwrote them. It is interesting that it doesn't deal with my video memory which is at E2000000, video card doesn't use system memory, but still. Here's the code in case somebody else wants to check out the memory in their system, board won't let me attach it as a file. org 100h use16 mov ebx,0 mem_loop: mov eax,0xe820 mov edx,534d4150h mov ecx,200h mov edi,the_data push cs pop es int 15h jc done push ebx call print_cs db "Base: ",0 mov eax,[the_data] push eax call print_dec call print_cs db ", ",0 pop eax call print_hex_big call print_cs db 13,10,"Size: ",0 mov eax,[the_data+8] push eax call print_dec call print_cs db ", ",0 pop eax call print_hex_big call print_cs db 13,10,"Type: ",0 mov eax,[the_data+16] push eax call print_dec call print_cs db ", ",0 pop eax call print_hex_big call print_cs db 13,10,13,10,0 pop ebx cmp ebx,0 jne mem_loop done: call print_cs db "All finished",13,10,0 int 20h print_dec_nc: push word 0 mov ecx,1000 jmp print_dec.loop print_dec: push word 0 .zero_loop: mov ecx,3 .loop: xor edx,edx mov ebx,10 div ebx or dl,30h push dx or eax,eax jz .end_numb loop .loop push word ',' jmp .zero_loop .end_numb: pop dx or dx,dx jz .end mov ah,2 int 21h jmp .end_numb .end: ret print_hex: push ax xor eax,eax pop ax print_hex_big: push word 0 .loop: push eax and al,0fh cmp al,10 cmc adc al,30h daa mov bl,al pop eax push bx shr eax,4 or eax,eax jz print_dec.end_numb jmp .loop print_cs: pop si push ds push cs pop ds .loop: lodsb or al,al jz .end mov ah,2 mov dl,al int 21h jmp .loop .end: pop ds jmp si align 16 the_data: |
|||
14 May 2004, 23:55 |
|
bogdanontanu 15 May 2004, 12:56
Thanks, pretty Interesting for SolOS
|
|||
15 May 2004, 12:56 |
|
Gomer73 15 Jun 2004, 02:56
anton wrote: You may get memory map using PNP BIOS (It presented as system device). For Anton, can you tell me how to get a memory map using PNP BIOS in code? Not too sure how to do it. |
|||
15 Jun 2004, 02:56 |
|
Gomer73 16 Jun 2004, 15:29
OK, anybody then, does anybody know how to get a memory map using PNP BIOS?
|
|||
16 Jun 2004, 15:29 |
|
Geek 07 Jun 2005, 14:01
It might be more efficiant to use a process of elimination.
for (a very simple) example: You have the base address of VRAM, You have the address location of your OS, You also have a basic idea of the 1st. 1MB, And any other devices that may need addresses, You may be able to piece together a vague memory map that you can go by. _________________ Death is not the opposite of life, rather, it is the absence of it. |
|||
07 Jun 2005, 14:01 |
|
Scanner 07 Jun 2005, 19:20
Easy
Days of 64MB memory modules are over. So scan for memory in 64MB increments by writing to a location, and then reading from it for the value you wrote. As soon as the value you read does not match the value you wrote, the last location written to is the max memory you can access. I think that is a fair test. |
|||
07 Jun 2005, 19:20 |
|
Endre 08 Jun 2005, 05:28
Scanner wrote: Easy |
|||
08 Jun 2005, 05:28 |
|
f0dder 08 Jun 2005, 12:24
I agree with Endre - scanning for memory in the way suggested by Scanner is a bad idea.
|
|||
08 Jun 2005, 12:24 |
|
THEWizardGenius 17 Jun 2005, 04:27
Simple: If your computer starts up, you have at least 1 byte of memory installed. If no memory exists, it won't startup properly.
|
|||
17 Jun 2005, 04:27 |
|
vid 17 Jun 2005, 08:52
isn't there just some BIOS call which returns amount of memory in Kb? can't remember number, maybe some int 15h
|
|||
17 Jun 2005, 08:52 |
|
THEWizardGenius 17 Jun 2005, 16:47
INT 12h does this, however it only returns the base memory- that is,
MIN (640, total_memory). In other words, if you have more than 640k (and I bet you do!) it returns 640k. INT 15h may have something that returns other things, however, here's how you find total memory size: CMOS! However, the maximum you'll find is 66175K. It should be stored in CMOS in bytes 15h-18h. Simply add bytes 15h and 16h (a word value equal to the base memory size, which once again is usually 640k. 15h is the LSB, 16h is the MSB.) to bytes 17h and 18h (a word value equal to the base memory subtracted from the total installed memory. 17h is the LSB and 18h is the MSB). The result will be total memory installed, in KB. If you have more than 66175K or so, I have no idea how to find that. Besides, I bet if you try to read/write to memory that isn't there (for example, if you try to read the byte at 0FFFFFFFFh and you have less than 4G memory installed) then an error will occur, in the CPU or somewhere else. But I dunno, never tried this. |
|||
17 Jun 2005, 16:47 |
|
UCM 18 Jun 2005, 15:39
I'm pretty sure, that if you try to write to nonexistent memory, the CPU won't complain, just that if you try to retrieve it again, you'll either get 0 or an error.
_________________ This calls for... Ultra CRUNCHY Man! Ta da!! *crunch* |
|||
18 Jun 2005, 15:39 |
|
smiddy 19 Jun 2005, 04:07
Here is a screen capture of how I do memory detection:
Code: smiddy's OS (C) 2004, 2005. All Rights Reserved. Version 1.00.00.000000AB CPU: CPUID Instruction: GenuineIntel Pentium III (Coppermine) A20 Gate: Init KBC: 1st Test: A20 memory address line enabled... E820: 1,073,741,824 bytes. E801: 1,073,741,824 bytes. 88xx: 16,777,216 bytes. CMOS: 67,108,864 bytes. Entering UnReal Mode... Probe: 1,073,741,824 bytes. Mapping Memory 1: 1,073,741,824 installed: E820: Mapping Memory 2: Bitmap Initialized at 14MB: 1,056,964,608 bytes free for use. I use INT 15h AX=E820, then AX=E801, then AH=88, followed by CMOS and finally I probe the memory at the top of each 1 MB chunk. UCM, my experience is that you can write to non-existent memory, but you won't retrieve what you wrote. The address lines are available, but they aren't connected to anything. TheWizardGenius, up around 080000000h (2 GB) you run into areas where PCI devices place buffers. In your example, 0FFFFFFFFh, if you back that off to 0FFFFFFF0h, and jump to that location, you'll reboot the machine because BIOS is up there. I don't know all the specifics but I imagine too, that you can get the BIOS date starting at 0FFFFFFF5h...check your and see. You can read all day at every location...you just have to watch where you write to, PCI information is up near 0FC000000h too, with all the configuration registers etcetera. |
|||
19 Jun 2005, 04:07 |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.