Changeset eadaeae8 in mainline for abi/include


Ignore:
Timestamp:
2018-03-21T20:58:49Z (8 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3be9d10
Parents:
874381a
Message:

Make capability handles type-safe

Define distinct pointer types for the handles of the supported
capability types and use them instead of integer handles. This makes it
virtually impossible to pass a non-handle or a handle of different type
instead of the proper handle. Also turn cap_handle_t into an "untyped"
capability handle that can be assigned to and from the "typed" handles.

This commit also fixes a bug in msim-con driver, which wrongly used the
IRQ number instead of the IRQ capability handle to unregister the IRQ.

This commit also fixes the wrong use of the capability handle instead
of error code in libusbhost.

Location:
abi/include/abi
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • abi/include/abi/cap.h

    r874381a readaeae8  
    3838#define CAP_NIL         0
    3939
    40 typedef int cap_handle_t;
     40#define CAP_HANDLE_VALID(handle)        ((handle) != CAP_NIL)
     41#define CAP_HANDLE_RAW(handle)          ((intptr_t) (handle))
     42
     43typedef void *cap_handle_t;
     44
     45typedef struct {} *cap_call_handle_t;
     46typedef struct {} *cap_phone_handle_t;
     47typedef struct {} *cap_irq_handle_t;
    4148
    4249#endif
  • abi/include/abi/ipc/methods.h

    r874381a readaeae8  
    3939
    4040/* Well known phone descriptors */
    41 #define PHONE_NS  (CAP_NIL + 1)
     41#define PHONE_NS  ((cap_phone_handle_t) (CAP_NIL + 1))
    4242
    4343/** Kernel IPC interfaces
  • abi/include/abi/mm/as.h

    r874381a readaeae8  
    3636#define ABI_AS_H_
    3737
     38#include <abi/cap.h>
     39
    3840/** Address space area flags. */
    3941#define AS_AREA_READ         0x01
     
    6264
    6365typedef struct {
    64         int pager;
     66        cap_phone_handle_t pager;
    6567        sysarg_t id1;
    6668        sysarg_t id2;
Note: See TracChangeset for help on using the changeset viewer.