From ec5d45f50fb95103b44dbeb7ecfa8fb59eb6df6b Mon Sep 17 00:00:00 2001 From: David Cock Date: Thu, 6 Aug 2015 13:16:38 +0200 Subject: [PATCH] Made errval_t a flounder builtin. The errval type is used internally by flounder, but has since been duplicated to be passed around through interfaces by user code. This led to a proliferation of ifname_errval_t types, which were used interchangably in user-level code. This breaks once strict typedef checking is enforced, as in recent GCC versions. This is a bandaid fix, and there's a larger underlying issue still to be resolved around how to deal with globally-defined types in flounder. Signed-off-by: David Cock --- if/intermon.if | 78 ++++++++++---------- if/monitor.if | 24 +++--- include/arch/arm/barrelfish_kpi/registers_arch.h | 2 +- .../arch/x86_32/barrelfish_kpi/registers_arch.h | 2 +- .../arch/x86_64/barrelfish_kpi/registers_arch.h | 2 +- tools/flounder/AHCI.hs | 2 +- tools/flounder/MsgFragments.hs | 1 + tools/flounder/Parser.hs | 2 +- tools/flounder/Syntax.lhs | 3 + 9 files changed, 60 insertions(+), 56 deletions(-) diff --git a/if/intermon.if b/if/intermon.if index ba3bd5c..8fa45f9 100644 --- a/if/intermon.if +++ b/if/intermon.if @@ -10,20 +10,20 @@ interface intermon "The Interface between monitors" { /* XXX Aliases for base system types */ - alias coreid_t uint8; - alias chanid_t uint32; + alias coreid uint8; + alias chanid uint32; /* Types which we may need to change at some point, especially on a heterogeneous platform, or 32-bit only platform */ - alias con_id_t uint64; - alias mon_id_t uint64; - alias state_id_t uint64; - alias vci_t uint64; - - alias capid_t uint32; - alias capaddr_t uint32; - alias capbits_t uint8; - alias capslot_t uint32; + alias con_id uint64; + alias mon_id uint64; + alias state_id uint64; + alias vci uint64; + + alias capid uint32; + alias capaddr uint32; + alias capbits uint8; + alias capslot uint32; alias capop_st uint64; /* XXX depends on MAX_COREID and definition of coremask_t in types.h */ @@ -38,9 +38,9 @@ interface intermon "The Interface between monitors" { } caprep; typedef struct { - capaddr_t cnptr; - capbits_t cnbits; - capslot_t slot; + capaddr cnptr; + capbits cnbits; + capslot slot; } captx; message spawnd_image_request(); @@ -72,46 +72,46 @@ interface intermon "The Interface between monitors" { */ message capops_ready(); message monitor_initialized(); - message new_monitor_notify(coreid_t core_id); - message bind_monitor_proxy(coreid_t dst_core_id, caprep cap); - call bind_monitor_request(coreid_t core_id, caprep cap); + message new_monitor_notify(coreid core_id); + message bind_monitor_proxy(coreid dst_core_id, caprep cap); + call bind_monitor_request(coreid core_id, caprep cap); response bind_monitor_reply(errval err); - message bind_monitor_request_scc(coreid_t core_id, + message bind_monitor_request_scc(coreid core_id, caprep cap, - chanid_t chan_id, - coreid_t from_core_id); + chanid chan_id, + coreid from_core_id); message bind_monitor_reply_scc(errval err, - chanid_t chan_id, - coreid_t core_id); - message bind_monitor_proxy_scc(coreid_t dst_core_id, + chanid chan_id, + coreid core_id); + message bind_monitor_proxy_scc(coreid dst_core_id, caprep cap, - chanid_t chan_id, - coreid_t core_id); + chanid chan_id, + coreid core_id); message bind_ump_request(iref iref, - mon_id_t mon_id, + mon_id mon_id, uint32 channel_length_in, uint32 channel_length_out, genpaddr framebase, uint8 framebits, caprep notify); - message bind_ump_reply(con_id_t con_id, - mon_id_t mon_id, + message bind_ump_reply(con_id con_id, + mon_id mon_id, errval err, caprep notify); - message cap_send_request(con_id_t con_id, - capid_t capid, + message cap_send_request(con_id con_id, + capid capid, captx cap); - message span_domain_request(state_id_t state_id, + message span_domain_request(state_id state_id, genpaddr vnodebase, genpaddr framebase, uint8 framebits); - message span_domain_reply(state_id_t state_id, errval err); + message span_domain_reply(state_id state_id, errval err); // Resource control - message rsrc_join(rsrcid id, coreid_t coreid); + message rsrc_join(rsrcid id, coreid coreid); message rsrc_join_complete(rsrcid id); message rsrc_phase_data(rsrcid id, uint32 phase, uint8 data[len]); message rsrc_timer_sync(uint64 timestamp); @@ -136,20 +136,20 @@ interface intermon "The Interface between monitors" { message multihop_routing_table_grow(coreid forwarder, coreid destinations[len]); // set up a new multihop virtual circuit - message bind_multihop_intermon_request(iref iref, vci_t sender_vci, + message bind_multihop_intermon_request(iref iref, vci sender_vci, coreid core_id); - message bind_multihop_intermon_reply(vci_t receiver_vci, vci_t sender_vci, + message bind_multihop_intermon_reply(vci receiver_vci, vci sender_vci, errval err); - message multihop_message(vci_t vci, uint8 direction, uint8 flags, uint32 ack, + message multihop_message(vci vci, uint8 direction, uint8 flags, uint32 ack, uint8 payload[size]); - message multihop_cap_send(vci_t vci, uint8 direction, capid_t capid, errval err, + message multihop_cap_send(vci vci, uint8 direction, capid capid, errval err, caprep cap, bool null_cap, coreid owner); // cap operation messages message capops_request_copy(coreid dest, caprep cap, capop_st st); message capops_recv_copy(caprep cap, uint8 owner_relations, capop_st st); - message capops_recv_copy_result(errval status, capaddr_t cap, capbits_t bits, capslot_t slot, capop_st st); + message capops_recv_copy_result(errval status, capaddr cap, capbits bits, capslot slot, capop_st st); message capops_move_request(caprep cap, uint8 relations, capop_st st); message capops_move_result(errval status, capop_st st); @@ -189,7 +189,7 @@ interface intermon "The Interface between monitors" { // Notify core 0 that you want to make a time measurement (Network Time // Protocol). The origin core is the one who initiated the trace preparation. - call trace_measure(coreid_t origin_core, uint64 t0); + call trace_measure(coreid origin_core, uint64 t0); // The response to a measurement call from a core. response trace_measure_ack(coreid origin_core, uint64 t0, uint64 t1, uint64 t2); diff --git a/if/monitor.if b/if/monitor.if index 8e37190..3fbe686 100644 --- a/if/monitor.if +++ b/if/monitor.if @@ -8,8 +8,8 @@ */ interface monitor "The monitor to client Interface" { - alias vci_t uint64; - alias capid_t uint32; + alias vci uint64; + alias capid uint32; call alloc_iref_request( uintptr service_id); @@ -119,16 +119,16 @@ interface monitor "The monitor to client Interface" { call cap_send_request( uintptr mon_id, cap cap, - capid_t capid); + capid capid); call cap_move_request( uintptr mon_id, give_away_cap cap, - capid_t capid); + capid capid); response cap_receive_request( uintptr conn_id, errval err, give_away_cap cap, - capid_t capid); + capid capid); call span_domain_request( uintptr domain_id, @@ -164,22 +164,22 @@ interface monitor "The monitor to client Interface" { call multihop_routing_table_set(coreid from, coreid to[len]); // Connection set-up between monitor and client - call multihop_bind_client_request(iref iref, vci_t sender_vci); - response multihop_bind_client_reply(vci_t receiver_vci, vci_t sender_vci, + call multihop_bind_client_request(iref iref, vci sender_vci); + response multihop_bind_client_reply(vci receiver_vci, vci sender_vci, errval err); // Connection set-up between monitor and service - call multihop_bind_service_request(uintptr service_id, vci_t sender_vci); - response multihop_bind_service_reply(vci_t receiver_vci , vci_t sender_vci, + call multihop_bind_service_request(uintptr service_id, vci sender_vci); + response multihop_bind_service_reply(vci receiver_vci , vci sender_vci, errval err); // user message - message multihop_message(vci_t vci, uint8 direction, uint8 flags, uint32 ack, + message multihop_message(vci vci, uint8 direction, uint8 flags, uint32 ack, uint8 payload[size]); // cap transfer - call multihop_cap_send(vci_t vci, uint8 direction, errval err, cap cap, - capid_t capid); + call multihop_cap_send(vci vci, uint8 direction, errval err, cap cap, + capid capid); /* Tracing Framework */ diff --git a/include/arch/arm/barrelfish_kpi/registers_arch.h b/include/arch/arm/barrelfish_kpi/registers_arch.h index d6213fa..a7fe793 100644 --- a/include/arch/arm/barrelfish_kpi/registers_arch.h +++ b/include/arch/arm/barrelfish_kpi/registers_arch.h @@ -113,7 +113,7 @@ registers_set_param(arch_registers_state_t *regs, uint32_t param) } static inline void -registers_get_param(arch_registers_state_t *regs, uint32_t *param) +registers_get_param(arch_registers_state_t *regs, uintptr_t *param) { *param = regs->named.r0; } diff --git a/include/arch/x86_32/barrelfish_kpi/registers_arch.h b/include/arch/x86_32/barrelfish_kpi/registers_arch.h index d1b5889..ae8bda5 100644 --- a/include/arch/x86_32/barrelfish_kpi/registers_arch.h +++ b/include/arch/x86_32/barrelfish_kpi/registers_arch.h @@ -38,7 +38,7 @@ registers_set_param(arch_registers_state_t *regs, uint32_t param) } static inline void -registers_get_param(arch_registers_state_t *regs, uint32_t *param) +registers_get_param(arch_registers_state_t *regs, uintptr_t *param) { registers_x86_32_get_param(regs, param); } diff --git a/include/arch/x86_64/barrelfish_kpi/registers_arch.h b/include/arch/x86_64/barrelfish_kpi/registers_arch.h index 85f8109..f19e976 100644 --- a/include/arch/x86_64/barrelfish_kpi/registers_arch.h +++ b/include/arch/x86_64/barrelfish_kpi/registers_arch.h @@ -38,7 +38,7 @@ registers_set_param(arch_registers_state_t *regs, uint64_t param) } static inline void -registers_get_param(arch_registers_state_t *regs, uint64_t *param) +registers_get_param(arch_registers_state_t *regs, uintptr_t *param) { registers_x86_64_get_param(regs, param); } diff --git a/tools/flounder/AHCI.hs b/tools/flounder/AHCI.hs index bdb274c..68878fb 100644 --- a/tools/flounder/AHCI.hs +++ b/tools/flounder/AHCI.hs @@ -439,7 +439,7 @@ cc_rx_fn ifn types msg@(RPC name rpcargs metaargs) = vtbl = gen_binding `C.FieldOf` "rx_vtbl" pr_region_var = C.Variable "completed_st" `C.DerefField` "dma_region" output_arg_expr :: Maybe Direction -> MessageArgument -> [C.Expr] - output_arg_expr _ (Arg (TypeAlias "errval" _) (Name "status")) = [C.Variable "SYS_ERR_OK"] + output_arg_expr _ (Arg (Builtin ErrVal) (Name "status")) = [C.Variable "SYS_ERR_OK"] output_arg_expr (Just RX) (Arg (Builtin UInt8) (DynamicArray _ _)) = [C.Variable dma_data_name, dma_size] output_arg_expr _ arg = error ("unrecoginized output argument " ++ (show arg)) diff --git a/tools/flounder/MsgFragments.hs b/tools/flounder/MsgFragments.hs index c5c9774..ff33191 100644 --- a/tools/flounder/MsgFragments.hs +++ b/tools/flounder/MsgFragments.hs @@ -233,6 +233,7 @@ bitsizeof_builtin _ IRef = 32 -- FIXME: move out of flounder bitsizeof_builtin _ Char = 8 bitsizeof_builtin _ String = undefined bitsizeof_builtin _ Cap = undefined +bitsizeof_builtin _ ErrVal = 32 bitsizeof_builtin _ GiveAwayCap = undefined diff --git a/tools/flounder/Parser.hs b/tools/flounder/Parser.hs index 6d8a5f9..5eaab5f 100644 --- a/tools/flounder/Parser.hs +++ b/tools/flounder/Parser.hs @@ -57,7 +57,7 @@ semiSep = P.semiSep lexer symbol = P.symbol lexer natural = P.natural lexer -builtinTypes = map show [UInt8 ..] ++ ["int"] -- int is legacy -AB +builtinTypes = map show [UInt8 ..] ++ ["errval"] ++ ["int"] -- int is legacy -AB -- identifyBuiltin :: [(String, Declaration)] -> String -> TypeRef identifyBuiltin typeDcls typeName = diff --git a/tools/flounder/Syntax.lhs b/tools/flounder/Syntax.lhs index 2eaa1c4..ee29ad5 100644 --- a/tools/flounder/Syntax.lhs +++ b/tools/flounder/Syntax.lhs @@ -107,6 +107,7 @@ The builtin types being: > | IRef > | Cap > | GiveAwayCap +> | ErrVal > deriving (Enum, Eq) Which are shown with: @@ -129,6 +130,7 @@ Which are shown with: > show IRef = "iref" > show Cap = "cap" > show GiveAwayCap = "give_away_cap" +> show ErrVal = "errval" > instance Read TypeBuiltin where > readsPrec _ = \s -> case s of @@ -150,6 +152,7 @@ Which are shown with: > "iref" -> [(IRef, "")] > "cap" -> [(Cap, "")] > "give_away_cap" -> [(GiveAwayCap, "")] +> "errval" -> [(ErrVal, "")] > _ -> error $ "Undefined builtin type " ++ s Hence, we can define: -- 1.7.2.5