Changeset 7b3b571 in mainline for kernel/genarch/src/acpi/acpi.c


Ignore:
Timestamp:
2012-01-28T14:40:18Z (12 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
dc9a3ba
Parents:
9970a5a (diff), 20de14d (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge from lp:~jakub/helenos/mm.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/genarch/src/acpi/acpi.c

    r9970a5a r7b3b571  
    3939#include <genarch/acpi/madt.h>
    4040#include <arch/bios/bios.h>
    41 #include <mm/as.h>
    4241#include <mm/page.h>
     42#include <mm/km.h>
    4343#include <print.h>
    4444
     
    9696}
    9797
    98 static void map_sdt(struct acpi_sdt_header *sdt)
    99 {
    100         page_table_lock(AS_KERNEL, true);
    101         page_mapping_insert(AS_KERNEL, (uintptr_t) sdt, (uintptr_t) sdt,
    102             PAGE_NOT_CACHEABLE | PAGE_WRITE);
    103         map_structure((uintptr_t) sdt, sdt->length);
    104         page_table_unlock(AS_KERNEL, true);
     98static struct acpi_sdt_header *map_sdt(struct acpi_sdt_header *psdt)
     99{
     100        struct acpi_sdt_header *vhdr;
     101        struct acpi_sdt_header *vsdt;
     102
     103        /* Start with mapping the header only. */
     104        vhdr = (struct acpi_sdt_header *) km_map_structure((uintptr_t) psdt,
     105            sizeof(struct acpi_sdt_header), PAGE_READ | PAGE_NOT_CACHEABLE);
     106
     107        /* Now we can map the entire structure. */
     108        vsdt = (struct acpi_sdt_header *) km_map_structure((uintptr_t) psdt,
     109            vhdr->length, PAGE_WRITE | PAGE_NOT_CACHEABLE);
     110       
     111        // TODO: do not leak vtmp
     112
     113        return vsdt;
    105114}
    106115
     
    118127                            (struct acpi_sdt_header *) (sysarg_t) acpi_rsdt->entry[i];
    119128                       
    120                         map_sdt(hdr);
    121                         if (CMP_SIGNATURE(hdr->signature, signature_map[j].signature)) {
    122                                 if (!acpi_sdt_check((uint8_t *) hdr))
     129                        struct acpi_sdt_header *vhdr = map_sdt(hdr);
     130                        if (CMP_SIGNATURE(vhdr->signature, signature_map[j].signature)) {
     131                                if (!acpi_sdt_check((uint8_t *) vhdr))
    123132                                        break;
    124133                               
    125                                 *signature_map[j].sdt_ptr = hdr;
     134                                *signature_map[j].sdt_ptr = vhdr;
    126135                                LOG("%p: ACPI %s", *signature_map[j].sdt_ptr,
    127136                                    signature_map[j].description);
     
    144153                            (struct acpi_sdt_header *) ((uintptr_t) acpi_xsdt->entry[i]);
    145154                       
    146                         map_sdt(hdr);
    147                         if (CMP_SIGNATURE(hdr->signature, signature_map[j].signature)) {
    148                                 if (!acpi_sdt_check((uint8_t *) hdr))
     155                        struct acpi_sdt_header *vhdr = map_sdt(hdr);
     156                        if (CMP_SIGNATURE(vhdr->signature, signature_map[j].signature)) {
     157                                if (!acpi_sdt_check((uint8_t *) vhdr))
    149158                                        break;
    150159                               
    151                                 *signature_map[j].sdt_ptr = hdr;
     160                                *signature_map[j].sdt_ptr = vhdr;
    152161                                LOG("%p: ACPI %s", *signature_map[j].sdt_ptr,
    153162                                    signature_map[j].description);
     
    187196        LOG("%p: ACPI Root System Description Pointer", acpi_rsdp);
    188197       
    189         acpi_rsdt = (struct acpi_rsdt *) ((uintptr_t) acpi_rsdp->rsdt_address);
     198        uintptr_t acpi_rsdt_p = (uintptr_t) acpi_rsdp->rsdt_address;
     199        uintptr_t acpi_xsdt_p = 0;
     200
    190201        if (acpi_rsdp->revision)
    191                 acpi_xsdt = (struct acpi_xsdt *) ((uintptr_t) acpi_rsdp->xsdt_address);
    192        
    193         if (acpi_rsdt)
    194                 map_sdt((struct acpi_sdt_header *) acpi_rsdt);
    195        
    196         if (acpi_xsdt)
    197                 map_sdt((struct acpi_sdt_header *) acpi_xsdt);
     202                acpi_xsdt_p = (uintptr_t) acpi_rsdp->xsdt_address;
     203       
     204        if (acpi_rsdt_p)
     205                acpi_rsdt = (struct acpi_rsdt *) map_sdt(
     206                    (struct acpi_sdt_header *) acpi_rsdt_p);
     207       
     208        if (acpi_xsdt_p)
     209                acpi_xsdt = (struct acpi_xsdt *) map_sdt(
     210                    (struct acpi_sdt_header *) acpi_xsdt_p);
    198211       
    199212        if ((acpi_rsdt) && (!acpi_sdt_check((uint8_t *) acpi_rsdt))) {
Note: See TracChangeset for help on using the changeset viewer.