int get_cursor(){ out_b(REG_SCREEN_CTRL, 14); // cursor offset high byte int offset = in_b(REG_SCREEN_DATA) << 8; //set offset high byte out_b(REG_SCREEN_CTRL, 15); // cursor offset low byte offset += in_b(REG_SCREEN_DATA); //set offset low byte return offset * 2; }
void disable_8259_irq (int irq) { if (irq > -1 && irq < 8) { __asm__ ("pushf"); out_b (MASTER_CTLMASK, (in_b (MASTER_CTLMASK) | (1 << irq))); __asm__ ("popf"); } else if (irq > 7 && irq < 16) { __asm__ ("pushf"); out_b (SLAVE_CTLMASK, (in_b (SLAVE_CTLMASK) | (1 << (irq - 8)))); __asm__ ("popf"); } }
//TODO char handleKBD(int currLinePosition){ /*return char if key pressed, 0 if no key press*/ char flag; char mychar = 0; /*read keyboard status*/ flag = in_b(0x64); /*if there is data to read, read data*/ if (flag & 0x1){ mychar = getChar(); //if at line cap, don't write if((mychar != '\b' && mychar != '\n') && currLinePosition == 99){ mychar = 0; } if (mychar != 0){ //mychar returns 0 on keyup, deal with this differently, current is crutch if (!(mychar == '\b' && currLinePosition == 0)){ //DON'T BACKSPACE OVER PROMPT //print char to screen print_char(mychar, -1, -1, WHIT_BLK); } else { mychar = 0; } } } return mychar; }
ACPI_STATUS AcpiOsReadPort ( ACPI_IO_ADDRESS Address, UINT32 *Value, UINT32 Width) { switch (Width) { case 8: *Value = in_b((uint16_t)Address); break; case 16: *Value = in_h((uint16_t)Address); break; case 32: *Value = in_w((uint16_t)Address); break; default: return (AE_BAD_PARAMETER); } return (AE_OK); }
/* * Memory block inputs (8 bit) cnt : number of bytes */ EXPORT void InMemB(UW iob, W ix, UB *buf, W cnt) { UW port = iob + (ix * IOSTEP); while (--cnt >= 0) { *buf++ = in_b(port); } }
void main() { while(1) { if(in_b(4)==0) { toggle_d(7); sleep(200); } } }
/* I/O read */ EXPORT W readIO(UW addr, UW *data, W unit) { W n; UW pa; /* address misalignment is reported as error */ if (addr & (unit - 1)) return 0; /* I/O address check & conversion to physical address */ n = chkIOAddr(addr, &pa, unit); if (n < unit) return 0; switch(unit) { case 4: *data = in_w(pa); break; case 2: *data = in_h(pa); break; default: *data = in_b(pa); } return unit; }
/* ================================================================================== Funtion :recvCounter2 Input :void Output :void Return :uint8_t < received a value of counter 2 > Description :receive a value of counter 2 from a pit ================================================================================== */ LOCAL INLINE uint8_t recvCounter2(void) { return(in_b(PIT_REG_COUNTER2)); }
/* ================================================================================== Funtion :recvData Input :void Output :void Return :uint8_t < received data > Description :receive a data from a pit ================================================================================== */ LOCAL INLINE uint8_t recvData(void) { return(in_b(PIT_REG_CONTROL)); }
/* ================================================================================== Funtion :recvDataSlave Input :void Output :void Return :uint8_t < received data > Description :receive data from a pic slave ================================================================================== */ LOCAL INLINE uint8_t recvDataSlave(void) { return(in_b(PIC_SLV_DAT_REG)); }
/* ================================================================================== Funtion :recvIrqMaskSlave Input :void Output :void Return :uint8_t < received data > Description :receive mask data from a pic slave ================================================================================== */ LOCAL INLINE uint8_t recvIrqMaskSlave(void) { return(in_b(PIC_SLV_IMR_REG)); }
/* ================================================================================== Funtion :recvStatusSlave Input :void Output :void Return :uint8_t < received status > Description :receive a status from a pic slave ================================================================================== */ LOCAL INLINE uint8_t recvStatusSlave(void) { return(in_b(PIC_SLV_STS_REG)); }
/* ================================================================================== Funtion :recvDataMaster Input :void Output :void Return :uint8_t < received data > Description :receive data from a pic master ================================================================================== */ LOCAL INLINE uint8_t recvDataMaster(void) { return(in_b(PIC_MST_DAT_REG)); }
/* ================================================================================== Funtion :recvIrqMaskMaster Input :void Output :void Return :uint8_t < received data > Description :receive mask data from a pic master ================================================================================== */ LOCAL INLINE uint8_t recvIrqMaskMaster(void) { return(in_b(PIC_MST_IMR_REG)); }
/* ================================================================================== Funtion :recvStatusMaster Input :void Output :void Return :uint8_t < received status > Description :receive a status from a pic master ================================================================================== */ LOCAL INLINE uint8_t recvStatusMaster(void) { return(in_b(PIC_MST_STS_REG)); }
int getScancode(){ int result; result = in_b(REGISTER_KEYBOARD_DATA); return result; }