/* * Initialises the CMOS RTC driver. */ static void* rtc_init(device_t *dev) { // Read initial RTC values rtc_read(); // Enable the periodic IRQ IRQ_OFF(); io_outb(CMOS_REG_PORT, 0x8B); uint8_t reg = io_inb(CMOS_DATA_PORT); io_outb(CMOS_REG_PORT, 0x8B); io_outb(CMOS_DATA_PORT, reg | 0x40); // Rate is 2 Hz io_outb(CMOS_REG_PORT, 0x8A); reg = io_inb(CMOS_DATA_PORT); io_outb(CMOS_REG_PORT, 0x8A); io_outb(CMOS_DATA_PORT, (reg & 0xF0) | 0x0F); // Install IRQ handler hal_register_irq_handler(8, rtc_sys_tick, NULL); // Re-enable IRQs IRQ_RES(); return BUS_NO_INIT_DATA; }
/* * Called when all drivers are loaded to attempt legacy ATA probing */ static int ata_post_driver_load(void) { if(ata_drivers_loaded == 0) { KWARNING("No ATA drivers loaded: attempting legacy init"); // Set up ATA driver (this will probe for devices) ata_driver_t *ata = ata_init_pci(0, 0, 0, 0, 0); // List devices found for (int i = 0; i < 4; i++) { if (ata->devices[i].drive_exists == true) { } } // Register IRQs 14 and 15 since the controller is in legacy ATA mode hal_register_irq_handler(14, (void (*)(void *)) ata_irq_callback, ata); hal_register_irq_handler(15, (void (*)(void *)) ata_irq_callback, ata); } return 0; }
void main() { int cnt = 4; hal_uart_putstr("DURGA has booted \n"); if (hal_mmc_init()) hal_uart_putstr("error initializing mmc !\n"); if (hal_mmc_sdcard_init()) hal_uart_putstr("error initializing sd card !\n"); while(1) { //toggle usr3 led hal_usr_led_toggle(3); hal_delay(1); if (cnt > 1) --cnt; else if (cnt == 1) { --cnt; hal_register_irq_handler(RTC_INTR_NUM, rtc_intr_hdlr, NULL); } } }