flat assembler
Message board for the users of flat assembler.
Index
> OS Construction > Protected Mode Memory |
Author |
|
tantrikwizard 05 Mar 2007, 11:28
Not sure why this is happening. What is the purpose of the code? Is there another way to work the algorithm?
|
|||
05 Mar 2007, 11:28 |
|
Navic 05 Mar 2007, 12:12
I have figured out that the function does work - there was an error in my printing function which is fixed..... The problem now is the huge output. It will return 100000000h - 24 which just happens to be the beginning of the algorithm I'm using (1MB intervals, at the end subtract 24). I can't tell why the code will loop this many times. Would it be easier if I pasted the code here?
|
|||
05 Mar 2007, 12:12 |
|
vid 05 Mar 2007, 12:56
yes, paste the code please
|
|||
05 Mar 2007, 12:56 |
|
Navic 05 Mar 2007, 18:20
I just tried this on my Athlon64 2800 and it gave the bogus value, so my two AMD boxes report bogus sizes, and my single Intel box reports the correct amount of RAM.... dunno if that has anything to do with it.
The GDT entry is 4GB limit, R/W. If there is any other known way to determine the total amount of physical RAM in protected mode, it would be much appreciated if that function was shared. Code: RAM_Size: mov eax,10h mov ds,eax mov es,eax mov eax,1000000 mov edi,eax mov esi,eax xor ecx,ecx mov eax,0AAh rep_mem: stosb lodsb cmp eax,0AAh jne set_var inc ecx add esi,999998 add edi,999998 jmp rep_mem set_var: lea edi,[mbram] mov eax,ecx sub eax,24 stosd |
|||
05 Mar 2007, 18:20 |
|
DOS386 05 Mar 2007, 20:52
Code: mov eax,1000000 Code: add esi,999998 Where do these values come from ??? How many bytes has one MB ? Quote: at the end subtract 24 Why ? Code: lea edi,[mbram] mov eax,ecx sub eax,24 stosd There might be simpler ways to do ... Finally, you would have to save and compare at least 2 different values to get sure that RAM exists at that address ... _________________ Bug Nr.: 12345 Title: Hello World program compiles to 100 KB !!! Status: Closed: NOT a Bug |
|||
05 Mar 2007, 20:52 |
|
Japheth 05 Mar 2007, 21:11
1.000.000 in decimal is F4240 in hex, which, if the base of your descriptors is 0, is a ROM address and might confuse your algorithm.
|
|||
05 Mar 2007, 21:11 |
|
tantrikwizard 05 Mar 2007, 21:26
Navic wrote: If there is any other known way to determine the total amount of physical RAM in protected mode, it would be much appreciated if that function was shared. |
|||
05 Mar 2007, 21:26 |
|
DOS386 05 Mar 2007, 21:48
Quote: ROM address and might confuse your algorithm Right ... will return 0 !!! Start testing at $180000 (1.5 MB) and jump in $80000 (512 KB) steps ... and reject result if it is $180000 (would mean less than 2 MB RAM or algo failure) And, still, test 2 values per address ... _________________ Bug Nr.: 12345 Title: Hello World program compiles to 100 KB !!! Status: Closed: NOT a Bug |
|||
05 Mar 2007, 21:48 |
|
f0dder 05 Mar 2007, 23:39
You shouldn't do memory detection this way... ROM, memory mapped devices, etc. Query the BIOS instead, e820.
|
|||
05 Mar 2007, 23:39 |
|
tantrikwizard 06 Mar 2007, 05:48
f0dder wrote: You shouldn't do memory detection this way... ROM, memory mapped devices, etc. Query the BIOS instead, e820. |
|||
06 Mar 2007, 05:48 |
|
Navic 06 Mar 2007, 07:10
Taking into account most systems that are around today have large amounts of RAM, would testing every 32MBs work? I understand there are I/O, PCI, ROM, etc spaces, but I was hoping to find a test value that would either skip these spaces..... not very probable I guess? My values were based on 1000000 starting, and since I used 0AAh to test, an increment should be 1000000-2 correct?
|
|||
06 Mar 2007, 07:10 |
|
f0dder 06 Mar 2007, 10:16
tantrikwizard wrote:
Afaik, PCI management is done through BIOS calls? (perhaps only to get a 32bit callable entrypoint - haven't done PCI setup myself). You can either query the e820 memory map before entering pmode, or you can use v86 to thunk down. Navic: better be safe and do it the e820 way, and falling back to older mechanisms in case bios doesn't support e820. There's a few broken BIOSes that don't support e820 correctly, but IMHO those should just be ignored, unless you want to end up with a bloated "support everything and have no specific goals" kernel. _________________ - carpe noctem |
|||
06 Mar 2007, 10:16 |
|
Navic 06 Mar 2007, 17:37
Well this question will show how much of a newbie I am...... what is the e820 map?
|
|||
06 Mar 2007, 17:37 |
|
LocoDelAssembly 06 Mar 2007, 22:28
|
|||
06 Mar 2007, 22:28 |
|
Navic 07 Mar 2007, 17:59
I've found a good algorithm for physical memory detection:
Code: ;By Jeff Leyda xor edx,edx ;MB counter mov eax,0cafef00dh ;test data mov edi,100000 ;start testLoop: mov ebx, [edi] ; save current memory contents mov [edi], eax ; write memory cmp [edi], eax ; did it stick? jnz endoftest mov [edi], ebx ; restore memory add edi, 1024*1024 ; next mb inc edx ; update counter jmp testLoop endoftest: lea edi,[mbram] mov eax,edx stosw This works on all my systems. |
|||
07 Mar 2007, 17:59 |
|
f0dder 07 Mar 2007, 23:13
Again: don't do it this way. Please, think of the kittens!
|
|||
07 Mar 2007, 23:13 |
|
tom tobias 08 Mar 2007, 09:02
kittens ....
The E820 BIOS method is a real mode solution. If this were a purely protected mode task, then how will E820 be useful? |
|||
08 Mar 2007, 09:02 |
|
ilya 07 May 2007, 13:34
I think it possible to go over all PCI devices and get the BARs largest address + range will be equal to min RAM available.
|
|||
07 May 2007, 13:34 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.