Changeset 91b60499 in mainline for kernel/generic/include


Ignore:
Timestamp:
2017-09-30T06:29:42Z (8 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
300f4c4
Parents:
d076f16 (diff), 6636fb19 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge support for capabilities from lp:~jakub/helenos/caps

This commit introduces capabilities as task-local names for references to kernel
objects. Kernel objects are reference-counted wrappers for a select group of
objects allocated in and by the kernel that can be made accessible to userspace
in a controlled way via integer handles.

So far, a kernel object encapsulates either an irq_t or a phone_t.

Support for the former lead to the removal of kernel-assigned devnos and
unsecure deregistration of IRQs in which a random task was able to unregister
some other task's IRQ.

Location:
kernel/generic/include
Files:
1 added
1 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/adt/hash_table.h

    rd076f16 r91b60499  
    8282extern link_t *hash_table_find(hash_table_t *h, sysarg_t key[]);
    8383extern void hash_table_remove(hash_table_t *h, sysarg_t key[], size_t keys);
     84extern void hash_table_remove_item(hash_table_t *h, link_t *item);
    8485
    8586#endif
  • kernel/generic/include/ddi/irq.h

    rd076f16 r91b60499  
    4343#include <proc/task.h>
    4444#include <ipc/ipc.h>
     45#include <mm/slab.h>
     46
     47typedef enum {
     48        IRQ_HT_KEY_INR,
     49        IRQ_HT_KEY_MODE
     50} irq_ht_key_t;
     51
     52typedef enum {
     53        IRQ_HT_MODE_CLAIM,
     54        IRQ_HT_MODE_NO_CLAIM
     55} irq_ht_mode_t;
    4556
    4657typedef enum {
     
    7081        /** When false, notifications are not sent. */
    7182        bool notify;
     83        /** True if the structure is in irq_uspace_hash_table_table */
     84        bool hashed_in;
    7285        /** Answerbox for notifications. */
    7386        answerbox_t *answerbox;
     
    7689        /** Arguments that will be sent if the IRQ is claimed. */
    7790        uint32_t scratch[IPC_CALL_LEN];
    78         /** Top-half pseudocode. */
     91        /** Top-half IRQ code. */
    7992        irq_code_t *code;
    8093        /** Counter. */
    8194        size_t counter;
    82        
    83         /**
    84          * Link between IRQs that are notifying the same answerbox. The list is
    85          * protected by the answerbox irq_lock.
    86          */
    87         link_t link;
    8895} ipc_notif_cfg_t;
    8996
     
    9198 *
    9299 * If one device has multiple interrupts, there will be multiple irq_t
    93  * instantions with the same devno.
    94  *
     100 * instantions.
    95101 */
    96102typedef struct irq {
     
    112118         */
    113119        bool preack;
    114        
    115         /** Unique device number. -1 if not yet assigned. */
    116         devno_t devno;
    117120       
    118121        /** Actual IRQ number. -1 if not yet assigned. */
     
    139142extern hash_table_t irq_uspace_hash_table;
    140143
     144extern slab_cache_t *irq_slab;
     145
    141146extern inr_t last_inr;
    142147
  • kernel/generic/include/ipc/ipc.h

    rd076f16 r91b60499  
    4242#include <abi/proc/task.h>
    4343#include <typedefs.h>
    44 
    45 #define IPC_MAX_PHONES  64
     44#include <mm/slab.h>
     45#include <cap/cap.h>
    4646
    4747struct answerbox;
     
    6262
    6363/** Structure identifying phone (in TASK structure) */
    64 typedef struct {
     64typedef struct phone {
    6565        mutex_t lock;
    6666        link_t link;
     
    6969        ipc_phone_state_t state;
    7070        atomic_t active_calls;
     71        kobject_t *kobject;
    7172} phone_t;
    7273
     
    9495        /** Notifications from IRQ handlers. */
    9596        list_t irq_notifs;
    96         /** IRQs with notifications to this answerbox. */
    97         list_t irq_list;
    9897} answerbox_t;
    9998
     
    170169} call_t;
    171170
     171extern slab_cache_t *phone_slab;
     172
    172173extern answerbox_t *ipc_phone_0;
    173174
  • kernel/generic/include/ipc/ipcrsc.h

    rd076f16 r91b60499  
    3838#include <proc/task.h>
    3939#include <ipc/ipc.h>
     40#include <cap/cap.h>
    4041
    4142extern call_t *get_call(sysarg_t);
    42 extern int phone_get(sysarg_t, phone_t **);
    43 extern int phone_alloc(task_t *);
    44 extern bool phone_connect(int, answerbox_t *);
    45 extern void phone_dealloc(int);
     43extern cap_handle_t phone_alloc(task_t *);
     44extern bool phone_connect(cap_handle_t, answerbox_t *);
     45extern void phone_dealloc(cap_handle_t);
    4646
    4747#endif
  • kernel/generic/include/ipc/irq.h

    rd076f16 r91b60499  
    4747#include <adt/list.h>
    4848
    49 extern int ipc_irq_subscribe(answerbox_t *, inr_t, devno_t, sysarg_t,
    50     irq_code_t *);
    5149
    5250extern irq_ownership_t ipc_irq_top_half_claim(irq_t *);
    5351extern void ipc_irq_top_half_handler(irq_t *);
    5452
    55 extern int ipc_irq_unsubscribe(answerbox_t *, inr_t, devno_t);
    56 extern void ipc_irq_cleanup(answerbox_t *);
     53extern int ipc_irq_subscribe(answerbox_t *, inr_t, sysarg_t, irq_code_t *);
     54extern int ipc_irq_unsubscribe(answerbox_t *, int);
    5755
    5856/*
  • kernel/generic/include/ipc/sysipc.h

    rd076f16 r91b60499  
    5656extern sysarg_t sys_ipc_hangup(sysarg_t);
    5757
    58 extern sysarg_t sys_ipc_irq_subscribe(inr_t, devno_t, sysarg_t, irq_code_t *);
    59 extern sysarg_t sys_ipc_irq_unsubscribe(inr_t, devno_t);
     58extern sysarg_t sys_ipc_irq_subscribe(inr_t, sysarg_t, irq_code_t *);
     59extern sysarg_t sys_ipc_irq_unsubscribe(sysarg_t);
    6060
    6161#ifdef __32_BITS__
  • kernel/generic/include/proc/task.h

    rd076f16 r91b60499  
    6060#include <abi/sysinfo.h>
    6161#include <arch.h>
     62#include <cap/cap.h>
    6263
    6364#define TASK                 THE->task
     
    6566
    6667struct thread;
     68struct cap;
    6769
    6870/** Task structure. */
     
    9597        /** Task permissions. */
    9698        perm_t perms;
     99
     100        /** Capabilities */
     101        cap_info_t *cap_info;
    97102       
    98103        /* IPC stuff */
     
    100105        /** Receiving communication endpoint */
    101106        answerbox_t answerbox;
    102 
    103         /** Sending communication endpoints */
    104         phone_t phones[IPC_MAX_PHONES];
    105107
    106108        /** Spinlock protecting the active_calls list. */
  • kernel/generic/include/typedefs.h

    rd076f16 r91b60499  
    4949
    5050typedef int32_t inr_t;
    51 typedef int32_t devno_t;
    5251
    5352typedef volatile uint8_t ioport8_t;
Note: See TracChangeset for help on using the changeset viewer.