📄 h8.c
字号:
char *p; if (!h8_enabled) return 0; p = buf; /* 0) Linux driver version (this will change if format changes) 1) 2) 3) 4) */ p += sprintf(p, "%s \n", driver_version ); return p - buf;}#endif/* Called from console driver -- must make sure h8_enabled. */int h8_display_blank(void){#ifdef CONFIG_H8_DISPLAY_BLANK int error; if (!h8_enabled) return 0; error = h8_set_display_power_state(H8_STATE_STANDBY); if (error == H8_SUCCESS) return 1; h8_error("set display standby", error);#endif return 0;}/* Called from console driver -- must make sure h8_enabled. */int h8_display_unblank(void){#ifdef CONFIG_H8_DISPLAY_BLANK int error; if (!h8_enabled) return 0; error = h8_set_display_power_state(H8_STATE_READY); if (error == H8_SUCCESS) return 1; h8_error("set display ready", error);#endif return 0;}inth8_alloc_queues(void){ h8_cmd_q_t *qp; unsigned long flags; int i; qp = (h8_cmd_q_t *)kmalloc((sizeof (h8_cmd_q_t) * H8_Q_ALLOC_AMOUNT), GFP_KERNEL); if (!qp) { printk("H8: could not allocate memory for command queue\n"); return(0); } /* add to the free queue */ save_flags(flags); cli(); for (i = 0; i < H8_Q_ALLOC_AMOUNT; i++) { /* place each at front of freeq */ QUEUE_ENTER(&h8_freeq, &qp[i], link, h8_cmd_q_t *); } restore_flags(flags); return (1);}/* * Basic means by which commands are sent to the H8. */voidh8_q_cmd(u_char *cmd, int cmd_size, int resp_size){ h8_cmd_q_t *qp; unsigned long flags; int i; /* get cmd buf */ save_flags(flags); cli(); while (QUEUE_EMPTY(&h8_freeq, link)) { Dprintk("H8: need to allocate more cmd buffers\n"); restore_flags(flags); h8_alloc_queues(); save_flags(flags); cli(); } /* get first element from queue */ qp = (h8_cmd_q_t *)QUEUE_FIRST(&h8_freeq, link); QUEUE_REMOVE(&h8_freeq, qp, link); restore_flags(flags); /* fill it in */ for (i = 0; i < cmd_size; i++) qp->cmdbuf[i] = cmd[i]; qp->ncmd = cmd_size; qp->nrsp = resp_size; /* queue it at the end of the cmd queue */ save_flags(flags); cli(); QUEUE_ENTER(&h8_cmdq, qp, link, h8_cmd_q_t *); restore_flags(flags); h8_start_new_cmd();}voidh8_start_new_cmd(void){ unsigned long flags; h8_cmd_q_t *qp; save_flags(flags); cli(); if (h8_state != H8_IDLE) { if (h8_debug & 0x1) Dprintk("h8_start_new_cmd: not idle\n"); restore_flags(flags); return; } if (!QUEUE_EMPTY(&h8_actq, link)) { Dprintk("h8_start_new_cmd: inconsistency: IDLE with non-empty active queue!\n"); restore_flags(flags); return; } if (QUEUE_EMPTY(&h8_cmdq, link)) { Dprintk("h8_start_new_cmd: no command to dequeue\n"); restore_flags(flags); return; } /* * Take first command off of the command queue and put * it on the active queue. */ qp = (h8_cmd_q_t *) QUEUE_FIRST(&h8_cmdq, link); QUEUE_REMOVE(&h8_cmdq, qp, link); QUEUE_ENTER(&h8_actq, qp, link, h8_cmd_q_t *); h8_state = H8_XMIT; if (h8_debug & 0x1) Dprintk("h8_start_new_cmd: Starting a command\n"); qp->cnt = 1; WRITE_CMD(qp->cmdbuf[0]); /* Kick it off */ restore_flags(flags); return;}voidh8_send_next_cmd_byte(void){ h8_cmd_q_t *qp = (h8_cmd_q_t *)QUEUE_FIRST(&h8_actq, link); int cnt; cnt = qp->cnt; qp->cnt++; if (h8_debug & 0x1) Dprintk("h8 sending next cmd byte 0x%x (0x%x)\n", cnt, qp->cmdbuf[cnt]); if (cnt) { WRITE_DATA(qp->cmdbuf[cnt]); } else { WRITE_CMD(qp->cmdbuf[cnt]); } return;}/* * Synchronize H8 communications channel for command transmission. */voidh8_sync(void){ u_char buf[H8_MAX_CMD_SIZE]; buf[0] = H8_SYNC; buf[1] = H8_SYNC_BYTE; h8_q_cmd(buf, 2, 1);}/* * Responds to external interrupt. Reads event status word and * decodes type of interrupt. */voidh8_read_event_status(void){ if(h8_debug & 0x200) printk("h8_read_event_status: value 0x%x\n", intrbuf.word); /* * Power related items */ if (intrbuf.word & H8_DC_CHANGE) { if(h8_debug & 0x4) printk("h8_read_event_status: DC_CHANGE\n"); /* see if dc added or removed, set batt/dc flag, send event */ h8_set_event_mask(H8_MANAGE_BATTERY); wake_up(&h8_monitor_wait); } if (intrbuf.word & H8_POWER_BUTTON) { printk("Power switch pressed - please wait - preparing to power off\n"); h8_set_event_mask(H8_POWER_BUTTON); wake_up(&h8_monitor_wait); } /* * Thermal related items */ if (intrbuf.word & H8_THERMAL_THRESHOLD) { if(h8_debug & 0x4) printk("h8_read_event_status: THERMAL_THRESHOLD\n"); h8_set_event_mask(H8_MANAGE_UTHERM); wake_up(&h8_monitor_wait); } /* * nops -for now */ if (intrbuf.word & H8_DOCKING_STATION_STATUS) { if(h8_debug & 0x4) printk("h8_read_event_status: DOCKING_STATION_STATUS\n"); /* read_ext_status */ } if (intrbuf.word & H8_EXT_BATT_STATUS) { if(h8_debug & 0x4) printk("h8_read_event_status: EXT_BATT_STATUS\n"); } if (intrbuf.word & H8_EXT_BATT_CHARGE_STATE) { if(h8_debug & 0x4) printk("h8_read_event_status: EXT_BATT_CHARGE_STATE\n"); } if (intrbuf.word & H8_BATT_CHANGE_OVER) { if(h8_debug & 0x4) printk("h8_read_event_status: BATT_CHANGE_OVER\n"); } if (intrbuf.word & H8_WATCHDOG) { if(h8_debug & 0x4) printk("h8_read_event_status: WATCHDOG\n"); /* nop */ } if (intrbuf.word & H8_SHUTDOWN) { if(h8_debug & 0x4) printk("h8_read_event_status: SHUTDOWN\n"); /* nop */ } if (intrbuf.word & H8_KEYBOARD) { if(h8_debug & 0x4) printk("h8_read_event_status: KEYBOARD\n"); /* nop */ } if (intrbuf.word & H8_EXT_MOUSE_OR_CASE_SWITCH) { if(h8_debug & 0x4) printk("h8_read_event_status: EXT_MOUSE_OR_CASE_SWITCH\n"); /* read_ext_status*/ } if (intrbuf.word & H8_INT_BATT_LOW) { if(h8_debug & 0x4) printk("h8_read_event_status: INT_BATT_LOW\n"); /* post event, warn user */ } if (intrbuf.word & H8_INT_BATT_CHARGE_STATE) { if(h8_debug & 0x4) printk("h8_read_event_status: INT_BATT_CHARGE_STATE\n"); /* nop - happens often */ } if (intrbuf.word & H8_INT_BATT_STATUS) { if(h8_debug & 0x4) printk("h8_read_event_status: INT_BATT_STATUS\n"); } if (intrbuf.word & H8_INT_BATT_CHARGE_THRESHOLD) { if(h8_debug & 0x4) printk("h8_read_event_status: INT_BATT_CHARGE_THRESHOLD\n"); /* nop - happens often */ } if (intrbuf.word & H8_EXT_BATT_LOW) { if(h8_debug & 0x4) printk("h8_read_event_status: EXT_BATT_LOW\n"); /*if no internal, post event, warn user */ /* else nop */ } return;}/* * Function called when H8 has performed requested command. */voidh8_cmd_done(h8_cmd_q_t *qp){ /* what to do */ switch (qp->cmdbuf[0]) { case H8_SYNC: if (h8_debug & 0x40000) printk("H8: Sync command done - byte returned was 0x%x\n", qp->rcvbuf[0]); QUEUE_ENTER(&h8_freeq, qp, link, h8_cmd_q_t *); break; case H8_RD_SN: case H8_RD_ENET_ADDR: printk("H8: read Ethernet address: command done - address: %x - %x - %x - %x - %x - %x \n", qp->rcvbuf[0], qp->rcvbuf[1], qp->rcvbuf[2], qp->rcvbuf[3], qp->rcvbuf[4], qp->rcvbuf[5]); QUEUE_ENTER(&h8_freeq, qp, link, h8_cmd_q_t *); break; case H8_RD_HW_VER: case H8_RD_MIC_VER: case H8_RD_MAX_TEMP: printk("H8: Max recorded CPU temp %d, Sys temp %d\n", qp->rcvbuf[0], qp->rcvbuf[1]); QUEUE_ENTER(&h8_freeq, qp, link, h8_cmd_q_t *); break; case H8_RD_MIN_TEMP: printk("H8: Min recorded CPU temp %d, Sys temp %d\n", qp->rcvbuf[0], qp->rcvbuf[1]); QUEUE_ENTER(&h8_freeq, qp, link, h8_cmd_q_t *); break; case H8_RD_CURR_TEMP: h8_sync_channel |= H8_RD_CURR_TEMP; xx.byte[0] = qp->rcvbuf[0]; xx.byte[1] = qp->rcvbuf[1]; wake_up(&h8_sync_wait); QUEUE_ENTER(&h8_freeq, qp, link, h8_cmd_q_t *); break; case H8_RD_SYS_VARIENT: case H8_RD_PWR_ON_CYCLES: printk(" H8: RD_PWR_ON_CYCLES command done\n"); break; case H8_RD_PWR_ON_SECS: printk("H8: RD_PWR_ON_SECS command done\n"); break; case H8_RD_RESET_STATUS: case H8_RD_PWR_DN_STATUS: case H8_RD_EVENT_STATUS: case H8_RD_ROM_CKSM: case H8_RD_EXT_STATUS: xx.byte[1] = qp->rcvbuf[0]; xx.byte[0] = qp->rcvbuf[1]; h8_sync_channel |= H8_GET_EXT_STATUS; wake_up(&h8_sync_wait); QUEUE_ENTER(&h8_freeq, qp, link, h8_cmd_q_t *); break; case H8_RD_USER_CFG: case H8_RD_INT_BATT_VOLT: case H8_RD_DC_INPUT_VOLT: case H8_RD_HORIZ_PTR_VOLT: case H8_RD_VERT_PTR_VOLT: case H8_RD_EEPROM_STATUS: case H8_RD_ERR_STATUS: case H8_RD_NEW_BUSY_SPEED: case H8_RD_CONFIG_INTERFACE: case H8_RD_INT_BATT_STATUS: printk("H8: Read int batt status cmd done - returned was %x %x %x\n", qp->rcvbuf[0], qp->rcvbuf[1], qp->rcvbuf[2]); QUEUE_ENTER(&h8_freeq, qp, link, h8_cmd_q_t *); break; case H8_RD_EXT_BATT_STATUS: case H8_RD_PWR_UP_STATUS: case H8_RD_EVENT_STATUS_MASK: case H8_CTL_EMU_BITPORT: case H8_DEVICE_CONTROL: if(h8_debug & 0x20000) { printk("H8: Device control cmd done - byte returned was 0x%x\n", qp->rcvbuf[0]); } QUEUE_ENTER(&h8_freeq, qp, link, h8_cmd_q_t *); break; case H8_CTL_TFT_BRT_DC: case H8_CTL_WATCHDOG: case H8_CTL_MIC_PROT: case H8_CTL_INT_BATT_CHG: case H8_CTL_EXT_BATT_CHG: case H8_CTL_MARK_SPACE: case H8_CTL_MOUSE_SENSITIVITY: case H8_CTL_DIAG_MODE: case H8_CTL_IDLE_AND_BUSY_SPDS:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -