Beispiel #1
0
acpi_table_t *
acpi_get(acpi_signature_t sig)
{
	acpi_iter_t it;

	if (sig == ACPI_DSDT) {
		acpi_table_t *fadt = acpi_get(ACPI_FADT);
		return VIRTUAL(fadt->fadt.dsdt);
	}

	if (!acpi_rsdt_iter_new(&it, rsdt))
		return NULL;

	do {
		acpi_table_t *t = acpi_rsdt_iter_val(&it);
		if (t->h.acpi_signature == sig)
			return t;
	} while (acpi_rsdt_iter_next(&it));

	return NULL;
}
Beispiel #2
0
int
acpi_init(void)
{
	int i;
	uint8_t sum;
	acpi_iter_t it;
	char buf[5];

	/* Check that the rsdp is valid */
	if (*(uint64_t*)rsdp->signature != RSDP_SIGNATURE)
		return -1;

	/* Check revision */
	if (rsdp->revision > 1)
		return -1;

	/* Validate the checksum */
	for (sum = 0, i = 0; i < RSDP_SIZE(rsdp); sum += ((uint8_t*)rsdp)[i], i++);
	if (sum != 0)
		return -1;

	/* Set up the root system descriptor table */
	kprintf("RSDT_ADDR %#x\n", rsdp->rsdt_addr);
	rsdt = VIRTUAL(rsdp->rsdt_addr);

	if (!acpi_rsdt_iter_new(&it, rsdt))
		return -1;

	buf[4] = 0;
	do {
		acpi_table_t *t = acpi_rsdt_iter_val(&it);

		memcpy(buf, t->h.signature, 4);
		kprintf("%#lx %d %s\n", t, t->h.length, buf);
	} while (acpi_rsdt_iter_next(&it));

	return 0;
}
Beispiel #3
0
acpi_table_t *
acpi_rsdt_iter_val(acpi_iter_t *i)
{
	return VIRTUAL(*(uint32_t*)(i->curr));
}
Beispiel #4
0
/*
 * Function invoked by roottask on pagefault
 */
int
pager(L4_ThreadId_t tid, L4_Msg_t *msgP)
{
    send = 1;
    // Get the faulting address
    L4_Word_t addr = L4_MsgWord(msgP, 0);
    L4_Word_t physicalAddress = 0;
    L4_Word_t permission = 0;
    L4_MsgTag_t tag;
    // Alignment
    addr = (addr / PAGESIZE)*PAGESIZE;
    tag = L4_MsgMsgTag(msgP);
    L4_Word_t access_type = L4_Label(tag) & 0x07;

    //printf("pager invoked addr=%lx by %lx %lx for access 0x%lx\n", addr,L4_ThreadNo(tid),tid.raw,access_type);

    // Construct fpage IPC message
    L4_Fpage_t targetFpage = L4_FpageLog2(addr, 12);
    
    if(VIRTUAL(addr)) 
    {
      if(addr >= BASE_CODE_SEGMENT_ADDRESS) {
	//Code segment
	int inPage = isInPage(tid,targetFpage);
	if(inPage == -1) {
	  //It should be in page table so this should not happen
	  printf("Panic !!! Cannot load the code segment");
	} else {
	  physicalAddress = new_low + inPage*PAGESIZE;
	  permission = L4_FullyAccessible;
	}
      } else {
	//Heap and stack
    	int inPage = isInPage(tid, targetFpage);
    	if (inPage == -1)
    	{
	  //We need to check if the page is in swap
	    inPage = isInSwap(tid,targetFpage);
	    mapAddress(tid, targetFpage,inPage);
	    //We dont need to map any addresses here as mapAddresses maps the addresses
	    return send;
    	} else {
    	    physicalAddress = new_low+inPage*PAGESIZE;
	    targetFpage = page_table[inPage].pageNo;
	    page_table[inPage].referenced = 1;
	    if(access_type & L4_Writable) {
	      //We now need to set the dirty bit and provide read write access
	      page_table[inPage].dirty = 1;
	      permission = L4_ReadWriteOnly;
	    } else {
	      permission = L4_Readable;
	    }
    	}
    	
      }
    } else {
        // we need to map physical addresses 1:1
        physicalAddress = addr;
        if(addr < new_low) {
	        // This is beyond the low memory range ie the page table
	        // and some other addresses which is below the low range
	        permission = L4_FullyAccessible;
        } else {
	        // This would be the code segment between the new_low and high
	        permission = L4_Readable;
        }
    } 
    
    L4_Set_Rights(&targetFpage,permission);
    L4_PhysDesc_t phys = L4_PhysDesc(physicalAddress, L4_DefaultMemory);

    if ( !L4_MapFpage(tid, targetFpage, phys) ) {
        sos_print_error(L4_ErrorCode());
        printf(" Can't map page at %lx\n", addr);
    }
    return send;
}