void uartinit(void) { char *p; // Turn off the FIFO outb(COM1+2, 0); // 9600 baud, 8 data bits, 1 stop bit, parity off. outb(COM1+3, 0x80); // Unlock divisor outb(COM1+0, 115200/9600); outb(COM1+1, 0); outb(COM1+3, 0x03); // Lock divisor, 8 data bits. outb(COM1+4, 0); outb(COM1+1, 0x01); // Enable receive interrupts. // If status is 0xFF, no serial port. if(inb(COM1+5) == 0xFF) return; uart = 1; // Acknowledge pre-existing interrupt conditions; // enable interrupts. inb(COM1+2); inb(COM1+0); picenable(IRQ_COM1); ioapicenable(IRQ_COM1, 0); // Announce that we're here. for(p="xv6...\n"; *p; p++) uartputc(*p); }
void mouseinit(void) { uchar statustemp; mouse_wait(1); outb(0x64, 0xa8); //激活鼠标接口 mouse_wait(1); //激活中断 outb(0x64, 0x20); mouse_wait(0); statustemp = (inb(0x60) | 2); mouse_wait(0); outb(0x64, 0x60); mouse_wait(1); outb(0x60, statustemp); mouse_write(0xf6); //设置鼠标为默认设置 mouse_read(); mouse_write(0xf3); //设置鼠标采样率 mouse_read(); mouse_write(10); mouse_read(); mouse_write(0xf4); mouse_read(); initlock(&mouselock, "mouse"); picenable(IRQ_MOUSE); ioapicenable(IRQ_MOUSE, 0); count = 0; lastclicktick = lastdowntick = -1000; }
void timerinit(void) { // Interrupt 100 times/sec. outb(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT); outb(IO_TIMER1, TIMER_DIV(100) % 256); outb(IO_TIMER1, TIMER_DIV(100) / 256); picenable(IRQ_TIMER); }
void consoleinit(void) { initlock(&cons.lock, "console"); historyList.size = 0; devsw[CONSOLE].write = consolewrite; devsw[CONSOLE].read = consoleread; cons.locking = 1; picenable(IRQ_KBD); ioapicenable(IRQ_KBD, 0); }
void mouseinit() { outb(0x64, 0xa8); outb(0x64, 0xd4); outb(0x60, 0xf4); outb(0x64, 0x60); outb(0x60, 0x47); setMousePosition(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2); initlock(&mouse_lock, "mouse"); picenable(IRQ_MOUSE); ioapicenable(IRQ_MOUSE, 0); }
void mouseinit() { outb( 0x64 , 0xa8 ); outb( 0x64 , 0xd4 ); outb( 0x60 , 0xf4 ); outb( 0x64 , 0x60 ); outb( 0x60 , 0x47 ); initlock(&mouse_lock,"mouse"); picenable(IRQ_MOUS); ioapicenable(IRQ_MOUS, 0); }
void consoleinit(void) { initlock(&cons.lock, "console"); initlock(&input.lock, "input"); devsw[CONSOLE].write = consolewrite; devsw[CONSOLE].read = consoleread; cons.locking = 1; picenable(IRQ_KBD); ioapicenable(IRQ_KBD, 0); }
void cmosinit() { outb(CMOS_CTRL_PORT, CMOS_STAT_B_REG); outb(CMOS_DATA_PORT, 0x10); // IRQ 8 on update picenable(IRQ_RTC); ioapicenable(IRQ_RTC, 1); // cprintf("CMOS time %d-%d-%d %d:%d.%d\n", cmos_time.year + 2000, cmos_time.month, // cmos_time.day, cmos_time.hour, cmos_time.min, cmos_time.sec); // cprintf("Julian date: %d\n", cmos_to_julian()); }
void soundcardinit(ushort addr) { uint tmp, cur, vendorID; ushort vendorID1, vendorID2; //Initializing the Audio I/O Space tmp = pciread(addr, PCI_CONFIG_SPACE_STA_CMD); pciwrite(addr, PCI_CONFIG_SPACE_STA_CMD, tmp | 0x5); SOUND_NAMBA_DATA = pciread(addr, PCI_CONFIG_SPACE_NAMBA) & (~0x1); SOUND_NABMBA_DATA = pciread(addr, PCI_CONFIG_SPACE_NABMBA) & (~0x1); cprintf("AUDIO I/O Space initialized successfully!\n"); //Removing AC_RESET outb(SOUND_NABMBA_DATA + NABMBA_GLOB_CNT, 0x2); cprintf("AC_RESET removed successfully!\n"); //Reading Codec Ready Status cur = 0; cprintf("Waiting for Codec Ready Status...\n"); while (!(inw(SOUND_NABMBA_DATA + NABMBA_GLOB_STA) & 0X100) && cur < 1000) { cur++; } if (cur == 1000) { cprintf("\nAudio Init Failed\n"); return; } cprintf("Codec is ready!\n"); //Determine Audio Codec tmp = inw(NAMBA_PCMV); cprintf("%x\n", tmp); outw(NAMBA_PCMV, 0x8000); if (inw(NAMBA_PCMV) != 0x8000) { cprintf("Audio Codec Function not found!\n"); return; } outw(NAMBA_PCMV, tmp); cprintf("Audio Codec Function is found, current volume is %x.\n", tmp); //Reading the Audio Codec Vendor ID vendorID1 = inw(SOUND_NAMBA_DATA + NAMBA_PCVID1); vendorID2 = inw(SOUND_NAMBA_DATA + NAMBA_PCVID2); cprintf("Audio Codec Vendor ID read successfully!\n"); //Programming the PCI Audio Subsystem ID vendorID = (vendorID2 << 16) + vendorID1; pciwrite(addr, PCI_CONFIG_SPACE_SID_SVID, vendorID); //Initailize Interruption initlock(&soundLock, "audio"); picenable(IRQ_SOUND); ioapicenable(IRQ_SOUND, ncpu - 1); outw(NAMBA_PCMV, 0x1f1f); soundQueue = 0; }
void consoleinit(void) { picenable(IRQ_KBD); ioapicenable(IRQ_KBD, 0); }