# HG changeset patch # User Paul Boddie # Date 1687186761 -7200 # Node ID 6ea03e9655d433a26e7ba6bea9743de63bbb1235 # Parent 04b175ff12cf59a89bde0f7fefc569e1abddfa44 Updated API usage in another example. diff -r 04b175ff12cf -r 6ea03e9655d4 pkg/landfall-examples/qi_lb60_keypad_physical/Makefile --- a/pkg/landfall-examples/qi_lb60_keypad_physical/Makefile Mon Jun 19 16:58:52 2023 +0200 +++ b/pkg/landfall-examples/qi_lb60_keypad_physical/Makefile Mon Jun 19 16:59:21 2023 +0200 @@ -2,7 +2,35 @@ L4DIR ?= $(PKGDIR)/../.. TARGET = ex_qi_lb60_keypad_physical -SRC_C = qi_lb60_keypad_physical.c -REQUIRES_LIBS = l4re_c-util + +# Locations for interface input and generated output. + +IDL_DIR = $(L4DIR)/pkg/devices/idl +IDL_MK_DIR = $(L4DIR)/idl4re/mk +IDL_BUILD_DIR = . +IDL_EXPORT_DIR = . + +include $(IDL_MK_DIR)/idl.mk + +# Individual interfaces. + +CLIENT_INTERFACES_C = keypad + +# Generated and plain source files. + +CLIENT_INTERFACES_SRC_C = $(call interfaces_to_client_c,$(CLIENT_INTERFACES_C)) + +PLAIN_SRC_C = qi_lb60_keypad_physical.c + +# Normal definitions. + +SRC_C = $(CLIENT_INTERFACES_SRC_C) $(PLAIN_SRC_C) + +REQUIRES_LIBS = l4re_c l4re_c-util libipc + +PRIVATE_INCDIR = $(IDL_BUILD_DIR) $(IDL_EXPORT_DIR) include $(L4DIR)/mk/prog.mk +include $(IDL_MK_DIR)/interface_rules.mk + +$(PLAIN_SRC_C): $(CLIENT_INTERFACES_SRC_C) diff -r 04b175ff12cf -r 6ea03e9655d4 pkg/landfall-examples/qi_lb60_keypad_physical/qi_lb60_keypad_physical.c --- a/pkg/landfall-examples/qi_lb60_keypad_physical/qi_lb60_keypad_physical.c Mon Jun 19 16:58:52 2023 +0200 +++ b/pkg/landfall-examples/qi_lb60_keypad_physical/qi_lb60_keypad_physical.c Mon Jun 19 16:59:21 2023 +0200 @@ -20,20 +20,19 @@ */ #include -#include #include -#include -#include #include #include -#include -#include #include #include #include +#include "keypad_client.h" + + + enum Jz4740_keypad_gpio { Jz4740_keypad_gpio_inputs_count = 8, @@ -48,8 +47,7 @@ /* Keypad status and dimensions. */ -uint32_t *keypad = 0; -void *keymem = 0; +uint32_t *keymem = 0; int columns = Jz4740_keypad_gpio_outputs_count, rows = Jz4740_keypad_gpio_inputs_count; /* Position units. */ @@ -246,7 +244,7 @@ /* Plot the rectangle for the key. */ fill_rectangle((pos[0] * fbi.width) / WIDTH, pos[1] * rowsize, colsize, rowsize, - keypad[column] & mask ? 0xffffff : 0); + keymem[column] & mask ? 0xffffff : 0); } /* Refresh the display. */ @@ -258,9 +256,8 @@ int main(void) { - l4_cap_idx_t keypad_server; + l4_cap_idx_t keypad_cap; l4re_ds_t mem; - l4_msgtag_t tag; if (l4re_util_video_goos_fb_setup_name(&gfb, "fb")) return 1; @@ -273,28 +270,21 @@ /* Obtain a reference to the keypad. */ - keypad_server = l4re_env_get_cap("keypad"); - if (l4_is_invalid_cap(keypad_server)) return 1; + keypad_cap = l4re_env_get_cap("keypad"); - /* Obtain a capability for the keypad data. */ - - mem = l4re_util_cap_alloc(); - if (l4_is_invalid_cap(mem)) return 1; + if (l4_is_invalid_cap(keypad_cap)) + return 1; /* Obtain a reference to the keypad data. */ - l4_utcb_br()->bdr = 0; - l4_utcb_br()->br[0] = L4_RCV_ITEM_SINGLE_CAP | mem; + Keypad keypad = {.ref={.cap=keypad_cap}, .iface=&client_iface_Keypad}; - tag = l4_ipc_call(keypad_server, l4_utcb(), - l4_msgtag(0, 0, 0, 0), /* label zero, zero words, zero *sent* items */ - L4_IPC_NEVER); - - if (l4_ipc_error(tag, l4_utcb())) return 1; + if (keypad.iface->get_keypad_data(keypad.ref, &mem)) + return 1; /* Attach the keypad data to a region in this task. */ - if (l4re_rm_attach(&keymem, l4re_ds_size(mem), + if (l4re_rm_attach((void **) &keymem, l4re_ds_size(mem), L4RE_RM_F_SEARCH_ADDR | L4RE_RM_F_R, mem, 0, L4_PAGESHIFT)) @@ -302,9 +292,8 @@ /* Show the keypad state. */ - keypad = (uint32_t *) keymem; - - while (1) show_keypad(); + while (1) + show_keypad(); return 0; }