WIP - Add intermediaries

Change-Id: I586c19a71e16c033ebaf4987552f57bcf4a10055
diff --git a/kernel/lib/magenta/include/magenta/gen-del-sysdefs.h b/kernel/lib/magenta/include/magenta/gen-del-sysdefs.h
new file mode 100644
index 0000000..16f279d
--- /dev/null
+++ b/kernel/lib/magenta/include/magenta/gen-del-sysdefs.h
@@ -0,0 +1,636 @@
+// Copyright 2017 The Fuchsia Authors. All rights reserved.
+// This is a GENERATED file. The license governing this file can be found in the LICENSE file.
+
+mx_time_t delegate_sys_time_get(
+    uint32_t clock_id);
+
+mx_status_t delegate_sys_nanosleep(
+    mx_time_t nanoseconds);
+
+uint64_t delegate_sys_ticks_get();
+
+uint64_t delegate_sys_ticks_per_second();
+
+uint32_t delegate_sys_num_cpus();
+
+mx_status_t delegate_sys_version_get(
+    char version[],
+    uint32_t version_len);
+
+mx_status_t delegate_sys_cache_flush(
+    const void* addr,
+    size_t len,
+    uint32_t flags);
+
+mx_status_t delegate_sys_handle_close(
+    mx_handle_t handle);
+
+mx_status_t delegate_sys_handle_duplicate(
+    mx_handle_t handle,
+    mx_rights_t rights,
+    mx_handle_t out[1]);
+
+mx_status_t delegate_sys_handle_replace(
+    mx_handle_t handle,
+    mx_rights_t rights,
+    mx_handle_t out[1]);
+
+mx_status_t delegate_sys_handle_wait_one(
+    mx_handle_t handle,
+    mx_signals_t waitfor,
+    mx_time_t timeout,
+    mx_signals_t observed[1]);
+
+mx_status_t delegate_sys_handle_wait_many(
+    mx_wait_item_t items[],
+    uint32_t count,
+    mx_time_t timeout);
+
+mx_status_t delegate_sys_object_signal(
+    mx_handle_t handle,
+    uint32_t clear_mask,
+    uint32_t set_mask);
+
+mx_status_t delegate_sys_object_signal_peer(
+    mx_handle_t handle,
+    uint32_t clear_mask,
+    uint32_t set_mask);
+
+mx_status_t delegate_sys_object_get_property(
+    mx_handle_t handle,
+    uint32_t property,
+    void* value,
+    size_t size);
+
+mx_status_t delegate_sys_object_set_property(
+    mx_handle_t handle,
+    uint32_t property,
+    const void* value,
+    size_t size);
+
+mx_status_t delegate_sys_object_get_info(
+    mx_handle_t handle,
+    uint32_t topic,
+    void* buffer,
+    size_t buffer_size,
+    size_t actual_count[1],
+    size_t avail_count[1]);
+
+mx_status_t delegate_sys_object_get_child(
+    mx_handle_t handle,
+    uint64_t koid,
+    mx_rights_t rights,
+    mx_handle_t out[1]);
+
+mx_status_t delegate_sys_object_bind_exception_port(
+    mx_handle_t object,
+    mx_handle_t eport,
+    uint64_t key,
+    uint32_t options);
+
+mx_status_t delegate_sys_channel_create(
+    uint32_t options,
+    mx_handle_t out0[1],
+    mx_handle_t out1[1]);
+
+mx_status_t delegate_sys_channel_read(
+    mx_handle_t handle,
+    uint32_t options,
+    void* bytes,
+    uint32_t num_bytes,
+    uint32_t actual_bytes[1],
+    mx_handle_t handles[],
+    uint32_t num_handles,
+    uint32_t actual_handles[1]);
+
+mx_status_t delegate_sys_channel_write(
+    mx_handle_t handle,
+    uint32_t options,
+    const void* bytes,
+    uint32_t num_bytes,
+    const mx_handle_t handles[],
+    uint32_t num_handles);
+
+mx_status_t delegate_sys_channel_call(
+    mx_handle_t handle,
+    uint32_t options,
+    mx_time_t timeout,
+    const mx_channel_call_args_t args[1],
+    uint32_t actual_bytes[1],
+    uint32_t actual_handles[1],
+    mx_status_t read_status[1]);
+
+mx_status_t delegate_sys_socket_create(
+    uint32_t options,
+    mx_handle_t out0[1],
+    mx_handle_t out1[1]);
+
+mx_status_t delegate_sys_socket_write(
+    mx_handle_t handle,
+    uint32_t options,
+    const void* buffer,
+    size_t size,
+    size_t actual[1]);
+
+mx_status_t delegate_sys_socket_read(
+    mx_handle_t handle,
+    uint32_t options,
+    void* buffer,
+    size_t size,
+    size_t actual[1]);
+
+void delegate_sys_thread_exit();
+
+mx_status_t delegate_sys_thread_create(
+    mx_handle_t process,
+    const char name[],
+    uint32_t name_len,
+    uint32_t options,
+    mx_handle_t out[1]);
+
+mx_status_t delegate_sys_thread_start(
+    mx_handle_t handle,
+    uintptr_t thread_entry,
+    uintptr_t stack,
+    uintptr_t arg1,
+    uintptr_t arg2);
+
+mx_status_t delegate_sys_thread_read_state(
+    mx_handle_t handle,
+    uint32_t kind,
+    void* buffer,
+    uint32_t len,
+    uint32_t actual[1]);
+
+mx_status_t delegate_sys_thread_write_state(
+    mx_handle_t handle,
+    uint32_t kind,
+    const void* buffer,
+    uint32_t buffer_len);
+
+void delegate_sys_process_exit(
+    int retcode);
+
+mx_status_t delegate_sys_process_create(
+    mx_handle_t job,
+    const char name[],
+    uint32_t name_len,
+    uint32_t options,
+    mx_handle_t proc_handle[1],
+    mx_handle_t vmar_handle[1]);
+
+mx_status_t delegate_sys_process_start(
+    mx_handle_t process_handle,
+    mx_handle_t thread_handle,
+    uintptr_t entry,
+    uintptr_t stack,
+    mx_handle_t arg_handle,
+    uintptr_t arg2);
+
+mx_status_t delegate_sys_process_read_memory(
+    mx_handle_t proc,
+    uintptr_t vaddr,
+    void* buffer,
+    size_t len,
+    size_t actual[1]);
+
+mx_status_t delegate_sys_process_write_memory(
+    mx_handle_t proc,
+    uintptr_t vaddr,
+    const void* buffer,
+    size_t len,
+    size_t actual[1]);
+
+mx_status_t delegate_sys_job_create(
+    mx_handle_t parent_job,
+    uint32_t options,
+    mx_handle_t out[1]);
+
+mx_status_t delegate_sys_task_resume(
+    mx_handle_t task_handle,
+    uint32_t options);
+
+mx_status_t delegate_sys_task_kill(
+    mx_handle_t task_handle);
+
+mx_status_t delegate_sys_event_create(
+    uint32_t options,
+    mx_handle_t out[1]);
+
+mx_status_t delegate_sys_eventpair_create(
+    uint32_t options,
+    mx_handle_t out0[1],
+    mx_handle_t out1[1]);
+
+mx_status_t delegate_sys_futex_wait(
+    mx_futex_t value_ptr[1],
+    int current_value,
+    mx_time_t timeout);
+
+mx_status_t delegate_sys_futex_wake(
+    mx_futex_t value_ptr[1],
+    uint32_t count);
+
+mx_status_t delegate_sys_futex_requeue(
+    mx_futex_t wake_ptr[1],
+    uint32_t wake_count,
+    int current_value,
+    mx_futex_t requeue_ptr[1],
+    uint32_t requeue_count);
+
+mx_status_t delegate_sys_waitset_create(
+    uint32_t options,
+    mx_handle_t out[1]);
+
+mx_status_t delegate_sys_waitset_add(
+    mx_handle_t waitset_handle,
+    uint64_t cookie,
+    mx_handle_t handle,
+    mx_signals_t signals);
+
+mx_status_t delegate_sys_waitset_remove(
+    mx_handle_t waitset_handle,
+    uint64_t cookie);
+
+mx_status_t delegate_sys_waitset_wait(
+    mx_handle_t waitset_handle,
+    mx_time_t timeout,
+    mx_waitset_result_t results[],
+    uint32_t count[1]);
+
+mx_status_t delegate_sys_port_create(
+    uint32_t options,
+    mx_handle_t out[1]);
+
+mx_status_t delegate_sys_port_queue(
+    mx_handle_t handle,
+    const void* packet,
+    size_t size);
+
+mx_status_t delegate_sys_port_wait(
+    mx_handle_t handle,
+    mx_time_t timeout,
+    void* packet,
+    size_t size);
+
+mx_status_t delegate_sys_port_bind(
+    mx_handle_t handle,
+    uint64_t key,
+    mx_handle_t source,
+    mx_signals_t signals);
+
+mx_status_t delegate_sys_vmo_create(
+    uint64_t size,
+    uint32_t options,
+    mx_handle_t out[1]);
+
+mx_status_t delegate_sys_vmo_read(
+    mx_handle_t handle,
+    void* data,
+    uint64_t offset,
+    size_t len,
+    size_t actual[1]);
+
+mx_status_t delegate_sys_vmo_write(
+    mx_handle_t handle,
+    const void* data,
+    uint64_t offset,
+    size_t len,
+    size_t actual[1]);
+
+mx_status_t delegate_sys_vmo_get_size(
+    mx_handle_t handle,
+    uint64_t size[1]);
+
+mx_status_t delegate_sys_vmo_set_size(
+    mx_handle_t handle,
+    uint64_t size);
+
+mx_status_t delegate_sys_vmo_op_range(
+    mx_handle_t handle,
+    uint32_t op,
+    uint64_t offset,
+    uint64_t size,
+    void* buffer,
+    size_t buffer_size);
+
+mx_status_t delegate_sys_cprng_draw(
+    void* buffer,
+    size_t len,
+    size_t actual[1]);
+
+mx_status_t delegate_sys_cprng_add_entropy(
+    const void* buffer,
+    size_t len);
+
+mx_status_t delegate_sys_fifo0_create(
+    uint64_t count,
+    mx_handle_t out[1]);
+
+mx_status_t delegate_sys_fifo0_op(
+    mx_handle_t handle,
+    uint32_t op,
+    uint64_t val,
+    mx_fifo_state_t out[1]);
+
+mx_status_t delegate_sys_log_create(
+    uint32_t options,
+    mx_handle_t out[1]);
+
+mx_status_t delegate_sys_log_write(
+    mx_handle_t handle,
+    uint32_t len,
+    const void* buffer,
+    uint32_t options);
+
+mx_status_t delegate_sys_log_read(
+    mx_handle_t handle,
+    uint32_t len,
+    void* buffer,
+    uint32_t options);
+
+mx_status_t delegate_sys_ktrace_read(
+    mx_handle_t handle,
+    void* data,
+    uint32_t offset,
+    uint32_t len,
+    uint32_t actual[1]);
+
+mx_status_t delegate_sys_ktrace_control(
+    mx_handle_t handle,
+    uint32_t action,
+    uint32_t options,
+    void* ptr);
+
+mx_status_t delegate_sys_ktrace_write(
+    mx_handle_t handle,
+    uint32_t id,
+    uint32_t arg0,
+    uint32_t arg1);
+
+mx_status_t delegate_sys_mtrace_control(
+    mx_handle_t handle,
+    uint32_t kind,
+    uint32_t action,
+    uint32_t options,
+    void* ptr,
+    uint32_t size);
+
+mx_handle_t delegate_sys_debug_transfer_handle(
+    mx_handle_t proc,
+    mx_handle_t handle);
+
+mx_status_t delegate_sys_debug_read(
+    mx_handle_t handle,
+    void* buffer,
+    uint32_t length);
+
+mx_status_t delegate_sys_debug_write(
+    const void* buffer,
+    uint32_t length);
+
+mx_status_t delegate_sys_debug_send_command(
+    mx_handle_t resource_handle,
+    const void* buffer,
+    uint32_t length);
+
+mx_handle_t delegate_sys_interrupt_create(
+    mx_handle_t handle,
+    uint32_t vector,
+    uint32_t options);
+
+mx_status_t delegate_sys_interrupt_complete(
+    mx_handle_t handle);
+
+mx_status_t delegate_sys_interrupt_wait(
+    mx_handle_t handle);
+
+mx_status_t delegate_sys_mmap_device_io(
+    mx_handle_t handle,
+    uint32_t io_addr,
+    uint32_t len);
+
+mx_status_t delegate_sys_mmap_device_memory(
+    mx_handle_t handle,
+    mx_paddr_t paddr,
+    uint32_t len,
+    mx_cache_policy_t cache_policy,
+    uintptr_t out_vaddr[1]);
+
+mx_status_t delegate_sys_io_mapping_get_info(
+    mx_handle_t handle,
+    uintptr_t out_vaddr[1],
+    uint64_t out_size[1]);
+
+mx_status_t delegate_sys_vmo_create_contiguous(
+    mx_handle_t rsrc_handle,
+    size_t size,
+    uint32_t alignment_log2,
+    mx_handle_t out[1]);
+
+mx_status_t delegate_sys_vmar_allocate(
+    mx_handle_t parent_vmar_handle,
+    size_t offset,
+    size_t size,
+    uint32_t flags,
+    mx_handle_t child_vmar[1],
+    uintptr_t child_addr[1]);
+
+mx_status_t delegate_sys_vmar_destroy(
+    mx_handle_t vmar_handle);
+
+mx_status_t delegate_sys_vmar_map(
+    mx_handle_t vmar_handle,
+    size_t vmar_offset,
+    mx_handle_t vmo_handle,
+    uint64_t vmo_offset,
+    size_t len,
+    uint32_t flags,
+    uintptr_t mapped_addr[1]);
+
+mx_status_t delegate_sys_vmar_unmap(
+    mx_handle_t vmar_handle,
+    uintptr_t addr,
+    size_t len);
+
+mx_status_t delegate_sys_vmar_protect(
+    mx_handle_t vmar_handle,
+    uintptr_t addr,
+    size_t len,
+    uint32_t prot);
+
+mx_status_t delegate_sys_bootloader_fb_get_info(
+    uint32_t format[1],
+    uint32_t width[1],
+    uint32_t height[1],
+    uint32_t stride[1]);
+
+mx_status_t delegate_sys_set_framebuffer(
+    mx_handle_t handle,
+    void* vaddr,
+    uint32_t len,
+    uint32_t format,
+    uint32_t width,
+    uint32_t height,
+    uint32_t stride);
+
+mx_status_t delegate_sys_clock_adjust(
+    mx_handle_t handle,
+    uint32_t clock_id,
+    int64_t offset);
+
+mx_handle_t delegate_sys_pci_get_nth_device(
+    mx_handle_t handle,
+    uint32_t index,
+    mx_pcie_get_nth_info_t out_info[1]);
+
+mx_status_t delegate_sys_pci_claim_device(
+    mx_handle_t handle);
+
+mx_status_t delegate_sys_pci_enable_bus_master(
+    mx_handle_t handle,
+    bool enable);
+
+mx_status_t delegate_sys_pci_enable_pio(
+    mx_handle_t handle,
+    bool enable);
+
+mx_status_t delegate_sys_pci_reset_device(
+    mx_handle_t handle);
+
+mx_handle_t delegate_sys_pci_map_mmio(
+    mx_handle_t handle,
+    uint32_t bar_num,
+    mx_cache_policy_t cache_policy);
+
+mx_status_t delegate_sys_pci_io_write(
+    mx_handle_t handle,
+    uint32_t bar_num,
+    uint32_t offset,
+    uint32_t len,
+    uint32_t value);
+
+mx_status_t delegate_sys_pci_io_read(
+    mx_handle_t handle,
+    uint32_t bar_num,
+    uint32_t offset,
+    uint32_t len,
+    uint32_t out_value[1]);
+
+mx_handle_t delegate_sys_pci_map_interrupt(
+    mx_handle_t handle,
+    int32_t which_irq);
+
+mx_handle_t delegate_sys_pci_map_config(
+    mx_handle_t handle);
+
+mx_status_t delegate_sys_pci_query_irq_mode_caps(
+    mx_handle_t handle,
+    uint32_t mode,
+    uint32_t out_max_irqs[1]);
+
+mx_status_t delegate_sys_pci_set_irq_mode(
+    mx_handle_t handle,
+    uint32_t mode,
+    uint32_t requested_irq_count);
+
+mx_status_t delegate_sys_pci_init(
+    mx_handle_t handle,
+    const mx_pci_init_arg_t init_buf[],
+    uint32_t len);
+
+mx_status_t delegate_sys_pci_add_subtract_io_range(
+    mx_handle_t handle,
+    bool mmio,
+    uint64_t base,
+    uint64_t len,
+    bool add);
+
+uint32_t delegate_sys_acpi_uefi_rsdp(
+    mx_handle_t handle);
+
+mx_status_t delegate_sys_acpi_cache_flush(
+    mx_handle_t handle);
+
+mx_status_t delegate_sys_resource_create(
+    mx_handle_t parent_handle,
+    const mx_rrec_t records[],
+    uint32_t count,
+    mx_handle_t resource_out[1]);
+
+mx_status_t delegate_sys_resource_get_handle(
+    mx_handle_t handle,
+    uint32_t index,
+    uint32_t options,
+    mx_handle_t out[1]);
+
+mx_status_t delegate_sys_resource_do_action(
+    mx_handle_t handle,
+    uint32_t index,
+    uint32_t action,
+    uint32_t arg0,
+    uint32_t arg1);
+
+mx_status_t delegate_sys_resource_connect(
+    mx_handle_t handle,
+    mx_handle_t channel);
+
+mx_status_t delegate_sys_resource_accept(
+    mx_handle_t handle,
+    mx_handle_t channel[1]);
+
+int delegate_sys_syscall_test_0();
+
+int delegate_sys_syscall_test_1(
+    int a);
+
+int delegate_sys_syscall_test_2(
+    int a,
+    int b);
+
+int delegate_sys_syscall_test_3(
+    int a,
+    int b,
+    int c);
+
+int delegate_sys_syscall_test_4(
+    int a,
+    int b,
+    int c,
+    int d);
+
+int delegate_sys_syscall_test_5(
+    int a,
+    int b,
+    int c,
+    int d,
+    int e);
+
+int delegate_sys_syscall_test_6(
+    int a,
+    int b,
+    int c,
+    int d,
+    int e,
+    int f);
+
+int delegate_sys_syscall_test_7(
+    int a,
+    int b,
+    int c,
+    int d,
+    int e,
+    int f,
+    int g);
+
+int delegate_sys_syscall_test_8(
+    int a,
+    int b,
+    int c,
+    int d,
+    int e,
+    int f,
+    int g,
+    int h);
+
+
diff --git a/kernel/lib/magenta/include/magenta/gen-del.inc b/kernel/lib/magenta/include/magenta/gen-del.inc
new file mode 100644
index 0000000..a0190d5
--- /dev/null
+++ b/kernel/lib/magenta/include/magenta/gen-del.inc
@@ -0,0 +1,847 @@
+// Copyright 2017 The Fuchsia Authors. All rights reserved.
+// This is a GENERATED file. The license governing this file can be found in the LICENSE file.
+
+mx_time_t delegate_sys_time_get(
+    uint32_t clock_id){
+    return sys_time_get(clock_id);
+}
+
+mx_status_t delegate_sys_nanosleep(
+    mx_time_t nanoseconds){
+    return sys_nanosleep(nanoseconds);
+}
+
+mx_status_t delegate_sys_handle_close(
+    mx_handle_t handle){
+    return sys_handle_close(handle);
+}
+
+mx_status_t delegate_sys_handle_duplicate(
+    mx_handle_t handle,
+    mx_rights_t rights,
+    mx_handle_t out[1]){
+    return sys_handle_duplicate(handle, rights, out);
+}
+
+mx_status_t delegate_sys_handle_replace(
+    mx_handle_t handle,
+    mx_rights_t rights,
+    mx_handle_t out[1]){
+    return sys_handle_replace(handle, rights, out);
+}
+
+mx_status_t delegate_sys_handle_wait_one(
+    mx_handle_t handle,
+    mx_signals_t waitfor,
+    mx_time_t timeout,
+    mx_signals_t observed[1]){
+    return sys_handle_wait_one(handle, waitfor, timeout, observed);
+}
+
+mx_status_t delegate_sys_handle_wait_many(
+    mx_wait_item_t items[],
+    uint32_t count,
+    mx_time_t timeout){
+    return sys_handle_wait_many(items, count, timeout);
+}
+
+mx_status_t delegate_sys_object_signal(
+    mx_handle_t handle,
+    uint32_t clear_mask,
+    uint32_t set_mask){
+    return sys_object_signal(handle, clear_mask, set_mask);
+}
+
+mx_status_t delegate_sys_object_signal_peer(
+    mx_handle_t handle,
+    uint32_t clear_mask,
+    uint32_t set_mask){
+    return sys_object_signal_peer(handle, clear_mask, set_mask);
+}
+
+mx_status_t delegate_sys_object_get_property(
+    mx_handle_t handle,
+    uint32_t property,
+    void* value,
+    size_t size){
+    return sys_object_get_property(handle, property, value, size);
+}
+
+mx_status_t delegate_sys_object_set_property(
+    mx_handle_t handle,
+    uint32_t property,
+    const void* value,
+    size_t size){
+    return sys_object_set_property(handle, property, value, size);
+}
+
+mx_status_t delegate_sys_object_get_info(
+    mx_handle_t handle,
+    uint32_t topic,
+    void* buffer,
+    size_t buffer_size,
+    size_t actual_count[1],
+    size_t avail_count[1]){
+    return sys_object_get_info(handle, topic, buffer, buffer_size, actual_count, avail_count);
+}
+
+mx_status_t delegate_sys_object_get_child(
+    mx_handle_t handle,
+    uint64_t koid,
+    mx_rights_t rights,
+    mx_handle_t out[1]){
+    return sys_object_get_child(handle, koid, rights, out);
+}
+
+mx_status_t delegate_sys_object_bind_exception_port(
+    mx_handle_t object,
+    mx_handle_t eport,
+    uint64_t key,
+    uint32_t options){
+    return sys_object_bind_exception_port(object, eport, key, options);
+}
+
+mx_status_t delegate_sys_channel_create(
+    uint32_t options,
+    mx_handle_t out0[1],
+    mx_handle_t out1[1]){
+    return sys_channel_create(options, out0, out1);
+}
+
+mx_status_t delegate_sys_channel_read(
+    mx_handle_t handle,
+    uint32_t options,
+    void* bytes,
+    uint32_t num_bytes,
+    uint32_t actual_bytes[1],
+    mx_handle_t handles[],
+    uint32_t num_handles,
+    uint32_t actual_handles[1]){
+    return sys_channel_read(handle, options, bytes, num_bytes, actual_bytes, handles, num_handles, actual_handles);
+}
+
+mx_status_t delegate_sys_channel_write(
+    mx_handle_t handle,
+    uint32_t options,
+    const void* bytes,
+    uint32_t num_bytes,
+    const mx_handle_t handles[],
+    uint32_t num_handles){
+    return sys_channel_write(handle, options, bytes, num_bytes, handles, num_handles);
+}
+
+mx_status_t delegate_sys_channel_call(
+    mx_handle_t handle,
+    uint32_t options,
+    mx_time_t timeout,
+    const mx_channel_call_args_t args[1],
+    uint32_t actual_bytes[1],
+    uint32_t actual_handles[1],
+    mx_status_t read_status[1]){
+    return sys_channel_call(handle, options, timeout, args, actual_bytes, actual_handles, read_status);
+}
+
+mx_status_t delegate_sys_socket_create(
+    uint32_t options,
+    mx_handle_t out0[1],
+    mx_handle_t out1[1]){
+    return sys_socket_create(options, out0, out1);
+}
+
+mx_status_t delegate_sys_socket_write(
+    mx_handle_t handle,
+    uint32_t options,
+    const void* buffer,
+    size_t size,
+    size_t actual[1]){
+    return sys_socket_write(handle, options, buffer, size, actual);
+}
+
+mx_status_t delegate_sys_socket_read(
+    mx_handle_t handle,
+    uint32_t options,
+    void* buffer,
+    size_t size,
+    size_t actual[1]){
+    return sys_socket_read(handle, options, buffer, size, actual);
+}
+
+void delegate_sys_thread_exit(){
+    sys_thread_exit();
+}
+
+mx_status_t delegate_sys_thread_create(
+    mx_handle_t process,
+    const char name[],
+    uint32_t name_len,
+    uint32_t options,
+    mx_handle_t out[1]){
+    return sys_thread_create(process, name, name_len, options, out);
+}
+
+mx_status_t delegate_sys_thread_start(
+    mx_handle_t handle,
+    uintptr_t thread_entry,
+    uintptr_t stack,
+    uintptr_t arg1,
+    uintptr_t arg2){
+    return sys_thread_start(handle, thread_entry, stack, arg1, arg2);
+}
+
+mx_status_t delegate_sys_thread_read_state(
+    mx_handle_t handle,
+    uint32_t kind,
+    void* buffer,
+    uint32_t len,
+    uint32_t actual[1]){
+    return sys_thread_read_state(handle, kind, buffer, len, actual);
+}
+
+mx_status_t delegate_sys_thread_write_state(
+    mx_handle_t handle,
+    uint32_t kind,
+    const void* buffer,
+    uint32_t buffer_len){
+    return sys_thread_write_state(handle, kind, buffer, buffer_len);
+}
+
+void delegate_sys_process_exit(
+    int retcode){
+    sys_process_exit(retcode);
+}
+
+mx_status_t delegate_sys_process_create(
+    mx_handle_t job,
+    const char name[],
+    uint32_t name_len,
+    uint32_t options,
+    mx_handle_t proc_handle[1],
+    mx_handle_t vmar_handle[1]){
+    return sys_process_create(job, name, name_len, options, proc_handle, vmar_handle);
+}
+
+mx_status_t delegate_sys_process_start(
+    mx_handle_t process_handle,
+    mx_handle_t thread_handle,
+    uintptr_t entry,
+    uintptr_t stack,
+    mx_handle_t arg_handle,
+    uintptr_t arg2){
+    return sys_process_start(process_handle, thread_handle, entry, stack, arg_handle, arg2);
+}
+
+mx_status_t delegate_sys_process_read_memory(
+    mx_handle_t proc,
+    uintptr_t vaddr,
+    void* buffer,
+    size_t len,
+    size_t actual[1]){
+    return sys_process_read_memory(proc, vaddr, buffer, len, actual);
+}
+
+mx_status_t delegate_sys_process_write_memory(
+    mx_handle_t proc,
+    uintptr_t vaddr,
+    const void* buffer,
+    size_t len,
+    size_t actual[1]){
+    return sys_process_write_memory(proc, vaddr, buffer, len, actual);
+}
+
+mx_status_t delegate_sys_job_create(
+    mx_handle_t parent_job,
+    uint32_t options,
+    mx_handle_t out[1]){
+    return sys_job_create(parent_job, options, out);
+}
+
+mx_status_t delegate_sys_task_resume(
+    mx_handle_t task_handle,
+    uint32_t options){
+    return sys_task_resume(task_handle, options);
+}
+
+mx_status_t delegate_sys_task_kill(
+    mx_handle_t task_handle){
+    return sys_task_kill(task_handle);
+}
+
+mx_status_t delegate_sys_event_create(
+    uint32_t options,
+    mx_handle_t out[1]){
+    return sys_event_create(options, out);
+}
+
+mx_status_t delegate_sys_eventpair_create(
+    uint32_t options,
+    mx_handle_t out0[1],
+    mx_handle_t out1[1]){
+    return sys_eventpair_create(options, out0, out1);
+}
+
+mx_status_t delegate_sys_futex_wait(
+    mx_futex_t value_ptr[1],
+    int current_value,
+    mx_time_t timeout){
+    return sys_futex_wait(value_ptr, current_value, timeout);
+}
+
+mx_status_t delegate_sys_futex_wake(
+    mx_futex_t value_ptr[1],
+    uint32_t count){
+    return sys_futex_wake(value_ptr, count);
+}
+
+mx_status_t delegate_sys_futex_requeue(
+    mx_futex_t wake_ptr[1],
+    uint32_t wake_count,
+    int current_value,
+    mx_futex_t requeue_ptr[1],
+    uint32_t requeue_count){
+    return sys_futex_requeue(wake_ptr, wake_count, current_value, requeue_ptr, requeue_count);
+}
+
+mx_status_t delegate_sys_waitset_create(
+    uint32_t options,
+    mx_handle_t out[1]){
+    return sys_waitset_create(options, out);
+}
+
+mx_status_t delegate_sys_waitset_add(
+    mx_handle_t waitset_handle,
+    uint64_t cookie,
+    mx_handle_t handle,
+    mx_signals_t signals){
+    return sys_waitset_add(waitset_handle, cookie, handle, signals);
+}
+
+mx_status_t delegate_sys_waitset_remove(
+    mx_handle_t waitset_handle,
+    uint64_t cookie){
+    return sys_waitset_remove(waitset_handle, cookie);
+}
+
+mx_status_t delegate_sys_waitset_wait(
+    mx_handle_t waitset_handle,
+    mx_time_t timeout,
+    mx_waitset_result_t results[],
+    uint32_t count[1]){
+    return sys_waitset_wait(waitset_handle, timeout, results, count);
+}
+
+mx_status_t delegate_sys_port_create(
+    uint32_t options,
+    mx_handle_t out[1]){
+    return sys_port_create(options, out);
+}
+
+mx_status_t delegate_sys_port_queue(
+    mx_handle_t handle,
+    const void* packet,
+    size_t size){
+    return sys_port_queue(handle, packet, size);
+}
+
+mx_status_t delegate_sys_port_wait(
+    mx_handle_t handle,
+    mx_time_t timeout,
+    void* packet,
+    size_t size){
+    return sys_port_wait(handle, timeout, packet, size);
+}
+
+mx_status_t delegate_sys_port_bind(
+    mx_handle_t handle,
+    uint64_t key,
+    mx_handle_t source,
+    mx_signals_t signals){
+    return sys_port_bind(handle, key, source, signals);
+}
+
+mx_status_t delegate_sys_vmo_create(
+    uint64_t size,
+    uint32_t options,
+    mx_handle_t out[1]){
+    return sys_vmo_create(size, options, out);
+}
+
+mx_status_t delegate_sys_vmo_read(
+    mx_handle_t handle,
+    void* data,
+    uint64_t offset,
+    size_t len,
+    size_t actual[1]){
+    return sys_vmo_read(handle, data, offset, len, actual);
+}
+
+mx_status_t delegate_sys_vmo_write(
+    mx_handle_t handle,
+    const void* data,
+    uint64_t offset,
+    size_t len,
+    size_t actual[1]){
+    return sys_vmo_write(handle, data, offset, len, actual);
+}
+
+mx_status_t delegate_sys_vmo_get_size(
+    mx_handle_t handle,
+    uint64_t size[1]){
+    return sys_vmo_get_size(handle, size);
+}
+
+mx_status_t delegate_sys_vmo_set_size(
+    mx_handle_t handle,
+    uint64_t size){
+    return sys_vmo_set_size(handle, size);
+}
+
+mx_status_t delegate_sys_vmo_op_range(
+    mx_handle_t handle,
+    uint32_t op,
+    uint64_t offset,
+    uint64_t size,
+    void* buffer,
+    size_t buffer_size){
+    return sys_vmo_op_range(handle, op, offset, size, buffer, buffer_size);
+}
+
+mx_status_t delegate_sys_cprng_draw(
+    void* buffer,
+    size_t len,
+    size_t actual[1]){
+    return sys_cprng_draw(buffer, len, actual);
+}
+
+mx_status_t delegate_sys_cprng_add_entropy(
+    const void* buffer,
+    size_t len){
+    return sys_cprng_add_entropy(buffer, len);
+}
+
+mx_status_t delegate_sys_fifo0_create(
+    uint64_t count,
+    mx_handle_t out[1]){
+    return sys_fifo0_create(count, out);
+}
+
+mx_status_t delegate_sys_fifo0_op(
+    mx_handle_t handle,
+    uint32_t op,
+    uint64_t val,
+    mx_fifo_state_t out[1]){
+    return sys_fifo0_op(handle, op, val, out);
+}
+
+mx_status_t delegate_sys_log_create(
+    uint32_t options,
+    mx_handle_t out[1]){
+    return sys_log_create(options, out);
+}
+
+mx_status_t delegate_sys_log_write(
+    mx_handle_t handle,
+    uint32_t len,
+    const void* buffer,
+    uint32_t options){
+    return sys_log_write(handle, len, buffer, options);
+}
+
+mx_status_t delegate_sys_log_read(
+    mx_handle_t handle,
+    uint32_t len,
+    void* buffer,
+    uint32_t options){
+    return sys_log_read(handle, len, buffer, options);
+}
+
+mx_status_t delegate_sys_ktrace_read(
+    mx_handle_t handle,
+    void* data,
+    uint32_t offset,
+    uint32_t len,
+    uint32_t actual[1]){
+    return sys_ktrace_read(handle, data, offset, len, actual);
+}
+
+mx_status_t delegate_sys_ktrace_control(
+    mx_handle_t handle,
+    uint32_t action,
+    uint32_t options,
+    void* ptr){
+    return sys_ktrace_control(handle, action, options, ptr);
+}
+
+mx_status_t delegate_sys_ktrace_write(
+    mx_handle_t handle,
+    uint32_t id,
+    uint32_t arg0,
+    uint32_t arg1){
+    return sys_ktrace_write(handle, id, arg0, arg1);
+}
+
+mx_status_t delegate_sys_mtrace_control(
+    mx_handle_t handle,
+    uint32_t kind,
+    uint32_t action,
+    uint32_t options,
+    void* ptr,
+    uint32_t size){
+    return sys_mtrace_control(handle, kind, action, options, ptr, size);
+}
+
+mx_handle_t delegate_sys_debug_transfer_handle(
+    mx_handle_t proc,
+    mx_handle_t handle){
+    return sys_debug_transfer_handle(proc, handle);
+}
+
+mx_status_t delegate_sys_debug_read(
+    mx_handle_t handle,
+    void* buffer,
+    uint32_t length){
+    return sys_debug_read(handle, buffer, length);
+}
+
+mx_status_t delegate_sys_debug_write(
+    const void* buffer,
+    uint32_t length){
+    return sys_debug_write(buffer, length);
+}
+
+mx_status_t delegate_sys_debug_send_command(
+    mx_handle_t resource_handle,
+    const void* buffer,
+    uint32_t length){
+    return sys_debug_send_command(resource_handle, buffer, length);
+}
+
+mx_handle_t delegate_sys_interrupt_create(
+    mx_handle_t handle,
+    uint32_t vector,
+    uint32_t options){
+    return sys_interrupt_create(handle, vector, options);
+}
+
+mx_status_t delegate_sys_interrupt_complete(
+    mx_handle_t handle){
+    return sys_interrupt_complete(handle);
+}
+
+mx_status_t delegate_sys_interrupt_wait(
+    mx_handle_t handle){
+    return sys_interrupt_wait(handle);
+}
+
+mx_status_t delegate_sys_mmap_device_io(
+    mx_handle_t handle,
+    uint32_t io_addr,
+    uint32_t len){
+    return sys_mmap_device_io(handle, io_addr, len);
+}
+
+mx_status_t delegate_sys_mmap_device_memory(
+    mx_handle_t handle,
+    mx_paddr_t paddr,
+    uint32_t len,
+    mx_cache_policy_t cache_policy,
+    uintptr_t out_vaddr[1]){
+    return sys_mmap_device_memory(handle, paddr, len, cache_policy, out_vaddr);
+}
+
+mx_status_t delegate_sys_io_mapping_get_info(
+    mx_handle_t handle,
+    uintptr_t out_vaddr[1],
+    uint64_t out_size[1]){
+    return sys_io_mapping_get_info(handle, out_vaddr, out_size);
+}
+
+mx_status_t delegate_sys_vmo_create_contiguous(
+    mx_handle_t rsrc_handle,
+    size_t size,
+    uint32_t alignment_log2,
+    mx_handle_t out[1]){
+    return sys_vmo_create_contiguous(rsrc_handle, size, alignment_log2, out);
+}
+
+mx_status_t delegate_sys_vmar_allocate(
+    mx_handle_t parent_vmar_handle,
+    size_t offset,
+    size_t size,
+    uint32_t flags,
+    mx_handle_t child_vmar[1],
+    uintptr_t child_addr[1]){
+    return sys_vmar_allocate(parent_vmar_handle, offset, size, flags, child_vmar, child_addr);
+}
+
+mx_status_t delegate_sys_vmar_destroy(
+    mx_handle_t vmar_handle){
+    return sys_vmar_destroy(vmar_handle);
+}
+
+mx_status_t delegate_sys_vmar_map(
+    mx_handle_t vmar_handle,
+    size_t vmar_offset,
+    mx_handle_t vmo_handle,
+    uint64_t vmo_offset,
+    size_t len,
+    uint32_t flags,
+    uintptr_t mapped_addr[1]){
+    return sys_vmar_map(vmar_handle, vmar_offset, vmo_handle, vmo_offset, len, flags, mapped_addr);
+}
+
+mx_status_t delegate_sys_vmar_unmap(
+    mx_handle_t vmar_handle,
+    uintptr_t addr,
+    size_t len){
+    return sys_vmar_unmap(vmar_handle, addr, len);
+}
+
+mx_status_t delegate_sys_vmar_protect(
+    mx_handle_t vmar_handle,
+    uintptr_t addr,
+    size_t len,
+    uint32_t prot){
+    return sys_vmar_protect(vmar_handle, addr, len, prot);
+}
+
+mx_status_t delegate_sys_bootloader_fb_get_info(
+    uint32_t format[1],
+    uint32_t width[1],
+    uint32_t height[1],
+    uint32_t stride[1]){
+    return sys_bootloader_fb_get_info(format, width, height, stride);
+}
+
+mx_status_t delegate_sys_set_framebuffer(
+    mx_handle_t handle,
+    void* vaddr,
+    uint32_t len,
+    uint32_t format,
+    uint32_t width,
+    uint32_t height,
+    uint32_t stride){
+    return sys_set_framebuffer(handle, vaddr, len, format, width, height, stride);
+}
+
+mx_status_t delegate_sys_clock_adjust(
+    mx_handle_t handle,
+    uint32_t clock_id,
+    int64_t offset){
+    return sys_clock_adjust(handle, clock_id, offset);
+}
+
+mx_handle_t delegate_sys_pci_get_nth_device(
+    mx_handle_t handle,
+    uint32_t index,
+    mx_pcie_get_nth_info_t out_info[1]){
+    return sys_pci_get_nth_device(handle, index, out_info);
+}
+
+mx_status_t delegate_sys_pci_claim_device(
+    mx_handle_t handle){
+    return sys_pci_claim_device(handle);
+}
+
+mx_status_t delegate_sys_pci_enable_bus_master(
+    mx_handle_t handle,
+    bool enable){
+    return sys_pci_enable_bus_master(handle, enable);
+}
+
+mx_status_t delegate_sys_pci_enable_pio(
+    mx_handle_t handle,
+    bool enable){
+    return sys_pci_enable_pio(handle, enable);
+}
+
+mx_status_t delegate_sys_pci_reset_device(
+    mx_handle_t handle){
+    return sys_pci_reset_device(handle);
+}
+
+mx_handle_t delegate_sys_pci_map_mmio(
+    mx_handle_t handle,
+    uint32_t bar_num,
+    mx_cache_policy_t cache_policy){
+    return sys_pci_map_mmio(handle, bar_num, cache_policy);
+}
+
+mx_status_t delegate_sys_pci_io_write(
+    mx_handle_t handle,
+    uint32_t bar_num,
+    uint32_t offset,
+    uint32_t len,
+    uint32_t value){
+    return sys_pci_io_write(handle, bar_num, offset, len, value);
+}
+
+mx_status_t delegate_sys_pci_io_read(
+    mx_handle_t handle,
+    uint32_t bar_num,
+    uint32_t offset,
+    uint32_t len,
+    uint32_t out_value[1]){
+    return sys_pci_io_read(handle, bar_num, offset, len, out_value);
+}
+
+mx_handle_t delegate_sys_pci_map_interrupt(
+    mx_handle_t handle,
+    int32_t which_irq){
+    return sys_pci_map_interrupt(handle, which_irq);
+}
+
+mx_handle_t delegate_sys_pci_map_config(
+    mx_handle_t handle){
+    return sys_pci_map_config(handle);
+}
+
+mx_status_t delegate_sys_pci_query_irq_mode_caps(
+    mx_handle_t handle,
+    uint32_t mode,
+    uint32_t out_max_irqs[1]){
+    return sys_pci_query_irq_mode_caps(handle, mode, out_max_irqs);
+}
+
+mx_status_t delegate_sys_pci_set_irq_mode(
+    mx_handle_t handle,
+    uint32_t mode,
+    uint32_t requested_irq_count){
+    return sys_pci_set_irq_mode(handle, mode, requested_irq_count);
+}
+
+mx_status_t delegate_sys_pci_init(
+    mx_handle_t handle,
+    const mx_pci_init_arg_t init_buf[],
+    uint32_t len){
+    return sys_pci_init(handle, init_buf, len);
+}
+
+mx_status_t delegate_sys_pci_add_subtract_io_range(
+    mx_handle_t handle,
+    bool mmio,
+    uint64_t base,
+    uint64_t len,
+    bool add){
+    return sys_pci_add_subtract_io_range(handle, mmio, base, len, add);
+}
+
+uint32_t delegate_sys_acpi_uefi_rsdp(
+    mx_handle_t handle){
+    return sys_acpi_uefi_rsdp(handle);
+}
+
+mx_status_t delegate_sys_acpi_cache_flush(
+    mx_handle_t handle){
+    return sys_acpi_cache_flush(handle);
+}
+
+mx_status_t delegate_sys_resource_create(
+    mx_handle_t parent_handle,
+    const mx_rrec_t records[],
+    uint32_t count,
+    mx_handle_t resource_out[1]){
+    return sys_resource_create(parent_handle, records, count, resource_out);
+}
+
+mx_status_t delegate_sys_resource_get_handle(
+    mx_handle_t handle,
+    uint32_t index,
+    uint32_t options,
+    mx_handle_t out[1]){
+    return sys_resource_get_handle(handle, index, options, out);
+}
+
+mx_status_t delegate_sys_resource_do_action(
+    mx_handle_t handle,
+    uint32_t index,
+    uint32_t action,
+    uint32_t arg0,
+    uint32_t arg1){
+    return sys_resource_do_action(handle, index, action, arg0, arg1);
+}
+
+mx_status_t delegate_sys_resource_connect(
+    mx_handle_t handle,
+    mx_handle_t channel){
+    return sys_resource_connect(handle, channel);
+}
+
+mx_status_t delegate_sys_resource_accept(
+    mx_handle_t handle,
+    mx_handle_t channel[1]){
+    return sys_resource_accept(handle, channel);
+}
+
+int delegate_sys_syscall_test_0(){
+    return sys_syscall_test_0();
+}
+
+int delegate_sys_syscall_test_1(
+    int a){
+    return sys_syscall_test_1(a);
+}
+
+int delegate_sys_syscall_test_2(
+    int a,
+    int b){
+    return sys_syscall_test_2(a, b);
+}
+
+int delegate_sys_syscall_test_3(
+    int a,
+    int b,
+    int c){
+    return sys_syscall_test_3(a, b, c);
+}
+
+int delegate_sys_syscall_test_4(
+    int a,
+    int b,
+    int c,
+    int d){
+    return sys_syscall_test_4(a, b, c, d);
+}
+
+int delegate_sys_syscall_test_5(
+    int a,
+    int b,
+    int c,
+    int d,
+    int e){
+    return sys_syscall_test_5(a, b, c, d, e);
+}
+
+int delegate_sys_syscall_test_6(
+    int a,
+    int b,
+    int c,
+    int d,
+    int e,
+    int f){
+    return sys_syscall_test_6(a, b, c, d, e, f);
+}
+
+int delegate_sys_syscall_test_7(
+    int a,
+    int b,
+    int c,
+    int d,
+    int e,
+    int f,
+    int g){
+    return sys_syscall_test_7(a, b, c, d, e, f, g);
+}
+
+int delegate_sys_syscall_test_8(
+    int a,
+    int b,
+    int c,
+    int d,
+    int e,
+    int f,
+    int g,
+    int h){
+    return sys_syscall_test_8(a, b, c, d, e, f, g, h);
+}
+
+
diff --git a/kernel/lib/magenta/include/magenta/gen-switch.inc b/kernel/lib/magenta/include/magenta/gen-switch.inc
index 364f4f5..fce3b8a 100644
--- a/kernel/lib/magenta/include/magenta/gen-switch.inc
+++ b/kernel/lib/magenta/include/magenta/gen-switch.inc
@@ -1,621 +1,230 @@
 // Copyright 2017 The Fuchsia Authors. All rights reserved.
 // This is a GENERATED file. The license governing this file can be found in the LICENSE file.
 
-    case 0: ret = reinterpret_cast<syscall_func1>(sys_time_get)(
-        arg1);
+    case 0: sfunc = reinterpret_cast<syscall_func>(delegate_sys_time_get);
        break;
-    case 1: ret = reinterpret_cast<syscall_func1>(sys_nanosleep)(
-        arg1);
+    case 1: sfunc = reinterpret_cast<syscall_func>(delegate_sys_nanosleep);
        break;
-    case 7: ret = reinterpret_cast<syscall_func1>(sys_handle_close)(
-        arg1);
+    case 7: sfunc = reinterpret_cast<syscall_func>(delegate_sys_handle_close);
        break;
-    case 8: ret = reinterpret_cast<syscall_func3>(sys_handle_duplicate)(
-        arg1,
-        arg2,
-        arg3);
+    case 8: sfunc = reinterpret_cast<syscall_func>(delegate_sys_handle_duplicate);
        break;
-    case 9: ret = reinterpret_cast<syscall_func3>(sys_handle_replace)(
-        arg1,
-        arg2,
-        arg3);
+    case 9: sfunc = reinterpret_cast<syscall_func>(delegate_sys_handle_replace);
        break;
-    case 10: ret = reinterpret_cast<syscall_func4>(sys_handle_wait_one)(
-        arg1,
-        arg2,
-        arg3,
-        arg4);
+    case 10: sfunc = reinterpret_cast<syscall_func>(delegate_sys_handle_wait_one);
        break;
-    case 11: ret = reinterpret_cast<syscall_func3>(sys_handle_wait_many)(
-        arg1,
-        arg2,
-        arg3);
+    case 11: sfunc = reinterpret_cast<syscall_func>(delegate_sys_handle_wait_many);
        break;
-    case 12: ret = reinterpret_cast<syscall_func3>(sys_object_signal)(
-        arg1,
-        arg2,
-        arg3);
+    case 12: sfunc = reinterpret_cast<syscall_func>(delegate_sys_object_signal);
        break;
-    case 13: ret = reinterpret_cast<syscall_func3>(sys_object_signal_peer)(
-        arg1,
-        arg2,
-        arg3);
+    case 13: sfunc = reinterpret_cast<syscall_func>(delegate_sys_object_signal_peer);
        break;
-    case 14: ret = reinterpret_cast<syscall_func4>(sys_object_get_property)(
-        arg1,
-        arg2,
-        arg3,
-        arg4);
+    case 14: sfunc = reinterpret_cast<syscall_func>(delegate_sys_object_get_property);
        break;
-    case 15: ret = reinterpret_cast<syscall_func4>(sys_object_set_property)(
-        arg1,
-        arg2,
-        arg3,
-        arg4);
+    case 15: sfunc = reinterpret_cast<syscall_func>(delegate_sys_object_set_property);
        break;
-    case 16: ret = reinterpret_cast<syscall_func6>(sys_object_get_info)(
-        arg1,
-        arg2,
-        arg3,
-        arg4,
-        arg5,
-        arg6);
+    case 16: sfunc = reinterpret_cast<syscall_func>(delegate_sys_object_get_info);
        break;
-    case 17: ret = reinterpret_cast<syscall_func4>(sys_object_get_child)(
-        arg1,
-        arg2,
-        arg3,
-        arg4);
+    case 17: sfunc = reinterpret_cast<syscall_func>(delegate_sys_object_get_child);
        break;
-    case 18: ret = reinterpret_cast<syscall_func4>(sys_object_bind_exception_port)(
-        arg1,
-        arg2,
-        arg3,
-        arg4);
+    case 18: sfunc = reinterpret_cast<syscall_func>(delegate_sys_object_bind_exception_port);
        break;
-    case 19: ret = reinterpret_cast<syscall_func3>(sys_channel_create)(
-        arg1,
-        arg2,
-        arg3);
+    case 19: sfunc = reinterpret_cast<syscall_func>(delegate_sys_channel_create);
        break;
-    case 20: ret = reinterpret_cast<syscall_func8>(sys_channel_read)(
-        arg1,
-        arg2,
-        arg3,
-        arg4,
-        arg5,
-        arg6,
-        arg7,
-        arg8);
+    case 20: sfunc = reinterpret_cast<syscall_func>(delegate_sys_channel_read);
        break;
-    case 21: ret = reinterpret_cast<syscall_func6>(sys_channel_write)(
-        arg1,
-        arg2,
-        arg3,
-        arg4,
-        arg5,
-        arg6);
+    case 21: sfunc = reinterpret_cast<syscall_func>(delegate_sys_channel_write);
        break;
-    case 22: ret = reinterpret_cast<syscall_func7>(sys_channel_call)(
-        arg1,
-        arg2,
-        arg3,
-        arg4,
-        arg5,
-        arg6,
-        arg7);
+    case 22: sfunc = reinterpret_cast<syscall_func>(delegate_sys_channel_call);
        break;
-    case 23: ret = reinterpret_cast<syscall_func3>(sys_socket_create)(
-        arg1,
-        arg2,
-        arg3);
+    case 23: sfunc = reinterpret_cast<syscall_func>(delegate_sys_socket_create);
        break;
-    case 24: ret = reinterpret_cast<syscall_func5>(sys_socket_write)(
-        arg1,
-        arg2,
-        arg3,
-        arg4,
-        arg5);
+    case 24: sfunc = reinterpret_cast<syscall_func>(delegate_sys_socket_write);
        break;
-    case 25: ret = reinterpret_cast<syscall_func5>(sys_socket_read)(
-        arg1,
-        arg2,
-        arg3,
-        arg4,
-        arg5);
+    case 25: sfunc = reinterpret_cast<syscall_func>(delegate_sys_socket_read);
        break;
-    case 26: ret = 0; reinterpret_cast<syscall_func0>(sys_thread_exit)();
+    case 26: sfunc = reinterpret_cast<syscall_func>(delegate_sys_thread_exit);
        break;
-    case 27: ret = reinterpret_cast<syscall_func5>(sys_thread_create)(
-        arg1,
-        arg2,
-        arg3,
-        arg4,
-        arg5);
+    case 27: sfunc = reinterpret_cast<syscall_func>(delegate_sys_thread_create);
        break;
-    case 28: ret = reinterpret_cast<syscall_func5>(sys_thread_start)(
-        arg1,
-        arg2,
-        arg3,
-        arg4,
-        arg5);
+    case 28: sfunc = reinterpret_cast<syscall_func>(delegate_sys_thread_start);
        break;
-    case 29: ret = reinterpret_cast<syscall_func5>(sys_thread_read_state)(
-        arg1,
-        arg2,
-        arg3,
-        arg4,
-        arg5);
+    case 29: sfunc = reinterpret_cast<syscall_func>(delegate_sys_thread_read_state);
        break;
-    case 30: ret = reinterpret_cast<syscall_func4>(sys_thread_write_state)(
-        arg1,
-        arg2,
-        arg3,
-        arg4);
+    case 30: sfunc = reinterpret_cast<syscall_func>(delegate_sys_thread_write_state);
        break;
-    case 31: ret = 0; reinterpret_cast<syscall_func1>(sys_process_exit)(
-        arg1);
+    case 31: sfunc = reinterpret_cast<syscall_func>(delegate_sys_process_exit);
        break;
-    case 32: ret = reinterpret_cast<syscall_func6>(sys_process_create)(
-        arg1,
-        arg2,
-        arg3,
-        arg4,
-        arg5,
-        arg6);
+    case 32: sfunc = reinterpret_cast<syscall_func>(delegate_sys_process_create);
        break;
-    case 33: ret = reinterpret_cast<syscall_func6>(sys_process_start)(
-        arg1,
-        arg2,
-        arg3,
-        arg4,
-        arg5,
-        arg6);
+    case 33: sfunc = reinterpret_cast<syscall_func>(delegate_sys_process_start);
        break;
-    case 34: ret = reinterpret_cast<syscall_func5>(sys_process_read_memory)(
-        arg1,
-        arg2,
-        arg3,
-        arg4,
-        arg5);
+    case 34: sfunc = reinterpret_cast<syscall_func>(delegate_sys_process_read_memory);
        break;
-    case 35: ret = reinterpret_cast<syscall_func5>(sys_process_write_memory)(
-        arg1,
-        arg2,
-        arg3,
-        arg4,
-        arg5);
+    case 35: sfunc = reinterpret_cast<syscall_func>(delegate_sys_process_write_memory);
        break;
-    case 36: ret = reinterpret_cast<syscall_func3>(sys_job_create)(
-        arg1,
-        arg2,
-        arg3);
+    case 36: sfunc = reinterpret_cast<syscall_func>(delegate_sys_job_create);
        break;
-    case 37: ret = reinterpret_cast<syscall_func2>(sys_task_resume)(
-        arg1,
-        arg2);
+    case 37: sfunc = reinterpret_cast<syscall_func>(delegate_sys_task_resume);
        break;
-    case 38: ret = reinterpret_cast<syscall_func1>(sys_task_kill)(
-        arg1);
+    case 38: sfunc = reinterpret_cast<syscall_func>(delegate_sys_task_kill);
        break;
-    case 39: ret = reinterpret_cast<syscall_func2>(sys_event_create)(
-        arg1,
-        arg2);
+    case 39: sfunc = reinterpret_cast<syscall_func>(delegate_sys_event_create);
        break;
-    case 40: ret = reinterpret_cast<syscall_func3>(sys_eventpair_create)(
-        arg1,
-        arg2,
-        arg3);
+    case 40: sfunc = reinterpret_cast<syscall_func>(delegate_sys_eventpair_create);
        break;
-    case 41: ret = reinterpret_cast<syscall_func3>(sys_futex_wait)(
-        arg1,
-        arg2,
-        arg3);
+    case 41: sfunc = reinterpret_cast<syscall_func>(delegate_sys_futex_wait);
        break;
-    case 42: ret = reinterpret_cast<syscall_func2>(sys_futex_wake)(
-        arg1,
-        arg2);
+    case 42: sfunc = reinterpret_cast<syscall_func>(delegate_sys_futex_wake);
        break;
-    case 43: ret = reinterpret_cast<syscall_func5>(sys_futex_requeue)(
-        arg1,
-        arg2,
-        arg3,
-        arg4,
-        arg5);
+    case 43: sfunc = reinterpret_cast<syscall_func>(delegate_sys_futex_requeue);
        break;
-    case 44: ret = reinterpret_cast<syscall_func2>(sys_waitset_create)(
-        arg1,
-        arg2);
+    case 44: sfunc = reinterpret_cast<syscall_func>(delegate_sys_waitset_create);
        break;
-    case 45: ret = reinterpret_cast<syscall_func4>(sys_waitset_add)(
-        arg1,
-        arg2,
-        arg3,
-        arg4);
+    case 45: sfunc = reinterpret_cast<syscall_func>(delegate_sys_waitset_add);
        break;
-    case 46: ret = reinterpret_cast<syscall_func2>(sys_waitset_remove)(
-        arg1,
-        arg2);
+    case 46: sfunc = reinterpret_cast<syscall_func>(delegate_sys_waitset_remove);
        break;
-    case 47: ret = reinterpret_cast<syscall_func4>(sys_waitset_wait)(
-        arg1,
-        arg2,
-        arg3,
-        arg4);
+    case 47: sfunc = reinterpret_cast<syscall_func>(delegate_sys_waitset_wait);
        break;
-    case 48: ret = reinterpret_cast<syscall_func2>(sys_port_create)(
-        arg1,
-        arg2);
+    case 48: sfunc = reinterpret_cast<syscall_func>(delegate_sys_port_create);
        break;
-    case 49: ret = reinterpret_cast<syscall_func3>(sys_port_queue)(
-        arg1,
-        arg2,
-        arg3);
+    case 49: sfunc = reinterpret_cast<syscall_func>(delegate_sys_port_queue);
        break;
-    case 50: ret = reinterpret_cast<syscall_func4>(sys_port_wait)(
-        arg1,
-        arg2,
-        arg3,
-        arg4);
+    case 50: sfunc = reinterpret_cast<syscall_func>(delegate_sys_port_wait);
        break;
-    case 51: ret = reinterpret_cast<syscall_func4>(sys_port_bind)(
-        arg1,
-        arg2,
-        arg3,
-        arg4);
+    case 51: sfunc = reinterpret_cast<syscall_func>(delegate_sys_port_bind);
        break;
-    case 52: ret = reinterpret_cast<syscall_func3>(sys_vmo_create)(
-        arg1,
-        arg2,
-        arg3);
+    case 52: sfunc = reinterpret_cast<syscall_func>(delegate_sys_vmo_create);
        break;
-    case 53: ret = reinterpret_cast<syscall_func5>(sys_vmo_read)(
-        arg1,
-        arg2,
-        arg3,
-        arg4,
-        arg5);
+    case 53: sfunc = reinterpret_cast<syscall_func>(delegate_sys_vmo_read);
        break;
-    case 54: ret = reinterpret_cast<syscall_func5>(sys_vmo_write)(
-        arg1,
-        arg2,
-        arg3,
-        arg4,
-        arg5);
+    case 54: sfunc = reinterpret_cast<syscall_func>(delegate_sys_vmo_write);
        break;
-    case 55: ret = reinterpret_cast<syscall_func2>(sys_vmo_get_size)(
-        arg1,
-        arg2);
+    case 55: sfunc = reinterpret_cast<syscall_func>(delegate_sys_vmo_get_size);
        break;
-    case 56: ret = reinterpret_cast<syscall_func2>(sys_vmo_set_size)(
-        arg1,
-        arg2);
+    case 56: sfunc = reinterpret_cast<syscall_func>(delegate_sys_vmo_set_size);
        break;
-    case 57: ret = reinterpret_cast<syscall_func6>(sys_vmo_op_range)(
-        arg1,
-        arg2,
-        arg3,
-        arg4,
-        arg5,
-        arg6);
+    case 57: sfunc = reinterpret_cast<syscall_func>(delegate_sys_vmo_op_range);
        break;
-    case 58: ret = reinterpret_cast<syscall_func3>(sys_cprng_draw)(
-        arg1,
-        arg2,
-        arg3);
+    case 58: sfunc = reinterpret_cast<syscall_func>(delegate_sys_cprng_draw);
        break;
-    case 59: ret = reinterpret_cast<syscall_func2>(sys_cprng_add_entropy)(
-        arg1,
-        arg2);
+    case 59: sfunc = reinterpret_cast<syscall_func>(delegate_sys_cprng_add_entropy);
        break;
-    case 60: ret = reinterpret_cast<syscall_func2>(sys_fifo0_create)(
-        arg1,
-        arg2);
+    case 60: sfunc = reinterpret_cast<syscall_func>(delegate_sys_fifo0_create);
        break;
-    case 61: ret = reinterpret_cast<syscall_func4>(sys_fifo0_op)(
-        arg1,
-        arg2,
-        arg3,
-        arg4);
+    case 61: sfunc = reinterpret_cast<syscall_func>(delegate_sys_fifo0_op);
        break;
-    case 62: ret = reinterpret_cast<syscall_func2>(sys_log_create)(
-        arg1,
-        arg2);
+    case 62: sfunc = reinterpret_cast<syscall_func>(delegate_sys_log_create);
        break;
-    case 63: ret = reinterpret_cast<syscall_func4>(sys_log_write)(
-        arg1,
-        arg2,
-        arg3,
-        arg4);
+    case 63: sfunc = reinterpret_cast<syscall_func>(delegate_sys_log_write);
        break;
-    case 64: ret = reinterpret_cast<syscall_func4>(sys_log_read)(
-        arg1,
-        arg2,
-        arg3,
-        arg4);
+    case 64: sfunc = reinterpret_cast<syscall_func>(delegate_sys_log_read);
        break;
-    case 65: ret = reinterpret_cast<syscall_func5>(sys_ktrace_read)(
-        arg1,
-        arg2,
-        arg3,
-        arg4,
-        arg5);
+    case 65: sfunc = reinterpret_cast<syscall_func>(delegate_sys_ktrace_read);
        break;
-    case 66: ret = reinterpret_cast<syscall_func4>(sys_ktrace_control)(
-        arg1,
-        arg2,
-        arg3,
-        arg4);
+    case 66: sfunc = reinterpret_cast<syscall_func>(delegate_sys_ktrace_control);
        break;
-    case 67: ret = reinterpret_cast<syscall_func4>(sys_ktrace_write)(
-        arg1,
-        arg2,
-        arg3,
-        arg4);
+    case 67: sfunc = reinterpret_cast<syscall_func>(delegate_sys_ktrace_write);
        break;
-    case 68: ret = reinterpret_cast<syscall_func6>(sys_mtrace_control)(
-        arg1,
-        arg2,
-        arg3,
-        arg4,
-        arg5,
-        arg6);
+    case 68: sfunc = reinterpret_cast<syscall_func>(delegate_sys_mtrace_control);
        break;
-    case 69: ret = reinterpret_cast<syscall_func2>(sys_debug_transfer_handle)(
-        arg1,
-        arg2);
+    case 69: sfunc = reinterpret_cast<syscall_func>(delegate_sys_debug_transfer_handle);
        break;
-    case 70: ret = reinterpret_cast<syscall_func3>(sys_debug_read)(
-        arg1,
-        arg2,
-        arg3);
+    case 70: sfunc = reinterpret_cast<syscall_func>(delegate_sys_debug_read);
        break;
-    case 71: ret = reinterpret_cast<syscall_func2>(sys_debug_write)(
-        arg1,
-        arg2);
+    case 71: sfunc = reinterpret_cast<syscall_func>(delegate_sys_debug_write);
        break;
-    case 72: ret = reinterpret_cast<syscall_func3>(sys_debug_send_command)(
-        arg1,
-        arg2,
-        arg3);
+    case 72: sfunc = reinterpret_cast<syscall_func>(delegate_sys_debug_send_command);
        break;
-    case 73: ret = reinterpret_cast<syscall_func3>(sys_interrupt_create)(
-        arg1,
-        arg2,
-        arg3);
+    case 73: sfunc = reinterpret_cast<syscall_func>(delegate_sys_interrupt_create);
        break;
-    case 74: ret = reinterpret_cast<syscall_func1>(sys_interrupt_complete)(
-        arg1);
+    case 74: sfunc = reinterpret_cast<syscall_func>(delegate_sys_interrupt_complete);
        break;
-    case 75: ret = reinterpret_cast<syscall_func1>(sys_interrupt_wait)(
-        arg1);
+    case 75: sfunc = reinterpret_cast<syscall_func>(delegate_sys_interrupt_wait);
        break;
-    case 76: ret = reinterpret_cast<syscall_func3>(sys_mmap_device_io)(
-        arg1,
-        arg2,
-        arg3);
+    case 76: sfunc = reinterpret_cast<syscall_func>(delegate_sys_mmap_device_io);
        break;
-    case 77: ret = reinterpret_cast<syscall_func5>(sys_mmap_device_memory)(
-        arg1,
-        arg2,
-        arg3,
-        arg4,
-        arg5);
+    case 77: sfunc = reinterpret_cast<syscall_func>(delegate_sys_mmap_device_memory);
        break;
-    case 78: ret = reinterpret_cast<syscall_func3>(sys_io_mapping_get_info)(
-        arg1,
-        arg2,
-        arg3);
+    case 78: sfunc = reinterpret_cast<syscall_func>(delegate_sys_io_mapping_get_info);
        break;
-    case 79: ret = reinterpret_cast<syscall_func4>(sys_vmo_create_contiguous)(
-        arg1,
-        arg2,
-        arg3,
-        arg4);
+    case 79: sfunc = reinterpret_cast<syscall_func>(delegate_sys_vmo_create_contiguous);
        break;
-    case 80: ret = reinterpret_cast<syscall_func6>(sys_vmar_allocate)(
-        arg1,
-        arg2,
-        arg3,
-        arg4,
-        arg5,
-        arg6);
+    case 80: sfunc = reinterpret_cast<syscall_func>(delegate_sys_vmar_allocate);
        break;
-    case 81: ret = reinterpret_cast<syscall_func1>(sys_vmar_destroy)(
-        arg1);
+    case 81: sfunc = reinterpret_cast<syscall_func>(delegate_sys_vmar_destroy);
        break;
-    case 82: ret = reinterpret_cast<syscall_func7>(sys_vmar_map)(
-        arg1,
-        arg2,
-        arg3,
-        arg4,
-        arg5,
-        arg6,
-        arg7);
+    case 82: sfunc = reinterpret_cast<syscall_func>(delegate_sys_vmar_map);
        break;
-    case 83: ret = reinterpret_cast<syscall_func3>(sys_vmar_unmap)(
-        arg1,
-        arg2,
-        arg3);
+    case 83: sfunc = reinterpret_cast<syscall_func>(delegate_sys_vmar_unmap);
        break;
-    case 84: ret = reinterpret_cast<syscall_func4>(sys_vmar_protect)(
-        arg1,
-        arg2,
-        arg3,
-        arg4);
+    case 84: sfunc = reinterpret_cast<syscall_func>(delegate_sys_vmar_protect);
        break;
-    case 85: ret = reinterpret_cast<syscall_func4>(sys_bootloader_fb_get_info)(
-        arg1,
-        arg2,
-        arg3,
-        arg4);
+    case 85: sfunc = reinterpret_cast<syscall_func>(delegate_sys_bootloader_fb_get_info);
        break;
-    case 86: ret = reinterpret_cast<syscall_func7>(sys_set_framebuffer)(
-        arg1,
-        arg2,
-        arg3,
-        arg4,
-        arg5,
-        arg6,
-        arg7);
+    case 86: sfunc = reinterpret_cast<syscall_func>(delegate_sys_set_framebuffer);
        break;
-    case 87: ret = reinterpret_cast<syscall_func3>(sys_clock_adjust)(
-        arg1,
-        arg2,
-        arg3);
+    case 87: sfunc = reinterpret_cast<syscall_func>(delegate_sys_clock_adjust);
        break;
-    case 88: ret = reinterpret_cast<syscall_func3>(sys_pci_get_nth_device)(
-        arg1,
-        arg2,
-        arg3);
+    case 88: sfunc = reinterpret_cast<syscall_func>(delegate_sys_pci_get_nth_device);
        break;
-    case 89: ret = reinterpret_cast<syscall_func1>(sys_pci_claim_device)(
-        arg1);
+    case 89: sfunc = reinterpret_cast<syscall_func>(delegate_sys_pci_claim_device);
        break;
-    case 90: ret = reinterpret_cast<syscall_func2>(sys_pci_enable_bus_master)(
-        arg1,
-        arg2);
+    case 90: sfunc = reinterpret_cast<syscall_func>(delegate_sys_pci_enable_bus_master);
        break;
-    case 91: ret = reinterpret_cast<syscall_func2>(sys_pci_enable_pio)(
-        arg1,
-        arg2);
+    case 91: sfunc = reinterpret_cast<syscall_func>(delegate_sys_pci_enable_pio);
        break;
-    case 92: ret = reinterpret_cast<syscall_func1>(sys_pci_reset_device)(
-        arg1);
+    case 92: sfunc = reinterpret_cast<syscall_func>(delegate_sys_pci_reset_device);
        break;
-    case 93: ret = reinterpret_cast<syscall_func3>(sys_pci_map_mmio)(
-        arg1,
-        arg2,
-        arg3);
+    case 93: sfunc = reinterpret_cast<syscall_func>(delegate_sys_pci_map_mmio);
        break;
-    case 94: ret = reinterpret_cast<syscall_func5>(sys_pci_io_write)(
-        arg1,
-        arg2,
-        arg3,
-        arg4,
-        arg5);
+    case 94: sfunc = reinterpret_cast<syscall_func>(delegate_sys_pci_io_write);
        break;
-    case 95: ret = reinterpret_cast<syscall_func5>(sys_pci_io_read)(
-        arg1,
-        arg2,
-        arg3,
-        arg4,
-        arg5);
+    case 95: sfunc = reinterpret_cast<syscall_func>(delegate_sys_pci_io_read);
        break;
-    case 96: ret = reinterpret_cast<syscall_func2>(sys_pci_map_interrupt)(
-        arg1,
-        arg2);
+    case 96: sfunc = reinterpret_cast<syscall_func>(delegate_sys_pci_map_interrupt);
        break;
-    case 97: ret = reinterpret_cast<syscall_func1>(sys_pci_map_config)(
-        arg1);
+    case 97: sfunc = reinterpret_cast<syscall_func>(delegate_sys_pci_map_config);
        break;
-    case 98: ret = reinterpret_cast<syscall_func3>(sys_pci_query_irq_mode_caps)(
-        arg1,
-        arg2,
-        arg3);
+    case 98: sfunc = reinterpret_cast<syscall_func>(delegate_sys_pci_query_irq_mode_caps);
        break;
-    case 99: ret = reinterpret_cast<syscall_func3>(sys_pci_set_irq_mode)(
-        arg1,
-        arg2,
-        arg3);
+    case 99: sfunc = reinterpret_cast<syscall_func>(delegate_sys_pci_set_irq_mode);
        break;
-    case 100: ret = reinterpret_cast<syscall_func3>(sys_pci_init)(
-        arg1,
-        arg2,
-        arg3);
+    case 100: sfunc = reinterpret_cast<syscall_func>(delegate_sys_pci_init);
        break;
-    case 101: ret = reinterpret_cast<syscall_func5>(sys_pci_add_subtract_io_range)(
-        arg1,
-        arg2,
-        arg3,
-        arg4,
-        arg5);
+    case 101: sfunc = reinterpret_cast<syscall_func>(delegate_sys_pci_add_subtract_io_range);
        break;
-    case 102: ret = reinterpret_cast<syscall_func1>(sys_acpi_uefi_rsdp)(
-        arg1);
+    case 102: sfunc = reinterpret_cast<syscall_func>(delegate_sys_acpi_uefi_rsdp);
        break;
-    case 103: ret = reinterpret_cast<syscall_func1>(sys_acpi_cache_flush)(
-        arg1);
+    case 103: sfunc = reinterpret_cast<syscall_func>(delegate_sys_acpi_cache_flush);
        break;
-    case 104: ret = reinterpret_cast<syscall_func4>(sys_resource_create)(
-        arg1,
-        arg2,
-        arg3,
-        arg4);
+    case 104: sfunc = reinterpret_cast<syscall_func>(delegate_sys_resource_create);
        break;
-    case 105: ret = reinterpret_cast<syscall_func4>(sys_resource_get_handle)(
-        arg1,
-        arg2,
-        arg3,
-        arg4);
+    case 105: sfunc = reinterpret_cast<syscall_func>(delegate_sys_resource_get_handle);
        break;
-    case 106: ret = reinterpret_cast<syscall_func5>(sys_resource_do_action)(
-        arg1,
-        arg2,
-        arg3,
-        arg4,
-        arg5);
+    case 106: sfunc = reinterpret_cast<syscall_func>(delegate_sys_resource_do_action);
        break;
-    case 107: ret = reinterpret_cast<syscall_func2>(sys_resource_connect)(
-        arg1,
-        arg2);
+    case 107: sfunc = reinterpret_cast<syscall_func>(delegate_sys_resource_connect);
        break;
-    case 108: ret = reinterpret_cast<syscall_func2>(sys_resource_accept)(
-        arg1,
-        arg2);
+    case 108: sfunc = reinterpret_cast<syscall_func>(delegate_sys_resource_accept);
        break;
-    case 109: ret = reinterpret_cast<syscall_func0>(sys_syscall_test_0)();
+    case 109: sfunc = reinterpret_cast<syscall_func>(delegate_sys_syscall_test_0);
        break;
-    case 110: ret = reinterpret_cast<syscall_func1>(sys_syscall_test_1)(
-        arg1);
+    case 110: sfunc = reinterpret_cast<syscall_func>(delegate_sys_syscall_test_1);
        break;
-    case 111: ret = reinterpret_cast<syscall_func2>(sys_syscall_test_2)(
-        arg1,
-        arg2);
+    case 111: sfunc = reinterpret_cast<syscall_func>(delegate_sys_syscall_test_2);
        break;
-    case 112: ret = reinterpret_cast<syscall_func3>(sys_syscall_test_3)(
-        arg1,
-        arg2,
-        arg3);
+    case 112: sfunc = reinterpret_cast<syscall_func>(delegate_sys_syscall_test_3);
        break;
-    case 113: ret = reinterpret_cast<syscall_func4>(sys_syscall_test_4)(
-        arg1,
-        arg2,
-        arg3,
-        arg4);
+    case 113: sfunc = reinterpret_cast<syscall_func>(delegate_sys_syscall_test_4);
        break;
-    case 114: ret = reinterpret_cast<syscall_func5>(sys_syscall_test_5)(
-        arg1,
-        arg2,
-        arg3,
-        arg4,
-        arg5);
+    case 114: sfunc = reinterpret_cast<syscall_func>(delegate_sys_syscall_test_5);
        break;
-    case 115: ret = reinterpret_cast<syscall_func6>(sys_syscall_test_6)(
-        arg1,
-        arg2,
-        arg3,
-        arg4,
-        arg5,
-        arg6);
+    case 115: sfunc = reinterpret_cast<syscall_func>(delegate_sys_syscall_test_6);
        break;
-    case 116: ret = reinterpret_cast<syscall_func7>(sys_syscall_test_7)(
-        arg1,
-        arg2,
-        arg3,
-        arg4,
-        arg5,
-        arg6,
-        arg7);
+    case 116: sfunc = reinterpret_cast<syscall_func>(delegate_sys_syscall_test_7);
        break;
-    case 117: ret = reinterpret_cast<syscall_func8>(sys_syscall_test_8)(
-        arg1,
-        arg2,
-        arg3,
-        arg4,
-        arg5,
-        arg6,
-        arg7,
-        arg8);
+    case 117: sfunc = reinterpret_cast<syscall_func>(delegate_sys_syscall_test_8);
        break;
 
diff --git a/kernel/lib/magenta/include/magenta/gen-sysdefs.h b/kernel/lib/magenta/include/magenta/gen-sysdefs.h
index 864721a..53dcc3e 100644
--- a/kernel/lib/magenta/include/magenta/gen-sysdefs.h
+++ b/kernel/lib/magenta/include/magenta/gen-sysdefs.h
@@ -14,7 +14,7 @@
 uint32_t sys_num_cpus();
 
 mx_status_t sys_version_get(
-    char* version,
+    char version[],
     uint32_t version_len);
 
 mx_status_t sys_cache_flush(
@@ -28,21 +28,21 @@
 mx_status_t sys_handle_duplicate(
     mx_handle_t handle,
     mx_rights_t rights,
-    mx_handle_t* out);
+    mx_handle_t out[1]);
 
 mx_status_t sys_handle_replace(
     mx_handle_t handle,
     mx_rights_t rights,
-    mx_handle_t* out);
+    mx_handle_t out[1]);
 
 mx_status_t sys_handle_wait_one(
     mx_handle_t handle,
     mx_signals_t waitfor,
     mx_time_t timeout,
-    mx_signals_t* observed);
+    mx_signals_t observed[1]);
 
 mx_status_t sys_handle_wait_many(
-    mx_wait_item_t* items,
+    mx_wait_item_t items[],
     uint32_t count,
     mx_time_t timeout);
 
@@ -73,14 +73,14 @@
     uint32_t topic,
     void* buffer,
     size_t buffer_size,
-    size_t* actual_count,
-    size_t* avail_count);
+    size_t actual_count[1],
+    size_t avail_count[1]);
 
 mx_status_t sys_object_get_child(
     mx_handle_t handle,
     uint64_t koid,
     mx_rights_t rights,
-    mx_handle_t* out);
+    mx_handle_t out[1]);
 
 mx_status_t sys_object_bind_exception_port(
     mx_handle_t object,
@@ -90,63 +90,63 @@
 
 mx_status_t sys_channel_create(
     uint32_t options,
-    mx_handle_t* out0,
-    mx_handle_t* out1);
+    mx_handle_t out0[1],
+    mx_handle_t out1[1]);
 
 mx_status_t sys_channel_read(
     mx_handle_t handle,
     uint32_t options,
     void* bytes,
     uint32_t num_bytes,
-    uint32_t* actual_bytes,
-    mx_handle_t* handles,
+    uint32_t actual_bytes[1],
+    mx_handle_t handles[],
     uint32_t num_handles,
-    uint32_t* actual_handles);
+    uint32_t actual_handles[1]);
 
 mx_status_t sys_channel_write(
     mx_handle_t handle,
     uint32_t options,
     const void* bytes,
     uint32_t num_bytes,
-    const mx_handle_t* handles,
+    const mx_handle_t handles[],
     uint32_t num_handles);
 
 mx_status_t sys_channel_call(
     mx_handle_t handle,
     uint32_t options,
     mx_time_t timeout,
-    const mx_channel_call_args_t* args,
-    uint32_t* actual_bytes,
-    uint32_t* actual_handles,
-    mx_status_t* read_status);
+    const mx_channel_call_args_t args[1],
+    uint32_t actual_bytes[1],
+    uint32_t actual_handles[1],
+    mx_status_t read_status[1]);
 
 mx_status_t sys_socket_create(
     uint32_t options,
-    mx_handle_t* out0,
-    mx_handle_t* out1);
+    mx_handle_t out0[1],
+    mx_handle_t out1[1]);
 
 mx_status_t sys_socket_write(
     mx_handle_t handle,
     uint32_t options,
     const void* buffer,
     size_t size,
-    size_t* actual);
+    size_t actual[1]);
 
 mx_status_t sys_socket_read(
     mx_handle_t handle,
     uint32_t options,
     void* buffer,
     size_t size,
-    size_t* actual);
+    size_t actual[1]);
 
 void sys_thread_exit();
 
 mx_status_t sys_thread_create(
     mx_handle_t process,
-    const char* name,
+    const char name[],
     uint32_t name_len,
     uint32_t options,
-    mx_handle_t* out);
+    mx_handle_t out[1]);
 
 mx_status_t sys_thread_start(
     mx_handle_t handle,
@@ -160,7 +160,7 @@
     uint32_t kind,
     void* buffer,
     uint32_t len,
-    uint32_t* actual);
+    uint32_t actual[1]);
 
 mx_status_t sys_thread_write_state(
     mx_handle_t handle,
@@ -173,11 +173,11 @@
 
 mx_status_t sys_process_create(
     mx_handle_t job,
-    const char* name,
+    const char name[],
     uint32_t name_len,
     uint32_t options,
-    mx_handle_t* proc_handle,
-    mx_handle_t* vmar_handle);
+    mx_handle_t proc_handle[1],
+    mx_handle_t vmar_handle[1]);
 
 mx_status_t sys_process_start(
     mx_handle_t process_handle,
@@ -192,19 +192,19 @@
     uintptr_t vaddr,
     void* buffer,
     size_t len,
-    size_t* actual);
+    size_t actual[1]);
 
 mx_status_t sys_process_write_memory(
     mx_handle_t proc,
     uintptr_t vaddr,
     const void* buffer,
     size_t len,
-    size_t* actual);
+    size_t actual[1]);
 
 mx_status_t sys_job_create(
     mx_handle_t parent_job,
     uint32_t options,
-    mx_handle_t* out);
+    mx_handle_t out[1]);
 
 mx_status_t sys_task_resume(
     mx_handle_t task_handle,
@@ -215,32 +215,32 @@
 
 mx_status_t sys_event_create(
     uint32_t options,
-    mx_handle_t* out);
+    mx_handle_t out[1]);
 
 mx_status_t sys_eventpair_create(
     uint32_t options,
-    mx_handle_t* out0,
-    mx_handle_t* out1);
+    mx_handle_t out0[1],
+    mx_handle_t out1[1]);
 
 mx_status_t sys_futex_wait(
-    mx_futex_t* value_ptr,
+    mx_futex_t value_ptr[1],
     int current_value,
     mx_time_t timeout);
 
 mx_status_t sys_futex_wake(
-    mx_futex_t* value_ptr,
+    mx_futex_t value_ptr[1],
     uint32_t count);
 
 mx_status_t sys_futex_requeue(
-    mx_futex_t* wake_ptr,
+    mx_futex_t wake_ptr[1],
     uint32_t wake_count,
     int current_value,
-    mx_futex_t* requeue_ptr,
+    mx_futex_t requeue_ptr[1],
     uint32_t requeue_count);
 
 mx_status_t sys_waitset_create(
     uint32_t options,
-    mx_handle_t* out);
+    mx_handle_t out[1]);
 
 mx_status_t sys_waitset_add(
     mx_handle_t waitset_handle,
@@ -255,12 +255,12 @@
 mx_status_t sys_waitset_wait(
     mx_handle_t waitset_handle,
     mx_time_t timeout,
-    mx_waitset_result_t* results,
-    uint32_t* count);
+    mx_waitset_result_t results[],
+    uint32_t count[1]);
 
 mx_status_t sys_port_create(
     uint32_t options,
-    mx_handle_t* out);
+    mx_handle_t out[1]);
 
 mx_status_t sys_port_queue(
     mx_handle_t handle,
@@ -282,25 +282,25 @@
 mx_status_t sys_vmo_create(
     uint64_t size,
     uint32_t options,
-    mx_handle_t* out);
+    mx_handle_t out[1]);
 
 mx_status_t sys_vmo_read(
     mx_handle_t handle,
     void* data,
     uint64_t offset,
     size_t len,
-    size_t* actual);
+    size_t actual[1]);
 
 mx_status_t sys_vmo_write(
     mx_handle_t handle,
     const void* data,
     uint64_t offset,
     size_t len,
-    size_t* actual);
+    size_t actual[1]);
 
 mx_status_t sys_vmo_get_size(
     mx_handle_t handle,
-    uint64_t* size);
+    uint64_t size[1]);
 
 mx_status_t sys_vmo_set_size(
     mx_handle_t handle,
@@ -317,7 +317,7 @@
 mx_status_t sys_cprng_draw(
     void* buffer,
     size_t len,
-    size_t* actual);
+    size_t actual[1]);
 
 mx_status_t sys_cprng_add_entropy(
     const void* buffer,
@@ -325,17 +325,17 @@
 
 mx_status_t sys_fifo0_create(
     uint64_t count,
-    mx_handle_t* out);
+    mx_handle_t out[1]);
 
 mx_status_t sys_fifo0_op(
     mx_handle_t handle,
     uint32_t op,
     uint64_t val,
-    mx_fifo_state_t* out);
+    mx_fifo_state_t out[1]);
 
 mx_status_t sys_log_create(
     uint32_t options,
-    mx_handle_t* out);
+    mx_handle_t out[1]);
 
 mx_status_t sys_log_write(
     mx_handle_t handle,
@@ -354,7 +354,7 @@
     void* data,
     uint32_t offset,
     uint32_t len,
-    uint32_t* actual);
+    uint32_t actual[1]);
 
 mx_status_t sys_ktrace_control(
     mx_handle_t handle,
@@ -415,26 +415,26 @@
     mx_paddr_t paddr,
     uint32_t len,
     mx_cache_policy_t cache_policy,
-    uintptr_t* out_vaddr);
+    uintptr_t out_vaddr[1]);
 
 mx_status_t sys_io_mapping_get_info(
     mx_handle_t handle,
-    uintptr_t* out_vaddr,
-    uint64_t* out_size);
+    uintptr_t out_vaddr[1],
+    uint64_t out_size[1]);
 
 mx_status_t sys_vmo_create_contiguous(
     mx_handle_t rsrc_handle,
     size_t size,
     uint32_t alignment_log2,
-    mx_handle_t* out);
+    mx_handle_t out[1]);
 
 mx_status_t sys_vmar_allocate(
     mx_handle_t parent_vmar_handle,
     size_t offset,
     size_t size,
     uint32_t flags,
-    mx_handle_t* child_vmar,
-    uintptr_t* child_addr);
+    mx_handle_t child_vmar[1],
+    uintptr_t child_addr[1]);
 
 mx_status_t sys_vmar_destroy(
     mx_handle_t vmar_handle);
@@ -446,7 +446,7 @@
     uint64_t vmo_offset,
     size_t len,
     uint32_t flags,
-    uintptr_t* mapped_addr);
+    uintptr_t mapped_addr[1]);
 
 mx_status_t sys_vmar_unmap(
     mx_handle_t vmar_handle,
@@ -460,10 +460,10 @@
     uint32_t prot);
 
 mx_status_t sys_bootloader_fb_get_info(
-    uint32_t* format,
-    uint32_t* width,
-    uint32_t* height,
-    uint32_t* stride);
+    uint32_t format[1],
+    uint32_t width[1],
+    uint32_t height[1],
+    uint32_t stride[1]);
 
 mx_status_t sys_set_framebuffer(
     mx_handle_t handle,
@@ -482,7 +482,7 @@
 mx_handle_t sys_pci_get_nth_device(
     mx_handle_t handle,
     uint32_t index,
-    mx_pcie_get_nth_info_t* out_info);
+    mx_pcie_get_nth_info_t out_info[1]);
 
 mx_status_t sys_pci_claim_device(
     mx_handle_t handle);
@@ -515,7 +515,7 @@
     uint32_t bar_num,
     uint32_t offset,
     uint32_t len,
-    uint32_t* out_value);
+    uint32_t out_value[1]);
 
 mx_handle_t sys_pci_map_interrupt(
     mx_handle_t handle,
@@ -527,7 +527,7 @@
 mx_status_t sys_pci_query_irq_mode_caps(
     mx_handle_t handle,
     uint32_t mode,
-    uint32_t* out_max_irqs);
+    uint32_t out_max_irqs[1]);
 
 mx_status_t sys_pci_set_irq_mode(
     mx_handle_t handle,
@@ -536,7 +536,7 @@
 
 mx_status_t sys_pci_init(
     mx_handle_t handle,
-    const mx_pci_init_arg_t* init_buf,
+    const mx_pci_init_arg_t init_buf[],
     uint32_t len);
 
 mx_status_t sys_pci_add_subtract_io_range(
@@ -554,15 +554,15 @@
 
 mx_status_t sys_resource_create(
     mx_handle_t parent_handle,
-    const mx_rrec_t* records,
+    const mx_rrec_t records[],
     uint32_t count,
-    mx_handle_t* resource_out);
+    mx_handle_t resource_out[1]);
 
 mx_status_t sys_resource_get_handle(
     mx_handle_t handle,
     uint32_t index,
     uint32_t options,
-    mx_handle_t* out);
+    mx_handle_t out[1]);
 
 mx_status_t sys_resource_do_action(
     mx_handle_t handle,
@@ -577,7 +577,7 @@
 
 mx_status_t sys_resource_accept(
     mx_handle_t handle,
-    mx_handle_t* channel);
+    mx_handle_t channel[1]);
 
 int sys_syscall_test_0();
 
diff --git a/kernel/lib/syscalls/rules.mk b/kernel/lib/syscalls/rules.mk
index 82f4f9c..a6b8283 100644
--- a/kernel/lib/syscalls/rules.mk
+++ b/kernel/lib/syscalls/rules.mk
@@ -27,6 +27,7 @@
     $(LOCAL_DIR)/syscalls_magenta.cpp \
     $(LOCAL_DIR)/syscalls_object.cpp \
     $(LOCAL_DIR)/syscalls_port.cpp \
+    $(LOCAL_DIR)/syscalls_priv_del.cpp \
     $(LOCAL_DIR)/syscalls_resource.cpp \
     $(LOCAL_DIR)/syscalls_task.cpp \
     $(LOCAL_DIR)/syscalls_test.cpp \
diff --git a/kernel/lib/syscalls/syscalls.cpp b/kernel/lib/syscalls/syscalls.cpp
index 29356e9..42c52aa 100644
--- a/kernel/lib/syscalls/syscalls.cpp
+++ b/kernel/lib/syscalls/syscalls.cpp
@@ -22,44 +22,23 @@
 #include <string.h>
 #include <trace.h>
 
-#include "syscalls_priv.h"
+#include "syscalls_priv_del.h"
 
 #define LOCAL_TRACE 0
 
-using syscall_func0 = int64_t (*)();
-using syscall_func1 = int64_t (*)(uint64_t a);
-using syscall_func2 = int64_t (*)(uint64_t a, uint64_t b);
-using syscall_func3 = int64_t (*)(uint64_t a, uint64_t b, uint64_t c);
-using syscall_func4 = int64_t (*)(uint64_t a, uint64_t b, uint64_t c, uint64_t d);
-using syscall_func5 = int64_t (*)(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e);
-using syscall_func6 = int64_t (*)(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e,
-                                  uint64_t f);
-using syscall_func7 = int64_t (*)(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e,
-                                  uint64_t f, uint64_t g);
-using syscall_func8 = int64_t (*)(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e,
-                                  uint64_t f, uint64_t g, uint64_t h);
-
 int sys_invalid_syscall(void) {
     LTRACEF("invalid syscall\n");
     return ERR_BAD_SYSCALL;
 }
 
-inline uint64_t invoke_syscall(uint64_t syscall_num, uint64_t arg1, uint64_t arg2, uint64_t arg3,
-                               uint64_t arg4, uint64_t arg5, uint64_t arg6, uint64_t arg7, uint64_t arg8) {
-    uint64_t ret;
-
-    switch (syscall_num) {
-#include <magenta/gen-switch.inc>
-        default:
-            ret = sys_invalid_syscall();
-    }
-
-    return ret;
-}
+#define MAGENTA_VDSOCALL_DEF(ret, name, args...) // Nothing to do here.
 
 #if ARCH_ARM64
 #include <arch/arm64.h>
 
+using syscall_func = int64_t (*)(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e,
+                                 uint64_t f, uint64_t g, uint64_t h);
+
 extern "C" void arm64_syscall(struct arm64_iframe_long* frame, bool is_64bit, uint32_t syscall_imm, uint64_t pc) {
     uint64_t syscall_num = frame->r[16];
 
@@ -78,9 +57,25 @@
 
     LTRACEF_LEVEL(2, "num %" PRIu64 "\n", syscall_num);
 
+    /* build a function pointer to call the routine.
+     * the args are jammed into the function independent of if the function
+     * uses them or not, which is safe for simple arg passing.
+     */
+    syscall_func sfunc;
+
+    switch (syscall_num) {
+#define MAGENTA_SYSCALL_DEF(nargs64, nargs32, n, ret, name, args...)                               \
+    case n:                                                                                        \
+        sfunc = reinterpret_cast<syscall_func>(sys_##name);                                        \
+        break;
+#include <magenta/gen-switch.inc>
+        default:
+            sfunc = reinterpret_cast<syscall_func>(sys_invalid_syscall);
+    }
+
     /* call the routine */
-    uint64_t ret = invoke_syscall(syscall_num, frame->r[0], frame->r[1], frame->r[2], frame->r[3],
-                                  frame->r[4], frame->r[5], frame->r[6], frame->r[7]);
+    uint64_t ret = sfunc(frame->r[0], frame->r[1], frame->r[2], frame->r[3], frame->r[4],
+                         frame->r[5], frame->r[6], frame->r[7]);
 
     LTRACEF_LEVEL(2, "ret %#" PRIx64 "\n", ret);
 
@@ -101,6 +96,9 @@
 #if ARCH_X86_64
 #include <arch/x86.h>
 
+using syscall_func = int64_t (*)(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e,
+                                 uint64_t f, uint64_t g, uint64_t h);
+
 uint64_t x86_64_syscall(uint64_t arg1, uint64_t arg2, uint64_t arg3, uint64_t arg4,
                         uint64_t arg5, uint64_t arg6, uint64_t arg7, uint64_t arg8,
                         uint64_t syscall_num, uint64_t ip) {
@@ -121,7 +119,24 @@
     LTRACEF_LEVEL(2, "t %p syscall num %" PRIu64 " ip %#" PRIx64 "\n",
                   get_current_thread(), syscall_num, ip);
 
-    uint64_t ret = invoke_syscall(syscall_num, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
+    /* build a function pointer to call the routine.
+     * the args are jammed into the function independent of if the function
+     * uses them or not, which is safe for simple arg passing.
+     */
+    syscall_func sfunc;
+
+    switch (syscall_num) {
+#define MAGENTA_SYSCALL_DEF(nargs64, nargs32, n, ret, name, args...)                               \
+    case n:                                                                                        \
+        sfunc = reinterpret_cast<syscall_func>(sys_##name);                                        \
+        break;
+#include <magenta/gen-switch.inc>
+        default:
+            sfunc = reinterpret_cast<syscall_func>(sys_invalid_syscall);
+    }
+
+    /* call the routine */
+    uint64_t ret = sfunc(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
 
     /* check to see if there are any pending signals */
     thread_process_pending_signals();
diff --git a/kernel/lib/syscalls/syscalls_priv_del.cpp b/kernel/lib/syscalls/syscalls_priv_del.cpp
new file mode 100644
index 0000000..e87dbce
--- /dev/null
+++ b/kernel/lib/syscalls/syscalls_priv_del.cpp
@@ -0,0 +1,10 @@
+// Copyright 2017 The Fuchsia Authors
+//
+// Use of this source code is governed by a MIT-style
+// license that can be found in the LICENSE file or at
+// https://opensource.org/licenses/MIT
+
+#include "syscalls_priv.h"
+#include "syscalls_priv_del.h"
+
+#include <magenta/gen-del.inc>
diff --git a/kernel/lib/syscalls/syscalls_priv_del.h b/kernel/lib/syscalls/syscalls_priv_del.h
new file mode 100644
index 0000000..4a4b0bd
--- /dev/null
+++ b/kernel/lib/syscalls/syscalls_priv_del.h
@@ -0,0 +1,13 @@
+// Copyright 2016 The Fuchsia Authors
+//
+// Use of this source code is governed by a MIT-style
+// license that can be found in the LICENSE file or at
+// https://opensource.org/licenses/MIT
+
+#pragma once
+
+#include <magenta/types.h>
+#include <magenta/syscalls/types.h>
+#include <lib/user_copy/user_ptr.h>
+
+#include <magenta/gen-del-sysdefs.h>
diff --git a/scripts/run-sysgen b/scripts/run-sysgen
index 5103a2f..431aab5 100755
--- a/scripts/run-sysgen
+++ b/scripts/run-sysgen
@@ -13,6 +13,8 @@
 rm -f generated.arm64.S
 rm -f generated.kernel.h
 rm -f generated.kernel.inc
+rm -f generated.kernel-del.h
+rm -f generated.kernel-del.inc
 rm -f generated.user.h
 rm -f generated.x86-64.S
 rm -f generated.syscall-numbers.h
@@ -41,5 +43,9 @@
     kernel/lib/magenta/include/magenta/gen-sysdefs.h
 rsync $rsync_options generated.kernel.inc \
     kernel/lib/magenta/include/magenta/gen-switch.inc
+rsync $rsync_options generated.kernel-del.h \
+    kernel/lib/magenta/include/magenta/gen-del-sysdefs.h
+rsync $rsync_options generated.kernel-del.inc \
+    kernel/lib/magenta/include/magenta/gen-del.inc
 rsync $rsync_options generated.trace.inc \
     kernel/lib/magenta/include/magenta/gen-trace.inc
diff --git a/system/tools/sysgen.cpp b/system/tools/sysgen.cpp
index 505a3b5..5ec940c 100644
--- a/system/tools/sysgen.cpp
+++ b/system/tools/sysgen.cpp
@@ -472,7 +472,6 @@
     const char* empty_args;
     const char* switch_var;
     const char* switch_type;
-    const bool  prefer_pointers;
     std::map<string, string> attributes;
 };
 
@@ -561,15 +560,11 @@
                 if (arg.arr_spec->kind == ArraySpec::IN)
                     os << "const ";
 
-                if (gp.prefer_pointers) {
-                    os << arg.type << "* " << arg.name;
-                } else {
-                    os << arg.type << " " << arg.name;
-                    os << "[";
-                    if (arg.arr_spec->count)
-                        os << arg.arr_spec->count;
-                    os << "]";
-                }
+                os << arg.type << " " << arg.name;
+                os << "[";
+                if (arg.arr_spec->count)
+                    os << arg.arr_spec->count;
+                os << "]";
             }
 
             os << ",";
@@ -603,18 +598,14 @@
     return os.good();
 }
 
-bool generate_legacy_code(
-    int index, const GenParams& gp, std::ofstream& os, const Syscall& sc) {
+bool generate_legacy_delegate_code(int index, const GenParams& gp, std::ofstream& os, const Syscall& sc) {
     if (is_vdso(sc))
         return true;
 
-    constexpr uint32_t indent_spaces = 8u;
+    constexpr uint32_t indent_spaces = 4u;
 
     auto syscall_name = gp.name_prefix + sc.name;
 
-    // case 0: ret =
-    os << "    case " << index << ": " << gp.switch_var << " = ";
-
     string ret_type;
     if (sc.ret_spec.empty()) {
         ret_type = override_type(string());
@@ -625,26 +616,37 @@
         }
         ret_type = override_type(sc.ret_spec[0].to_string());
     }
-    int num_args = sc.arg_spec.size();
-
-    bool is_void = ret_type.compare("void") == 0;
-    if (is_void) {
-        // void function - synthesise an empty return value.
-        // case 0: ret = 0; sys_andy(
-        os << "0; ";
-    }
-    os << "reinterpret_cast<syscall_func" << num_args << ">(" << syscall_name << ")(";
+    os << ret_type;
+    os << " " << syscall_name << "(";
 
     // Writes all arguments.
-    int arg_num = 1;
+    string delegate_args;
+
     for (const auto& arg : sc.arg_spec) {
         if (!os.good())
             return false;
-
         // writes each parameter in its own line.
         os << "\n" << string(indent_spaces, ' ');
-        os << "arg" << arg_num << ",";
-        ++arg_num;
+
+        auto overrided = override_type(arg.to_string());
+
+        if (overrided != arg.to_string()) {
+            os << overrided << " " << arg.name;
+        } else if (!arg.arr_spec) {
+            os << arg.type << " " << arg.name;
+        } else {
+            if (arg.arr_spec->kind == ArraySpec::IN)
+                os << "const ";
+
+            os << arg.type << " " << arg.name;
+            os << "[";
+            if (arg.arr_spec->count)
+                os << arg.arr_spec->count;
+            os << "]";
+        }
+
+        os << ",";
+        delegate_args = delegate_args + arg.name + ", ";
     }
 
     if (!sc.arg_spec.empty()) {
@@ -660,11 +662,24 @@
 
     os.seekp(-1, std::ios_base::end);
 
-    os << ";\n       break;\n";
+    os << "{\n    ";
+    if (ret_type.compare("void") != 0) {
+        os << "return ";
+    }
+    os << "sys_" << sc.name << "(" << delegate_args.substr(0, delegate_args.length() - 2) << ");\n}\n\n";
 
     return os.good();
 }
 
+bool generate_legacy_code(int index, const GenParams& gp, std::ofstream& os, const Syscall& sc) {
+    if (is_vdso(sc))
+        return true;
+    os << "    case " << index << ": " << gp.switch_var
+       << " = reinterpret_cast<" << gp.switch_type << ">(" << gp.name_prefix << sc.name <<");\n"
+       << "       break;\n";
+    return os.good();
+}
+
 bool generate_legacy_assembly_x64(
     int index, const GenParams& gp, std::ofstream& os, const Syscall& sc) {
     if (is_vdso(sc))
@@ -714,7 +729,9 @@
 enum GenType : uint32_t {
     UserHeaderC,
     KernelHeaderCPP,
+    KernelDelegationHeaderCPP,
     KernelCodeCPP,
+    KernelDelegationCodeCPP,
     KernelAsmIntel64,
     KernelAsmArm64,
     SyscallNumberHeader,
@@ -732,7 +749,6 @@
         "void",             // no-args special type
         nullptr,            // switch var (does not apply)
         nullptr,            // switch type (does not apply)
-        false,
         user_attrs,         // attributes dictionary
     },
     // The kernel header, C++.  (KernelHeaderCPP)
@@ -741,20 +757,33 @@
         ".kernel.h",        // file postfix.
         nullptr,            // no function prefix.
         "sys_",             // function name prefix.
-        nullptr,
-        nullptr,
-        nullptr,
-        true,               // output arrays as pointers
+    },
+    // The kernel header, C++.  (KernelHeaderCPP)
+    {
+        generate_legacy_header,
+        ".kernel-del.h",    // file postfix.
+        nullptr,            // no function prefix.
+        "delegate_sys_",    // function name prefix.
     },
     // The kernel C++ code. A switch statement set.
     {
         generate_legacy_code,
         ".kernel.inc",      // file postfix.
         nullptr,            // no function prefix.
-        "sys_",             // function name prefix.
+        "delegate_sys_",             // function name prefix.
         nullptr,            // no-args (does not apply)
-        "ret",              // switch var name
-        "uint64_t"          // switch var type
+        "sfunc",            // switch var name
+        "syscall_func"      // switch var type
+    },
+    // The kernel C++ code. Function delegation.
+    {
+        generate_legacy_delegate_code,
+        ".kernel-del.inc",  // file postfix.
+        nullptr,            // no function prefix.
+        "delegate_sys_",             // function name prefix.
+        nullptr,            // no-args (does not apply)
+        "sfunc",            // switch var name
+        "syscall_func"      // switch var type
     },
     //  The assembly file for x86-64 (KernelAsmIntel64).
     {
@@ -941,8 +970,12 @@
         return 1;
     if (!generator.Generate(GenType::KernelHeaderCPP, output_prefix))
         return 1;
+    if (!generator.Generate(GenType::KernelDelegationHeaderCPP, output_prefix))
+        return 1;
     if (!generator.Generate(GenType::KernelCodeCPP, output_prefix))
         return 1;
+    if (!generator.Generate(GenType::KernelDelegationCodeCPP, output_prefix))
+        return 1;
     if (!generator.Generate(GenType::KernelAsmIntel64, output_prefix))
         return 1;
     if (!generator.Generate(GenType::KernelAsmArm64, output_prefix))