chore: fix almost *ALL* warnings.
[lunaix-os.git] / lunaix-os / kernel / peripheral / ps2kbd.c
index fbd7e751a1a18c5227947cc7c1a0784af8819bdc..c31d73666b84fa4e7d849b97d80ef98720a562f3 100644 (file)
@@ -16,7 +16,7 @@
 
 #define PS2_DEV_CMD_MAX_ATTEMPTS 5
 
-LOG_MODULE("PS2KBD");
+LOG_MODULE("i8042");
 
 static struct ps2_cmd_queue cmd_q;
 static struct ps2_kbd_state kbd_state;
@@ -86,8 +86,8 @@ static struct input_device* kbd_idev;
 void
 intr_ps2_kbd_handler(const isr_param* param);
 
-static uint8_t
-ps2_issue_cmd_wretry(char cmd, uint16_t arg);
+static u8_t
+ps2_issue_cmd_wretry(char cmd, u16_t arg);
 
 void
 ps2_device_post_cmd(char cmd, char arg)
@@ -139,13 +139,13 @@ ps2_kbd_init()
          *      https://bochs.sourceforge.io/cgi-bin/lxr/source/bios/rombios32.c#L1314
          */
         if (!(acpi_ctx->fadt.boot_arch & IAPC_ARCH_8042)) {
-            kprintf(KERROR "i8042: not found\n");
+            kprintf(KERROR "not found\n");
             // FUTURE: Some alternative fallback on this? Check PCI bus for USB
             // controller instead?
             return;
         }
     } else {
-        kprintf(KWARN "i8042: outdated FADT used, assuming exists.\n");
+        kprintf(KWARN "outdated FADT used, assuming exists.\n");
     }
 
     char result;
@@ -167,14 +167,14 @@ ps2_kbd_init()
     // 4、控制器自检
     result = ps2_issue_cmd_wretry(PS2_CMD_SELFTEST, PS2_NO_ARG);
     if (result != PS2_RESULT_TEST_OK) {
-        kprintf(KWARN "Controller self-test failed. (%x)\n", result);
+        kprintf(KWARN "controller self-test failed. (%x)\n", result);
         // goto done;
     }
 
     // 5、设备自检(端口1自检,通常是我们的键盘)
     result = ps2_issue_cmd_wretry(PS2_CMD_SELFTEST_PORT1, PS2_NO_ARG);
     if (result != 0) {
-        kprintf(KERROR "Interface test on port 1 failed. (%x)\n", result);
+        kprintf(KERROR "interface test on port 1 failed. (%x)\n", result);
         // goto done;
     }
 
@@ -207,7 +207,6 @@ ps2_kbd_init()
      */
     isrm_bindirq(PC_AT_IRQ_KBD, intr_ps2_kbd_handler);
 
-done:
     cpu_enable_interrupt();
 }
 
@@ -231,7 +230,7 @@ ps2_process_cmd(void* arg)
 
     // 处理队列排头的指令
     struct ps2_cmd* pending_cmd = &cmd_q.cmd_queue[cmd_q.queue_ptr];
-    char result;
+    u8_t result;
     int attempts = 0;
 
     // 尝试将命令发送至PS/2键盘(通过PS/2控制器)
@@ -251,7 +250,7 @@ ps2_process_cmd(void* arg)
 }
 
 void
-kbd_buffer_key_event(kbd_keycode_t key, uint8_t scancode, kbd_kstate_t state)
+kbd_buffer_key_event(kbd_keycode_t key, u8_t scancode, kbd_kstate_t state)
 {
     /*
         forgive me on these ugly bit-level tricks,
@@ -306,7 +305,7 @@ intr_ps2_kbd_handler(const isr_param* param)
     // check. But DO NOT. This chunk is in right place and right order. Moving
     // it at your own risk This is to ensure we've cleared the output buffer
     // everytime, so it won't pile up across irqs.
-    uint8_t scancode = io_inb(PS2_PORT_ENC_DATA);
+    u8_t scancode = io_inb(PS2_PORT_ENC_DATA);
     kbd_keycode_t key;
 
     /*
@@ -403,8 +402,8 @@ intr_ps2_kbd_handler(const isr_param* param)
     }
 }
 
-static uint8_t
-ps2_issue_cmd(char cmd, uint16_t arg)
+static u8_t
+ps2_issue_cmd(char cmd, u16_t arg)
 {
     ps2_post_cmd(PS2_PORT_CTRL_CMDREG, cmd, arg);
 
@@ -416,21 +415,21 @@ ps2_issue_cmd(char cmd, uint16_t arg)
     return io_inb(PS2_PORT_ENC_CMDREG);
 }
 
-static uint8_t
-ps2_issue_cmd_wretry(char cmd, uint16_t arg)
+static u8_t
+ps2_issue_cmd_wretry(char cmd, u16_t arg)
 {
-    uint8_t r, c = 0;
+    u8_t r, c = 0;
     while ((r = ps2_issue_cmd(cmd, arg)) == PS2_RESULT_NAK && c < 5) {
         c++;
     }
     if (c >= 5) {
-        kprintf(KWARN "Max attempt reached.\n");
+        kprintf(KWARN "max attempt reached.\n");
     }
     return r;
 }
 
 static void
-ps2_post_cmd(uint8_t port, char cmd, uint16_t arg)
+ps2_post_cmd(u8_t port, char cmd, u16_t arg)
 {
     // 等待PS/2输入缓冲区清空,这样我们才可以写入命令
     while (io_inb(PS2_PORT_CTRL_STATUS) & PS2_STATUS_IFULL)
@@ -443,13 +442,13 @@ ps2_post_cmd(uint8_t port, char cmd, uint16_t arg)
         // 所有参数一律通过0x60传入。
         while (io_inb(PS2_PORT_CTRL_STATUS) & PS2_STATUS_IFULL)
             ;
-        io_outb(PS2_PORT_ENC_CMDREG, (uint8_t)(arg & 0x00ff));
+        io_outb(PS2_PORT_ENC_CMDREG, (u8_t)(arg & 0x00ff));
         io_delay(PS2_DELAY);
     }
 }
 
-static uint8_t
-ps2_issue_dev_cmd(char cmd, uint16_t arg)
+static u8_t
+ps2_issue_dev_cmd(char cmd, u16_t arg)
 {
     ps2_post_cmd(PS2_PORT_ENC_CMDREG, cmd, arg);