Exemple #1
0
void arch_cpu_processor_init_2(void)
{
	acpi_init();
	x86_hpet_init();
#if _DBOS_KERNEL_HAVE_CPU_SMP
	probe_smp();
	init_lapic();
	calibrate_lapic_timer(1000);
	init_ioapic();
	set_ksf(KSF_SMP_ENABLE);
#endif
}
Exemple #2
0
void
acpi_init()
{
  ACPI_STATUS status;
  status = AcpiInitializeTables(TableArray, ACPI_MAX_INIT_TABLES, FALSE);
  LRT_Assert(status == AE_OK);
  
  madt *madt_ptr;
  status = AcpiGetTable("APIC", 0, (ACPI_TABLE_HEADER **)&madt_ptr);
  LRT_Assert(status == AE_OK);  

  uint32_t size = madt_ptr->header.Length - sizeof(madt);
  uint8_t *ptr = (uint8_t *)(madt_ptr + 1);
  uint8_t ioapics = 0;
  do {
    if (*ptr == PROCESSOR_LOCAL_APIC) {
      lapic_structure *ls = (lapic_structure *)ptr;
      size -= ls->length;
      ptr += ls->length;
      //do nothing with the structure
    } else if (*ptr == IO_APIC) {
      ioapic_structure *is = (ioapic_structure *)ptr;
      size -= is->length;
      ptr += is->length;
      init_ioapic((ioapic *)(uintptr_t)is->ioapic_address);
      LRT_Assert(++ioapics < 2);
      lrt_printf("found ioapic table\n");
    } else if (*ptr == INTERRUPT_SOURCE_OVERRIDE) {
      iso_structure *is = (iso_structure *)ptr;
      size -= is->length;
      ptr += is->length;
      lrt_printf("IRQ %d is mapped to I/O APIC input %d\n", is->source, 
		     is->global_system_interrupt);
    } else {
      //No definitions for other structures yet!
      lrt_printf("Found MADT structed unimplimented: %d\n", *ptr);
      LRT_Assert(0);
    }
  } while (size > 0);
}
Exemple #3
0
// The main function
int init(unsigned long magic, multiboot_info_t* hdr)
{
        setGDT();
        init_heap();
#ifdef SLAB
        slab_alloc_init();
#endif
        textInit();
        /**
         * \todo Make complement_heap so that it allocates memory from pte
         */
        complement_heap(&end, HEAPSIZE);
        addr_t tmp = (addr_t)hdr + offset;
        hdr = (multiboot_info_t*)tmp;

        if (magic != MULTIBOOT_BOOTLOADER_MAGIC)
        {
                printf("\nInvalid magic word: %X\n", magic);
                panic("");
        }
        if (hdr->flags & MULTIBOOT_INFO_MEMORY)
        {
                memsize = hdr->mem_upper;
                memsize += 1024;
        }
        else
                panic("No memory flags!");
        if (!(hdr->flags & MULTIBOOT_INFO_MEM_MAP))
                panic("Invalid memory map");

        mmap = (multiboot_memory_map_t*) hdr->mmap_addr;

        /** Build the memory map and allow for allocation */
        x86_pte_init();
        page_alloc_init(mmap, (unsigned int)hdr->mmap_length);
        vm_init();
#ifdef PA_DBG
//         endProg();
#endif
        /** In the progress of phasing out */
        /** Set up paging administration */
        x86_page_init(memsize);
        mboot_page_setup(mmap, (uint32_t)hdr->mmap_length);
        mboot_map_modules((void*)hdr->mods_addr, hdr->mods_count);

        /** For now this is the temporary page table map */
        build_map(mmap, (unsigned int) hdr->mmap_length);

        /** end of deprication */
        task_init();

        page_init();
        printf(WELCOME); // The only screen output that should be maintained
        page_unmap_low_mem();
        pic_init();
        setIDT();
        setup_irq_data();

        if (dev_init() != -E_SUCCESS)
                panic("Couldn't initialise /dev");

        ol_pit_init(1024); // program pic to 1024 hertz

        debug("Size of the heap: 0x%x\tStarting at: %x\n", HEAPSIZE, heap);

        acpi_init();
        ol_cpu_t cpu = kalloc(sizeof (*cpu));
        if (cpu == NULL)
                panic("OUT OF MEMORY!");
        ol_cpu_init(cpu);

        ol_ps2_init_keyboard();
        ol_apic_init(cpu);
        init_ioapic();
        ol_pci_init();
        debug("Little endian 0xf in net endian %x\n", htons(0xf));
#ifdef DBG
#ifdef __IOAPIC_DBG
        ioapic_debug();
#endif
#ifdef __MEMTEST
        ol_detach_all_devices(); /* free's al the pci devices */
#endif
#ifdef __DBG_HEAP
        printf("Heap list:\n");
        ol_dbg_heap();
#endif
        printf("\nSome (temp) debug info:\n");
        printf("CPU vendor: %s\n", cpus->vendor);

        if(systables->magic == SYS_TABLE_MAGIC)
        {
                printf("RSDP ASCII signature: 0x%x%x\n",
                *(((uint32_t*) systables->rsdp->signature) + 1),
                *(((uint32_t*) systables->rsdp->signature)));
                printf("MP specification signature: 0x%x\n", systables->mp->signature);
        }
#endif
#ifdef PA_DBG
        addr_t p = (addr_t)page_alloc();
        page_free((void*)p);
        printf("Allocated: %X\n", p);
        page_dump();
#endif
#ifdef PA_DBG
        addr_t p = (addr_t)page_alloc();
        page_free((void*)p);
        printf("Allocated: %X\n", p);
        page_dump();
#endif

        core_loop();
        return 0; // To keep the compiler happy.
}