flat assembler
Message board for the users of flat assembler.
Index
> OS Construction > cpu speed, memory, and keyboard |
Author |
|
odrene.koleno 23 Mar 2005, 09:18
Hi,
about the ram... try this thing Code: getamountofram: push ebx ecx edi ;nastavi nejvyssi bit edi a ecx na 1 mov edi,80000000h mov ecx,edi ;zacatak cyklu .znovu: ;kdyz se testuje 10. bit skonci, skok na konec ;(snad je kazda ramka v PC vetsi nez 1024 bajtu) cmp ecx,400h jz .konec ;vlastni testovani adresy mov ebx,[edi-4] mov dword [edi-4],10101010101010101010101010101010b mov eax,[edi-4] mov [edi-4],ebx ;snizeni bitu shr ecx,1 ;zjistovani jestli test adresy skoncil spravne cmp eax,10101010101010101010101010101010b jnz .nic ;jestli jo, zkusi se vice ramky add edi,ecx jmp .znovu .nic: ;jestli ne, prekvapive se zkusi mene ramky sub edi,ecx jmp .znovu .konec: sub edi,400h mov dword [ramsize],edi pop edi ecx ebx ret ;sem se uklada velikost ramky ramsize dd 0 Sorry for text in comments its in czech language. if you dont understant the code, say it to me and I can provide more explanation. And two more things. You should execute this code in pmode but before you turn on paging. And also you should have in DS rw selector which covers 0B to 4GB ram. |
|||
23 Mar 2005, 09:18 |
|
f0dder 23 Mar 2005, 10:27
odrene, scanning for memory like that is NOT safe - consider things like memory mapped hardware. The way to do it is to use BIOS calls to get the memory map before going to pmode; first you should try the 0xE820 memory map call. If that fails, try 0xE801 which returns a 32bit memory size, and if that fails, finally try 0x88 which is limited to 64meg max.
consumed, are you sure it's this particular code that is causing the triple fault? Or perhaps it's because there's some interrupt happening on your real machine that you haven't set up a handler for? (try masking out interrupts + doing a CLI). |
|||
23 Mar 2005, 10:27 |
|
odrene.koleno 23 Mar 2005, 11:28
f0dder:
OK, you're right. But I thing that (maybe) all memory mapped hardware use lower part of ram below 1MB so I can limit scan from 1MB to 4GB. Just change "cmp ecx,400h" to "cmp ecx,100000h" at the begining of function. One more amount of memory test. Size of ram can be determinated via cmos: Code: macro hw.cmos.nactiBajt { out 70h,al jmp $+2 jmp $+2 jmp $+2 in al,71h } hw.ram.zjistiVelikost.cmos: push ebx xor eax,eax ;nacteni zakladni pameti z cmos v kB mov al,16h hw.cmos.nactiBajt mov ah,al mov al,15h hw.cmos.nactiBajt cmp eax,280h jnz .konec ;nacteni rozsirene pameti z cmos zase v kB mov al,18h hw.cmos.nactiBajt mov ah,al mov al,17h hw.cmos.nactiBajt ;pridani 1MB k rozsirene pameti add eax,400h .konec: ;z kilobajtu na bajty mov ebx,400h mul ebx mov dword [ramsize],eax pop ebx ret ramsize dd 0 But it's limited to 64MB |
|||
23 Mar 2005, 11:28 |
|
f0dder 24 Mar 2005, 15:41
Quote:
Nope, most hardware in fact uses very high adresses, in the gigabyte range. I must confess that I'm not sure whether the memory mapped ranges are activated by default, or if it requires PCI initialization - but I certainly wouldn't detect available memory with a scan like that, when there's BIOS functions that work well |
|||
24 Mar 2005, 15:41 |
|
DennisCGc 26 Mar 2005, 20:56
about the cpu speed: http://www.mega-tokyo.com/osfaq2/index.php/How%20can%20I%20tell%20CPU%20speed%20%3F
HTH. |
|||
26 Mar 2005, 20:56 |
|
Consumed 27 Mar 2005, 00:22
Thanks for the help. I knew about the BIOS interrupts, but the bootloader I use (bootf02 @ osdever.net) sets up pmode before it jumps to my kernel, which is why I was looking for a pmode-savvy way of doing it. I suppose I'll write my own bootcode now. On a note, I don't think it's the port that's doing it, because I've tried some other code that uses ports (e.g. remapping the PIC) and it triple's my pc too. DennisCGc: I'm having a bit of a hard time understanding how to use that code (possibly 'cause I'm not that good at asm...). Could you provide me a complete example of how to use it? Thanks.
|
|||
27 Mar 2005, 00:22 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.