chore: fix almost *ALL* warnings.
[lunaix-os.git] / lunaix-os / kernel / asm / x86 / i386_isrm.c
index 0a26c3be2a7a55a7286d4fae754d4e97b891ebc2..a45ce7e2dfcc4d7f8a03389f445df3628225499e 100644 (file)
@@ -25,53 +25,62 @@ isrm_init()
     }
 }
 
-static inline uint32_t
+static inline int
 __ivalloc_within(size_t a, size_t b, isr_cb handler)
 {
     a = (a - IV_BASE) / 8;
     b = (b - IV_BASE) / 8;
+
     for (size_t i = a; i < b; i++) {
-        char chunk = iv_bmp[i], j = 0;
+        u8_t chunk = iv_bmp[i], j = 0;
+
         if (chunk == 0xff)
             continue;
+
         while ((chunk & 0x1)) {
             chunk >>= 1;
             j++;
         }
+
         iv_bmp[i] |= 1 << j;
-        uint32_t iv = IV_BASE + i * 8 + j;
+
+        int iv = IV_BASE + i * 8 + j;
         handlers[iv] = handler ? handler : intr_routine_fallback;
+
         return iv;
     }
+
     return 0;
 }
 
-uint32_t
+int
 isrm_ivosalloc(isr_cb handler)
 {
     return __ivalloc_within(IV_BASE, IV_EX, handler);
 }
 
-uint32_t
+int
 isrm_ivexalloc(isr_cb handler)
 {
     return __ivalloc_within(IV_EX, IV_MAX, handler);
 }
 
 void
-isrm_ivfree(uint32_t iv)
+isrm_ivfree(int iv)
 {
     assert(iv < 256);
+
     if (iv >= IV_BASE) {
         iv_bmp[(iv - IV_BASE) / 8] &= ~(1 << ((iv - IV_BASE) % 8));
     }
+
     handlers[iv] = intr_routine_fallback;
 }
 
-uint32_t
-isrm_bindirq(uint32_t irq, isr_cb irq_handler)
+int
+isrm_bindirq(int irq, isr_cb irq_handler)
 {
-    uint32_t iv;
+    int iv;
     if (!(iv = isrm_ivexalloc(irq_handler))) {
         panickf("out of IV resource. (irq=%d)", irq);
         return 0; // never reach
@@ -80,22 +89,26 @@ isrm_bindirq(uint32_t irq, isr_cb irq_handler)
     // PC_AT_IRQ_RTC -> RTC_TIMER_IV, fixed, edge trigged, polarity=high,
     // physical, APIC ID 0
     ioapic_redirect(acpi_gistranslate(irq), iv, 0, IOAPIC_DELMOD_FIXED);
+
     return iv;
 }
 
-uint32_t
-isrm_bindiv(uint32_t iv, isr_cb handler)
+void
+isrm_bindiv(int iv, isr_cb handler)
 {
     assert(iv < 256);
+
     if (iv >= IV_BASE) {
         iv_bmp[(iv - IV_BASE) / 8] |= 1 << ((iv - IV_BASE) % 8);
     }
+
     handlers[iv] = handler;
 }
 
 isr_cb
-isrm_get(uint32_t iv)
+isrm_get(int iv)
 {
     assert(iv < 256);
+
     return handlers[iv];
 }
\ No newline at end of file