IRQ: use uint64_t everywhere for int numbers, renamed controller
authorLukas Humbel <lukas.humbel@inf.ethz.ch>
Tue, 12 Jul 2016 09:15:34 +0000 (11:15 +0200)
committerLukas Humbel <lukas.humbel@inf.ethz.ch>
Fri, 29 Jul 2016 11:38:02 +0000 (13:38 +0200)
Signed-off-by: Lukas Humbel <lukas.humbel@inf.ethz.ch>

13 files changed:
capabilities/caps.hl
include/arch/arm/barrelfish/invocations_arch.h
include/arch/x86_64/barrelfish/invocations_arch.h
include/barrelfish/inthandler.h
include/barrelfish_kpi/capabilities.h
kernel/arch/x86_64/irq.c
kernel/arch/x86_64/syscall.c
kernel/capabilities.c
lib/barrelfish/debug.c
lib/barrelfish/inthandler.c
lib/int_route/server/init.c
lib/pci/pci_client.c
usr/acpi/acpica_osglue.c

index 2d97e20..567dc0a 100644 (file)
@@ -401,7 +401,7 @@ cap IRQTable is_always_copy {
 };
 
 cap IRQDest {
-    eq uint64 controller;
+    eq uint64 cpu;
     eq uint64 vector;
 };
 
index 630deaa..0f7f19c 100644 (file)
@@ -523,14 +523,14 @@ static inline errval_t invoke_irqdest_connect(struct capref irqcap, struct capre
     return ret.error;
 }
 
-static inline errval_t invoke_irqdest_get_vector(struct capref irqcap, uint32_t * out_vec)
+static inline errval_t invoke_irqdest_get_vector(struct capref irqcap, uint64_t * out_vec)
 {
     struct sysret ret = cap_invoke1(irqcap, IRQDestCmd_GetVector);
     *out_vec = ret.value;
     return ret.error;
 }
 
-static inline errval_t invoke_irqsrc_get_vector(struct capref irqcap, uint32_t * out_vec)
+static inline errval_t invoke_irqsrc_get_vector(struct capref irqcap, uint64_t * out_vec)
 {
     struct sysret ret = cap_invoke1(irqcap, IRQSrcCmd_GetVector);
     *out_vec = ret.value;
index 9b126a3..62374c1 100644 (file)
@@ -422,14 +422,21 @@ static inline errval_t invoke_irqdest_connect(struct capref irqcap, struct capre
     return ret.error;
 }
 
-static inline errval_t invoke_irqdest_get_vector(struct capref irqcap, uint32_t * out_vec)
+static inline errval_t invoke_irqdest_get_vector(struct capref irqcap, uint64_t * out_vec)
 {
     struct sysret ret = cap_invoke1(irqcap, IRQDestCmd_GetVector);
     *out_vec = ret.value;
     return ret.error;
 }
 
-static inline errval_t invoke_irqsrc_get_vector(struct capref irqcap, uint32_t * out_vec)
+static inline errval_t invoke_irqdest_get_cpu(struct capref irqcap, uint64_t * out_cpu)
+{
+    struct sysret ret = cap_invoke1(irqcap, IRQDestCmd_GetCpu);
+    *out_cpu = ret.value;
+    return ret.error;
+}
+
+static inline errval_t invoke_irqsrc_get_vector(struct capref irqcap, uint64_t * out_vec)
 {
     struct sysret ret = cap_invoke1(irqcap, IRQSrcCmd_GetVector);
     *out_vec = ret.value;
index 2828ed3..987a87e 100644 (file)
@@ -24,9 +24,9 @@ errval_t inthandler_setup_movable_cap(struct capref dest_cap, interrupt_handler_
 errval_t inthandler_setup_movable(interrupt_handler_fn handler, void *handler_arg,
                                   interrupt_handler_fn reloc_handler,
                                   void *reloc_handler_arg,
-                                  uint32_t *ret_vector);
+                                  uint64_t *ret_vector);
 errval_t inthandler_setup(interrupt_handler_fn handler, void *handler_arg,
-                          uint32_t *ret_vector);
+                          uint64_t *ret_vector);
 errval_t inthandler_setup_arm(interrupt_handler_fn handler, void *handler_arg,
         uint32_t irq);
 
index 95ed96c..0e7ec6b 100644 (file)
@@ -431,7 +431,8 @@ enum irqtable_cmd {
 
 enum irqdest_cmd {
        IRQDestCmd_Connect,     ///< Connect this capability to a messaging channel
-       IRQDestCmd_GetVector ///< Return the local interrupt vector
+       IRQDestCmd_GetVector, ///< Return the local interrupt vector
+       IRQDestCmd_GetCpu ///< Return the local interrupt vector
 };
 
 /**
index 6bfafb7..3e9ad25 100644 (file)
@@ -572,7 +572,7 @@ errval_t irq_table_alloc_dest_cap(uint8_t dcn_vbits, capaddr_t dcn, capaddr_t ou
         bitmap_set_true(kcb_current->irq_in_use, i);
 
         out_cap.cap.type = ObjType_IRQDest;
-        out_cap.cap.u.irqdest.controller = my_core_id;
+        out_cap.cap.u.irqdest.cpu = my_core_id;
         out_cap.cap.u.irqdest.vector = i;
 
         struct cte * cn;
@@ -612,7 +612,7 @@ errval_t irq_connect(struct capability *dest_cap, capaddr_t endpoint_adr)
     }
 
     assert(dest_cap->type == ObjType_IRQDest);
-    if(dest_cap->u.irqdest.controller != my_core_id){
+    if(dest_cap->u.irqdest.cpu != my_core_id){
         return SYS_ERR_IRQ_WRONG_CONTROLLER;
     }
 
index d009810..9e5a3b3 100644 (file)
@@ -845,6 +845,15 @@ static struct sysret handle_irqdest_get_vector(struct capability *to, int cmd,
     return ret;
 }
 
+static struct sysret handle_irqdest_get_cpu(struct capability *to, int cmd,
+                                            uintptr_t *args)
+{
+    struct sysret ret;
+    ret.error = SYS_ERR_OK;
+    ret.value = to->u.irqdest.cpu;
+    return ret;
+}
+
 static struct sysret handle_irqdest_connect(struct capability *to, int cmd,
                                             uintptr_t *args)
 {
@@ -1213,7 +1222,8 @@ static invocation_handler_t invocations[ObjType_Num][CAP_MAX_CMD] = {
     },
        [ObjType_IRQDest] = {
         [IRQDestCmd_Connect] = handle_irqdest_connect,
-        [IRQDestCmd_GetVector] = handle_irqdest_get_vector
+        [IRQDestCmd_GetVector] = handle_irqdest_get_vector,
+        [IRQDestCmd_GetCpu] = handle_irqdest_get_cpu
        },
        [ObjType_IRQSrc] = {
         [IRQSrcCmd_GetVector] = handle_irqsrc_get_vector,
index c7a065e..b44f3be 100644 (file)
@@ -248,8 +248,8 @@ int sprint_cap(char *buf, size_t len, struct capability *cap)
         return snprintf(buf, len, "IRQTable cap");
 
     case ObjType_IRQDest:
-        return snprintf(buf, len, "IRQDest cap (vec: %"PRIu64", ctrl: %"PRIu64")",
-                cap->u.irqdest.vector, cap->u.irqdest.controller);
+        return snprintf(buf, len, "IRQDest cap (vec: %"PRIu64", cpu: %"PRIu64")",
+                cap->u.irqdest.vector, cap->u.irqdest.cpu);
 
     case ObjType_EndPoint:
         return snprintf(buf, len, "EndPoint cap (disp %p offset 0x%" PRIxLVADDR ")",
index fee7b45..52e7a66 100644 (file)
@@ -329,8 +329,8 @@ int debug_print_cap(char *buf, size_t len, struct capability *cap)
         return snprintf(buf, len, "IRQTable cap");
 
     case ObjType_IRQDest:
-        return snprintf(buf, len, "IRQDest cap (vec: %"PRIu64", ctrl: %"PRIu64")",
-                cap->u.irqdest.vector, cap->u.irqdest.controller);
+        return snprintf(buf, len, "IRQDest cap (vec: %"PRIu64", cpu: %"PRIu64")",
+                cap->u.irqdest.vector, cap->u.irqdest.cpu);
 
     case ObjType_EndPoint:
         return snprintf(buf, len, "EndPoint cap (disp %p offset 0x%" PRIxLVADDR ")",
index aa6ad22..ffc36bd 100644 (file)
@@ -218,7 +218,7 @@ errval_t inthandler_setup_movable_cap(struct capref dest_cap, interrupt_handler_
 errval_t inthandler_setup_movable(interrupt_handler_fn handler, void *handler_arg,
                                   interrupt_handler_fn reloc_handler,
                                   void *reloc_handler_arg,
-                                  uint32_t *ret_vector)
+                                  uint64_t *ret_vector)
 {
     errval_t err;
 
@@ -283,7 +283,7 @@ errval_t inthandler_setup_movable(interrupt_handler_fn handler, void *handler_ar
 }
 
 errval_t inthandler_setup(interrupt_handler_fn handler, void *handler_arg,
-                          uint32_t *ret_vector)
+                          uint64_t *ret_vector)
 {
 
     return inthandler_setup_movable(handler, handler_arg, NULL, NULL, ret_vector);
index 6831aee..d782323 100644 (file)
@@ -155,16 +155,27 @@ static errval_t read_route_output_and_tell_controllers(void){
     return SYS_ERR_OK;
 }
 
+#define INVALID_VECTOR ((uint64_t)-1)
+
 static void driver_route_call(struct int_route_service_binding *b,
         struct capref intsource, struct capref intdest){
     INT_DEBUG("%s: enter\n", __FUNCTION__);
     errval_t err;
 
-    // TODO find int source number. find int dest cpu and vector.
-    int int_src_num = 27;
-    int dest_cpu = 0;
-    int dest_vec = 32;
-    const char * template = "find_and_add_irq_route(%d,%d,%d).";
+    uint64_t int_src_num = INVALID_VECTOR;
+    err = invoke_irqsrc_get_vector(intsource, &int_src_num);
+    assert(err_is_ok(err));
+
+    uint64_t dest_vec = INVALID_VECTOR;
+    err = invoke_irqdest_get_vector(intdest, &dest_vec);
+    assert(err_is_ok(err));
+
+    //TODO fix this
+    uint64_t dest_cpu = INVALID_VECTOR;
+    err = invoke_irqdest_get_cpu(intdest, &dest_cpu);
+    assert(err_is_ok(err));
+
+    const char * template = "find_and_add_irq_route(%"PRIu64",%"PRIu64",%"PRIu64").";
     int q_size = strlen(template) + 3 * 16;
     char * query = malloc(q_size);
     snprintf(query, q_size, template, int_src_num, dest_cpu, dest_vec);
index 85a8ed9..ed8442e 100644 (file)
@@ -25,7 +25,7 @@
 #include <if/acpi_rpcclient_defs.h>
 #include <acpi_client/acpi_client.h>
 
-#define INVALID_VECTOR ((uint32_t)-1)
+#define INVALID_VECTOR ((uint64_t)-1)
 
 static struct pci_rpc_client *pci_client = NULL;
 
@@ -37,7 +37,7 @@ errval_t pci_reregister_irq_for_device(uint32_t class, uint32_t subclass, uint32
                                        interrupt_handler_fn reloc_handler,
                                        void *reloc_handler_arg)
 {
-    uint32_t vector = INVALID_VECTOR;
+    uint64_t vector = INVALID_VECTOR;
     errval_t err, msgerr;
 
     if (handler != NULL && reloc_handler != NULL) {
@@ -108,7 +108,7 @@ errval_t pci_register_driver_movable_irq(pci_driver_init_fn init_func, uint32_t
         goto out;
     }
 
-    uint32_t gsi = INVALID_VECTOR;
+    uint64_t gsi = INVALID_VECTOR;
     err = invoke_irqsrc_get_vector(irq_src_cap, &gsi);
     if (err_is_fail(err)) {
         DEBUG_ERR(err, "Could not lookup GSI vector");
@@ -123,7 +123,7 @@ errval_t pci_register_driver_movable_irq(pci_driver_init_fn init_func, uint32_t
         DEBUG_ERR(err, "Could not allocate dest irq cap");
         goto out;
     }
-    uint32_t irq_dest_vec = INVALID_VECTOR;
+    uint64_t irq_dest_vec = INVALID_VECTOR;
     err = invoke_irqdest_get_vector(irq_dest_cap, &irq_dest_vec);
     if (err_is_fail(err)) {
         DEBUG_ERR(err, "Could not lookup irq vector");
@@ -248,7 +248,7 @@ errval_t pci_register_legacy_driver_irq(legacy_driver_init_fn init_func,
     errval_t err, msgerr;
     struct capref iocap;
 
-    uint32_t vector = INVALID_VECTOR;
+    uint64_t vector = INVALID_VECTOR;
     err = inthandler_setup(handler, handler_arg, &vector);
     if (err_is_fail(err)) {
         DEBUG_ERR(err, "inthandler_setup()\n");
@@ -285,7 +285,7 @@ errval_t pci_setup_inthandler(interrupt_handler_fn handler, void *handler_arg,
                                       uint8_t *ret_vector)
 {
     errval_t err;
-    uint32_t vector = INVALID_VECTOR;
+    uint64_t vector = INVALID_VECTOR;
     *ret_vector = 0;
     err = inthandler_setup(handler, handler_arg, &vector);
     if (err_is_ok(err)) {
index 3a0db92..58e4a26 100644 (file)
@@ -981,9 +981,9 @@ AcpiOsInstallInterruptHandler (
     ic->handler = ServiceRoutine;
     ic->context = Context;
 
-    uint32_t vector;
+    uint64_t vector;
     errval_t e = inthandler_setup(interrupt_wrapper, ic, &vector);
-    ACPI_DEBUG("Allocated local vec %"PRIu32"\n", vector);
+    ACPI_DEBUG("Allocated local vec %"PRIu64"\n", vector);
     if (err_is_fail(e)) {
         DEBUG_ERR(e, "failed to setup handler function/vector");
         return AE_ERROR;