flat assembler
Message board for the users of flat assembler.

Index > OS Construction > RSDT problem...

Author
Thread Post new topic Reply to topic
BOTOKILLER



Joined: 07 Jan 2011
Posts: 154
Location: Ukraine
BOTOKILLER 18 Jun 2011, 16:26
Hi everyone!
I want my OS to find and read ACPI table, Osdev wiki says that I need to look somewhere near 1MB point for a descryptor, but the code I wrote didnt work. How to locate the RSDP???

_________________
_______________________________
NSOS
Post 18 Jun 2011, 16:26
View user's profile Send private message Reply with quote
egos



Joined: 10 Feb 2009
Posts: 144
egos 18 Jun 2011, 21:53
See ACPI Spec.: "Finding the RSDP on IA-PC Systems"
Post 18 Jun 2011, 21:53
View user's profile Send private message Reply with quote
BOTOKILLER



Joined: 07 Jan 2011
Posts: 154
Location: Ukraine
BOTOKILLER 19 Jun 2011, 07:37
Its really fun, I found it manualy in debugger on 0E0000h
Also I found out why my code didnt work, it used 'loop RSDP_LOOP' and didnt scan for the first byte of segment 0E000h, That was exactly where the signature started!

_________________
_______________________________
NSOS
Post 19 Jun 2011, 07:37
View user's profile Send private message Reply with quote
Mac2004



Joined: 15 Dec 2003
Posts: 314
Mac2004 19 Jun 2011, 10:33
Wikipedia contains acpi information which should be helpful for you.
Acpi spec seems to be available from there.

http://en.wikipedia.org/wiki/Advanced_Configuration_and_Power_Interface

regards
Mac2004
Post 19 Jun 2011, 10:33
View user's profile Send private message Reply with quote
sinsi



Joined: 10 Aug 2007
Posts: 790
Location: Adelaide
sinsi 19 Jun 2011, 10:44
Post 19 Jun 2011, 10:44
View user's profile Send private message Reply with quote
smiddy



Joined: 31 Oct 2004
Posts: 557
smiddy 16 May 2012, 23:25
Hey BOTOKILLER,

I put this together:

Code:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ACPI memory table look up.
;;
;; I have to do this in stages. 1st I need to read the RSDP to get the XSDT, to look for other
;; tables.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

RSDPSignature:  db 'RSD PTR ',0
RSDTAddress:    dd 0
XSDTAddress:    dq 0

ACPIMemoryLookUp:

   push es
   push edi
   push eax

   mov si,ACPILookUpMessage
   call PrintString

   mov ax,0E000h        ; Need to start looking for the RSDP to get the location of the XSDT
   mov es,ax            ;   the RSDP is in the E0000h to FFFFFh area, so the search is on.
   mov edi,0            ; Start at the first byte.

.LoopToLook:

   mov eax,edi
   shl eax,24
   cmp eax,0
   jg .MoveOn
   mov al,[RSDPSignature]
   cmp byte [es:edi],al
   je .CheckTheRest

.MoveOn:

   inc edi
   cmp edi,0FFF0h
   jg .CheckSegment

.CheckTheRest:

   mov al,[RSDPSignature+1]
   cmp byte [es:edi+1],al
   jne .NotTheSame
   mov al,[RSDPSignature+2]
   cmp byte [es:edi+2],al
   jne .NotTheSame
   mov al,[RSDPSignature+3]
   cmp byte [es:edi+3],al
   jne .NotTheSame
   mov al,[RSDPSignature+4]
   cmp byte [es:edi+4],al
   jne .NotTheSame
   mov al,[RSDPSignature+5]
   cmp byte [es:edi+5],al
   jne .NotTheSame
   mov al,[RSDPSignature+6]
   cmp byte [es:edi+6],al
   jne .NotTheSame
   mov al,[RSDPSignature+7]
   cmp byte [es:edi+7],al
   jne .NotTheSame
   mov eax,[es:edi+16]              ; 32 bit physical address of the RSDT.
   mov [RSDTAddress],eax            ; 32 bit physical address of the RSDT.
   mov eax,[es:edi+24]              ; 64 bit physical address of the XSDT.
   mov [XSDTAddress],eax            ; 64 bit physical address of the XSDT.
   mov eax,[es:edi+28]              ; 64 bit physical address of the XSDT.
   mov [XSDTAddress+4],eax          ; 64 bit physical address of the XSDT.
   jmp .Done

.NotTheSame:

   inc edi
   jmp .LoopToLook

.CheckSegment:

   mov ax,es
   cmp ax,0F000h
   je .FailedToLocateRSDP
   mov ax,0F000h
   mov es,ax
   mov edi,0
   jmp .LoopToLook

.FailedToLocateRSDP:

   mov si,FailedMessage
   call PrintString

.Done:

   mov si,ESMessage
   call PrintString

   mov eax,es
   mov cl,10h
   call ToHex
   mov si,HexBuffer
   call PrintString
   mov si,TheHexAfter
   call PrintString

   mov si,EDIMessage
   call PrintString

   mov eax,edi
   mov cl,20h
   call ToHex
   mov si,HexBuffer
   call PrintString
   mov si,TheHexAfter
   call PrintString
   mov si,TheEndOfLine
   call PrintString

   cmp dword [RSDTAddress],0
   je .CheckXSDTAddress
   mov si,RSDTAddressMessage
   call PrintString
   mov eax,[RSDTAddress]
   mov cl,20h
   call ToHex
   mov si,HexBuffer
   call PrintString
   mov si,TheHexAfter
   call PrintString
   mov si,TheEndOfLine
   call PrintString

.CheckXSDTAddress:

   cmp dword [XSDTAddress],0
   je .DoTheEndOfTheLine
   mov si,XSDTAddressMessage
   call PrintString
   mov eax,[XSDTAddress+4]
   mov cl,20h
   call ToHex
   mov si,HexBuffer
   call PrintString
   mov eax,[XSDTAddress]
   mov cl,20h
   call ToHex
   mov si,HexBuffer
   call PrintString
   mov si,TheHexAfter
   call PrintString
   mov si,TheEndOfLine
   call PrintString

.DoTheEndOfTheLine:

   mov si,TheEndOfLine
   call PrintString

   pop eax
   pop edi
   pop es

   ret
    


This finds both the RSDT and XSDT addresses. However, and this is not fully tested (yet), when I look at the length of the RSDT and XSDT from their respective locations, I get weird results from Virtual PC and Virtualbox.

Did you get very far in your endeavor?
Post 16 May 2012, 23:25
View user's profile Send private message Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 618
cod3b453 17 May 2012, 20:20
For reference, VirtualBox locations are:

RSDP 000E0000
FACP 3FFF00F0
APIC 3FFF0240
DSDT 3FFF0480

(those are the ones I've parsed so far; there are plenty more) and reports ACPI v2.

----

One thing to be careful of is one VM (and theoretically some BIOS') have the signature in more than one place in the EBDA so it's probably a good idea to perform the checksum.
Post 17 May 2012, 20:20
View user's profile Send private message Reply with quote
smiddy



Joined: 31 Oct 2004
Posts: 557
smiddy 18 May 2012, 01:20
cod3b453 wrote:
For reference, VirtualBox locations are:

RSDP 000E0000
FACP 3FFF00F0
APIC 3FFF0240
DSDT 3FFF0480

(those are the ones I've parsed so far; there are plenty more) and reports ACPI v2.

----

One thing to be careful of is one VM (and theoretically some BIOS') have the signature in more than one place in the EBDA so it's probably a good idea to perform the checksum.

Well, I figured this, that it is all over the place. RSDT tends to be reasonable in size, but I get F000FF53h for the XSDT, which in reality is off target since the numbers are even, so I must be doing something wrong.

Thanks for the addresses. I'll try to verify them. I'm working to get the memory allocation information (outside of E820) and if the data spec is 2.0 versus 5.0 perhaps I need to revert some of my texts and adjust accordingly. (?)
Post 18 May 2012, 01:20
View user's profile Send private message Reply with quote
smiddy



Joined: 31 Oct 2004
Posts: 557
smiddy 19 May 2012, 01:01
Ok, I was hosing up my addressing for the XSDT, however, it seems the RSDP at E0000h has a bad addess information for the XSDT. I will have to check elsewhere in Virtualbox, VirtualPC seems to work nicely.
Post 19 May 2012, 01:01
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.