📄 h8.c
字号:
/* 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 */ list_add(&qp[i].link, &h8_freeq); } 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 (list_empty(&h8_freeq)) { 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 = list_entry(h8_freeq.next, h8_cmd_q_t, link); list_del(&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(); /* XXX this actually puts it at the start of cmd queue, bug? */ list_add(&qp->link, &h8_cmdq); 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 (!list_empty(&h8_actq)) { Dprintk("h8_start_new_cmd: inconsistency: IDLE with non-empty active queue!\n"); restore_flags(flags); return; } if (list_empty(&h8_cmdq)) { 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 = list_entry(h8_cmdq.next, h8_cmd_q_t, link); list_del(&qp->link); /* XXX should this go to the end of the active queue? */ list_add(&qp->link, &h8_actq); 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 = list_entry(h8_actq.next, h8_cmd_q_t, 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]); list_add(&qp->link, &h8_freeq); 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]); list_add(&qp->link, &h8_freeq); 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]); list_add(&qp->link, &h8_freeq); break; case H8_RD_MIN_TEMP: printk("H8: Min recorded CPU temp %d, Sys temp %d\n", qp->rcvbuf[0], qp->rcvbuf[1]); list_add(&qp->link, &h8_freeq); 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); list_add(&qp->link, &h8_freeq); 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); list_add(&qp->link, &h8_freeq); 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]); list_add(&qp->link, &h8_freeq); 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]); } list_add(&qp->link, &h8_freeq); 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: printk("H8: Idle and busy speed command done\n"); break; case H8_CTL_TFT_BRT_BATT: case H8_CTL_UPPER_TEMP: if(h8_debug & 0x10) { XDprintk("H8: ctl upper thermal thresh cmd done - returned was %d\n", qp->rcvbuf[0]); } list_add(&qp->link, &h8_freeq); break; case H8_CTL_LOWER_TEMP: case H8_CTL_TEMP_CUTOUT: case H8_CTL_WAKEUP: case H8_CTL_CHG_THRESHOLD: case H8_CTL_TURBO_MODE: case H8_SET_DIAG_STATUS: case H8_SOFTWARE_RESET:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -