OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Apr 18, 2024 10:40 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: problem locating RSDP
PostPosted: Wed Feb 01, 2017 6:53 am 
Offline

Joined: Wed Feb 01, 2017 6:48 am
Posts: 10
Hey,
after going through the following wiki page
http://wiki.osdev.org/RSDP

I wrote a module which should be able to locate the RSDP, but unfortunately i never seem to find "RSD PTR ", I made sure the string was carfully compared and everything.
before giving up i dumped the entire memory region to file indeed there was no RSD PTR string inside, but i did find "_SD PTR" instead.

the machine is a g580 lenovo laptop with a second gen i5 processor.

any help will be more than welcome.
thanks.


Top
 Profile  
 
 Post subject: Re: problem locating RSDP
PostPosted: Wed Feb 01, 2017 6:58 am 
Offline
Member
Member

Joined: Fri May 16, 2014 2:40 pm
Posts: 36
Are you sure that you haven't written to the memory space containing the RSDP before searching for it?


Top
 Profile  
 
 Post subject: Re: problem locating RSDP
PostPosted: Wed Feb 01, 2017 9:58 am 
Offline

Joined: Wed Feb 01, 2017 6:48 am
Posts: 10
I'm positive.


Top
 Profile  
 
 Post subject: Re: problem locating RSDP
PostPosted: Wed Feb 01, 2017 12:00 pm 
Offline
Member
Member
User avatar

Joined: Fri Oct 27, 2006 9:42 am
Posts: 1925
Location: Athens, GA, USA
The Ideapad g580 is from 2013 (and the CPU is 3rd gen, not 2nd), and has UEFI with a BIOS mode. Do you have particular need to use the BIOS mode, or can you use UEFI (which, as the wiki states, provides a direct interface to the RSDP)?

Assuming for the moment, that such a reason exists, could you please either post or give a repo link to the code in question, so we could put eyes on it for you?

_________________
Rev. First Speaker Schol-R-LEA;2 LCF ELF JAM POEE KoR KCO PPWMTF
Ordo OS Project
Lisp programmers tend to seem very odd to outsiders, just like anyone else who has had a religious experience they can't quite explain to others.


Top
 Profile  
 
 Post subject: Re: problem locating RSDP
PostPosted: Wed Feb 01, 2017 2:10 pm 
Offline

Joined: Wed Feb 01, 2017 6:48 am
Posts: 10
the problem is that i need code which works both for windows and linux, and more important, the code needs to be as os independent as possible, this is why i use old bios mode.
unfortunately i cannot post full code, but the relevant snippets can be seen below. it works on every machine tested other than that old g580.

(updated to include ebda code)

Code:

#define RSDP_BASE_1  0xE0000
#define RSDP_END_1   0xFFFFF
#define BIOS_EBDA_PA 0x40E

#define RSDP_SIG "RSD PTR "
#define RSDT_SIG "RSDT"
#define XSDT_SIG "XSDT"
#define APIC_SIG "APIC"


static PRSDP_DESC scan_for_rsdp (char* start, UINT32 length)
{
    char* end = start + length;

    for (; start < end; start += 16)
    {
        if (!TPmemcmp(start, RSDP_SIG, sizeof(RSDP_SIG) -1))
            return (PRSDP_DESC)start;
    }
    return NULL;
}

void* map_physical_region_cached(UINT64 base, size_t size)
{
    return ioremap_cache(base, size);
}

BOOLEAN get_acpi_table(const char* sig, PACPI_TBL* out_tbl, UINT32* out_tbl_size)
{
   PRSDP_DESC p;
   char *rsdp = NULL;

   rsdp = (char*)map_physical_region_cached(RSDP_BASE_1, RSDP_END_1 - RSDP_BASE_1);
   if (!rsdp)
       goto ebda;

   if ((p = scan_for_rsdp(rsdp, RSDP_END_1 - RSDP_BASE_1)) == NULL)
        goto ebda;

   goto found;
ebda:
   {
      UINT16 ebda_rm_segment = *(u16*)map_physical_region_cached(0x40E,2);
      rsdp = (char*)map_physical_region(((UINT32)ebda_rm_segment)*16,1024);

      if (!rsdp)
        return FALSE;

       if ((p = scan_for_rsdp(rsdp, 1024)) == NULL)
         return FALSE;   
   }
found:
   //rest of the code
}


Last edited by algawi86 on Wed Feb 01, 2017 2:17 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: problem locating RSDP
PostPosted: Wed Feb 01, 2017 2:11 pm 
Offline
Member
Member

Joined: Wed Oct 12, 2016 11:32 am
Posts: 34
Location: At my PC
Sounds like bad ram to me. Some bits are flipped when they shouldn't.
Code:
R        _
01010010 01011111


Top
 Profile  
 
 Post subject: Re: problem locating RSDP
PostPosted: Wed Feb 01, 2017 2:17 pm 
Offline
Member
Member
User avatar

Joined: Sun Sep 19, 2010 10:05 pm
Posts: 1074
You may also want to check the BIOS settings. There may be a setting that disables ACPI, and changing the first character of the pointer table may be the BIOS's way of "disabling" all ACPI support.

My gut feeling is that the problem is going to be something simple like this, because this functionality is pretty straight forward.

Maybe your TPmemcmp function is broken.

Why are you subtracting one from the RSDP_SIG size?

_________________
Project: OZone
Source: GitHub
Current Task: LIB/OBJ file support
"The more they overthink the plumbing, the easier it is to stop up the drain." - Montgomery Scott


Top
 Profile  
 
 Post subject: Re: problem locating RSDP
PostPosted: Wed Feb 01, 2017 2:19 pm 
Offline

Joined: Wed Feb 01, 2017 6:48 am
Posts: 10
so i wont compare the NULL terminator.

sizeof(char[]) = strlen(char[])+1

regarding memory issues or ACPI disable, i'll check it.

thanks


Top
 Profile  
 
 Post subject: Re: problem locating RSDP
PostPosted: Wed Feb 01, 2017 2:22 pm 
Offline
Member
Member
User avatar

Joined: Sun Sep 19, 2010 10:05 pm
Posts: 1074
Hmm.. You might also want to try hard coding the length to 8, just to eliminate that as a possible issue. (Temporarily)

_________________
Project: OZone
Source: GitHub
Current Task: LIB/OBJ file support
"The more they overthink the plumbing, the easier it is to stop up the drain." - Montgomery Scott


Top
 Profile  
 
 Post subject: Re: problem locating RSDP
PostPosted: Wed Feb 01, 2017 2:26 pm 
Offline
Member
Member
User avatar

Joined: Sat Jan 15, 2005 12:00 am
Posts: 8561
Location: At his keyboard!
Hi,

robbiedobbie wrote:
Are you sure that you haven't written to the memory space containing the RSDP before searching for it?
algawi86 wrote:
I'm positive.


I'd write an "absolute bare minimum boot test" to check that nothing (including code you didn't write if you're using something like (e.g.) GRUB) has modified it before your code searched. If you know the address where you expect to find it, it should be relatively easy to write a "cmp [es:address],..." boot sector.


Cheers,

Brendan

_________________
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.


Top
 Profile  
 
 Post subject: Re: problem locating RSDP
PostPosted: Wed Feb 01, 2017 2:28 pm 
Offline
Member
Member
User avatar

Joined: Sat Dec 27, 2014 9:11 am
Posts: 901
Location: Maadi, Cairo, Egypt
The RSDP doesn't have a null terminator. The first field in it in the ASCII characters 'RSD PTR ' (notice the last space) but it doesn't have a null terminator. The size of this signature is 8 on all PCs and thus should be hard-coded; you don't need strlen() for ACPI detection. Right after it (at offset 9) is the checksum of the structure, no null terminators.

_________________
You know your OS is advanced when you stop using the Intel programming guide as a reference.


Top
 Profile  
 
 Post subject: Re: problem locating RSDP
PostPosted: Thu Feb 02, 2017 1:23 am 
Offline

Joined: Wed Feb 01, 2017 6:48 am
Posts: 10
i've checked in the machine bios and couldn't find any thing that might change or disable ACPI,
neither in GRUB boot options (didn't find acpi=off)
i also tried booting into recovery root shell with single user mode and still i couldn't find anything, couldn't find the RSDP

the only thing i can think of at the moment is that the hard drive currently in this machine was swapped from another machine with the OS still in it, could that cause the problems ?


Top
 Profile  
 
 Post subject: Re: problem locating RSDP
PostPosted: Thu Feb 02, 2017 2:04 am 
Offline

Joined: Wed Feb 01, 2017 6:48 am
Posts: 10
algawi86 wrote:
i've checked in the machine bios and couldn't find any thing that might change or disable ACPI,
neither in GRUB boot options (didn't find acpi=off)
i also tried booting into recovery root shell with single user mode and still i couldn't find anything, couldn't find the RSDP

the only thing i can think of at the moment is that the hard drive currently in this machine was swapped from another machine with the OS still in it, could that cause the problems ?



I've double checked the hdd thing, when booting from a live usb of mint, i still can't find that table.


Top
 Profile  
 
 Post subject: Re: problem locating RSDP
PostPosted: Thu Feb 02, 2017 2:08 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5137
Have you tried looking for the table without booting an OS?


Top
 Profile  
 
 Post subject: Re: problem locating RSDP
PostPosted: Thu Feb 02, 2017 2:25 am 
Offline
Member
Member
User avatar

Joined: Sat Jan 15, 2005 12:00 am
Posts: 8561
Location: At his keyboard!
Hi,

algawi86 wrote:
i also tried booting into recovery root shell with single user mode and still i couldn't find anything, couldn't find the RSDP


Why did you try this? All OSs can and will modify and/or trash thousands of things before anything happens in user-space at all; and ACPI tables were deliberately designed to use memory that is freed/recycled/reused by the OS (a special "ACPI reclaimable" area type was added by to the firmware's memory map by the ACPI specification specifically for this reason).

algawi86 wrote:
the only thing i can think of at the moment is that the hard drive currently in this machine was swapped from another machine with the OS still in it, could that cause the problems ?


If you are an OS developer (and therefore you wrote all the OS's code yourself) then you would know if it does/doesn't matter for your OS. If you're an application/utility developer (using a forum intended for OS developers and not intended for application developers); then all OSs can and will modify and/or trash thousands of things before anything happens in user-space at all.


Cheers,

Brendan

_________________
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], DotBot [Bot] and 85 guests


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 post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group