Changeset b3f8fb7 in mainline for kernel/generic/include


Ignore:
Timestamp:
2007-01-28T13:25:49Z (19 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8e8c1a5
Parents:
1ba41c5
Message:

huge type system cleanup
remove cyclical type dependencies across multiple header files
many minor coding style fixes

Location:
kernel/generic/include
Files:
1 added
50 edited

Legend:

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

    r1ba41c5 rb3f8fb7  
    3737
    3838#include <arch/types.h>
    39 #include <typedefs.h>
    4039
    4140#define BITS2BYTES(bits)        (bits ? ((((bits)-1)>>3)+1) : 0)
  • kernel/generic/include/adt/btree.h

    r1ba41c5 rb3f8fb7  
    3737
    3838#include <arch/types.h>
    39 #include <typedefs.h>
    4039#include <adt/list.h>
    4140
     
    4645
    4746/** B-tree node structure. */
    48 struct btree_node {
     47typedef struct btree_node {
    4948        /** Number of keys. */
    5049        count_t keys;
     
    6665         * There is room for storing a subtree pointer for the extra key.
    6766         */
    68         btree_node_t *subtree[BTREE_M + 1];
     67        struct btree_node *subtree[BTREE_M + 1];
    6968
    7069        /** Pointer to parent node. Root node has NULL parent. */
    71         btree_node_t *parent;
     70        struct btree_node *parent;
    7271
    7372        /** Link connecting leaf-level nodes. Defined only when this node is a leaf. */
     
    7776        link_t bfs_link;
    7877        int depth;
    79 };
     78} btree_node_t;
    8079
    8180/** B-tree structure. */
    82 struct btree {
     81typedef struct {
    8382        btree_node_t *root;     /**< B-tree root node pointer. */
    8483        link_t leaf_head;       /**< Leaf-level list head. */
    85 };
     84} btree_t;
    8685
    8786extern void btree_init(void);
  • kernel/generic/include/adt/fifo.h

    r1ba41c5 rb3f8fb7  
    4646#define KERN_FIFO_H_
    4747
    48 #include <typedefs.h>
    4948#include <mm/slab.h>
    5049
  • kernel/generic/include/adt/hash_table.h

    r1ba41c5 rb3f8fb7  
    3838#include <adt/list.h>
    3939#include <arch/types.h>
    40 #include <typedefs.h>
    41 
    42 /** Hash table structure. */
    43 struct hash_table {
    44         link_t *entry;
    45         count_t entries;
    46         count_t max_keys;
    47         hash_table_operations_t *op;
    48 };
    4940
    5041/** Set of operations for hash table. */
    51 struct hash_table_operations {
     42typedef struct {
    5243        /** Hash function.
    5344         *
     
    7162         */
    7263        void (*remove_callback)(link_t *item);
    73 };
     64} hash_table_operations_t;
     65
     66/** Hash table structure. */
     67typedef struct {
     68        link_t *entry;
     69        count_t entries;
     70        count_t max_keys;
     71        hash_table_operations_t *op;
     72} hash_table_t;
    7473
    7574#define hash_table_get_instance(item, type, member)     list_get_instance((item), type, member)
  • kernel/generic/include/adt/list.h

    r1ba41c5 rb3f8fb7  
    3737
    3838#include <arch/types.h>
    39 #include <typedefs.h>
    4039
    4140/** Doubly linked list head and link type. */
    42 struct link {
    43         link_t *prev;   /**< Pointer to the previous item in the list. */
    44         link_t *next;   /**< Pointer to the next item in the list. */
    45 };
     41typedef struct link {
     42        struct link *prev;      /**< Pointer to the previous item in the list. */
     43        struct link *next;      /**< Pointer to the next item in the list. */
     44} link_t;
    4645
    4746/** Declare and initialize statically allocated list.
  • kernel/generic/include/arch.h

    r1ba41c5 rb3f8fb7  
    3636#define KERN_ARCH_H_
    3737
    38 #include <arch/types.h>
    3938#include <arch/arch.h>
    40 #include <typedefs.h>
    41 
    42 #include <cpu.h>
    43 #include <arch/cpu.h>
    44 #include <arch/asm.h>
     39#include <proc/task.h>
    4540
    4641#define DEFAULT_CONTEXT         0
  • kernel/generic/include/bitops.h

    r1ba41c5 rb3f8fb7  
    3535#ifndef KERN_BITOPS_H_
    3636#define KERN_BITOPS_H_
    37 
    38 #include <typedefs.h>
    3937
    4038
  • kernel/generic/include/config.h

    r1ba41c5 rb3f8fb7  
    3737
    3838#include <arch/types.h>
    39 #include <typedefs.h>
    4039#include <arch/mm/page.h>
    4140
  • kernel/generic/include/console/chardev.h

    r1ba41c5 rb3f8fb7  
    3636#define KERN_CHARDEV_H_
    3737
    38 #include <typedefs.h>
    3938#include <arch/types.h>
    4039#include <synch/waitq.h>
     
    4342#define CHARDEV_BUFLEN 512
    4443
     44struct chardev;
     45
    4546/* Character device operations interface. */
    46 struct chardev_operations {
    47         void (* suspend)(chardev_t *);          /**< Suspend pushing characters. */
    48         void (* resume)(chardev_t *);           /**< Resume pushing characters. */
    49         void (* write)(chardev_t *, char c);    /**< Write character to stream. */
     47typedef struct {
     48        void (* suspend)(struct chardev *);             /**< Suspend pushing characters. */
     49        void (* resume)(struct chardev *);              /**< Resume pushing characters. */
     50        void (* write)(struct chardev *, char c);       /**< Write character to stream. */
    5051        /** Read character directly from device, assume interrupts disabled */
    51         char (* read)(chardev_t *);
    52 };
    53 
    54 typedef struct chardev_operations chardev_operations_t;
     52        char (* read)(struct chardev *);
     53} chardev_operations_t;
    5554
    5655/** Character input device. */
    57 struct chardev {
     56typedef struct chardev {
    5857        char *name;
    5958       
     
    6564        index_t index;
    6665        void *data;
    67 };
     66} chardev_t;
    6867
    6968extern void chardev_initialize(char *name,
  • kernel/generic/include/console/cmd.h

    r1ba41c5 rb3f8fb7  
    3636#define KERN_CMD_H_
    3737
    38 #include <typedefs.h>
     38#include <console/kconsole.h>
    3939
    4040extern void cmd_initialize(cmd_info_t *cmd);
  • kernel/generic/include/console/console.h

    r1ba41c5 rb3f8fb7  
    3737
    3838#include <arch/types.h>
    39 #include <typedefs.h>
     39#include <console/chardev.h>
    4040
    4141extern chardev_t *stdin;
  • kernel/generic/include/console/kconsole.h

    r1ba41c5 rb3f8fb7  
    3636#define KERN_KCONSOLE_H_
    3737
    38 #include <typedefs.h>
    3938#include <adt/list.h>
    4039#include <synch/spinlock.h>
     
    4342#define KCONSOLE_HISTORY 10
    4443
    45 enum cmd_arg_type {
     44typedef enum {
    4645        ARG_TYPE_INVALID = 0,
    4746        ARG_TYPE_INT,
    4847        ARG_TYPE_STRING,
    4948        ARG_TYPE_VAR      /**< Variable type - either symbol or string */
    50 };
     49} cmd_arg_type_t;
    5150
    5251/** Structure representing one argument of kconsole command line. */
    53 struct cmd_arg {
     52typedef struct {
    5453        cmd_arg_type_t type;            /**< Type descriptor. */
    5554        void *buffer;                   /**< Buffer where to store data. */
     
    5756        unative_t intval;                /**< Integer value */
    5857        cmd_arg_type_t vartype;         /**< Resulting type of variable arg */
    59 };
     58} cmd_arg_t;
    6059
    6160/** Structure representing one kconsole command. */
    62 struct cmd_info {
     61typedef struct {
    6362        link_t link;                    /**< Command list link. */
    6463        SPINLOCK_DECLARE(lock);         /**< This lock protects everything below. */
     
    6968        cmd_arg_t *argv;                /**< Argument vector. */
    7069        void (* help)(void);            /**< Function for printing detailed help. */
    71 };
     70} cmd_info_t;
    7271
    7372extern spinlock_t cmd_lock;
  • kernel/generic/include/context.h

    r1ba41c5 rb3f8fb7  
    3737
    3838#include <arch/types.h>
    39 #include <typedefs.h>
    4039#include <arch/context.h>
    4140
  • kernel/generic/include/cpu.h

    r1ba41c5 rb3f8fb7  
    3636#define KERN_CPU_H_
    3737
    38 #include <arch/cpu.h>
    39 #include <proc/scheduler.h>
    40 #include <synch/spinlock.h>
    41 #include <synch/waitq.h>
    42 #include <arch/types.h>
    43 #include <typedefs.h>
    44 #include <arch/context.h>
    45 #include <config.h>
    46 #include <adt/list.h>
    47 #include <mm/tlb.h>
     38#include <proc/thread.h>
    4839
    4940#define CPU_STACK_SIZE  STACK_SIZE
    50 
    51 /** CPU structure.
    52  *
    53  * There is one structure like this for every processor.
    54  */
    55 typedef struct {
    56         SPINLOCK_DECLARE(lock);
    57 
    58         tlb_shootdown_msg_t tlb_messages[TLB_MESSAGE_QUEUE_LEN];
    59         count_t tlb_messages_count;
    60        
    61         context_t saved_context;
    62 
    63         atomic_t nrdy;
    64         runq_t rq[RQ_COUNT];
    65         volatile count_t needs_relink;
    66 
    67         SPINLOCK_DECLARE(timeoutlock);
    68         link_t timeout_active_head;
    69 
    70         count_t missed_clock_ticks;     /**< When system clock loses a tick, it is recorded here
    71                                              so that clock() can react. This variable is
    72                                              CPU-local and can be only accessed when interrupts
    73                                              are disabled. */
    74 
    75         /**
    76          * Processor ID assigned by kernel.
    77          */
    78         int id;
    79        
    80         int active;
    81         int tlb_active;
    82 
    83         uint16_t frequency_mhz;
    84         uint32_t delay_loop_const;
    85 
    86         cpu_arch_t arch;
    87 
    88         thread_t *fpu_owner;
    89        
    90         /**
    91          * Stack used by scheduler when there is no running thread.
    92          */
    93         uint8_t *stack;
    94 } cpu_t;
    9541
    9642extern cpu_t *cpus;
  • kernel/generic/include/ddi/ddi.h

    r1ba41c5 rb3f8fb7  
    3838#include <ddi/ddi_arg.h>
    3939#include <arch/types.h>
    40 #include <typedefs.h>
     40#include <proc/task.h>
    4141
    4242/** Structure representing contiguous physical memory area. */
  • kernel/generic/include/ddi/device.h

    r1ba41c5 rb3f8fb7  
    3636#define KERN_DEVICE_H_
    3737
    38 #include <typedefs.h>
    39 
    4038extern devno_t device_assign_devno(void);
    4139
  • kernel/generic/include/ddi/irq.h

    r1ba41c5 rb3f8fb7  
    3636#define KERN_IRQ_H_
    3737
     38typedef enum {
     39        CMD_MEM_READ_1 = 0,
     40        CMD_MEM_READ_2,
     41        CMD_MEM_READ_4,
     42        CMD_MEM_READ_8,
     43        CMD_MEM_WRITE_1,
     44        CMD_MEM_WRITE_2,
     45        CMD_MEM_WRITE_4,
     46        CMD_MEM_WRITE_8,
     47        CMD_PORT_READ_1,
     48        CMD_PORT_WRITE_1,
     49        CMD_IA64_GETCHAR,
     50        CMD_PPC32_GETCHAR,
     51        CMD_LAST
     52} irq_cmd_type;
     53
     54typedef struct {
     55        irq_cmd_type cmd;
     56        void *addr;
     57        unsigned long long value;
     58        int dstarg;
     59} irq_cmd_t;
     60
     61typedef struct {
     62        unsigned int cmdcount;
     63        irq_cmd_t *cmds;
     64} irq_code_t;
     65
     66#ifdef KERNEL
     67
    3868#include <arch/types.h>
    39 #include <typedefs.h>
    4069#include <adt/list.h>
    41 #include <ipc/irq.h>
    4270#include <synch/spinlock.h>
     71#include <proc/task.h>
    4372
    4473typedef enum {
     
    5281} irq_trigger_t;
    5382
    54 typedef void (* irq_handler_t)(irq_t *irq, void *arg, ...);
     83struct irq;
     84typedef void (* irq_handler_t)(struct irq *irq, void *arg, ...);
     85
     86
     87
     88/** IPC notification config structure.
     89 *
     90 * Primarily, this structure is encapsulated in the irq_t structure.
     91 * It is protected by irq_t::lock.
     92 */
     93typedef struct {
     94        bool notify;                    /**< When false, notifications are not sent. */
     95        answerbox_t *answerbox;         /**< Answerbox for notifications. */
     96        unative_t method;               /**< Method to be used for the notification. */
     97        irq_code_t *code;               /**< Top-half pseudocode. */
     98        count_t counter;                /**< Counter. */
     99        link_t link;                    /**< Link between IRQs that are notifying the
     100                                             same answerbox. The list is protected by
     101                                             the answerbox irq_lock. */
     102} ipc_notif_cfg_t;
    55103
    56104/** Structure representing one device IRQ.
     
    60108 * devno.
    61109 */
    62 struct irq {
     110typedef struct irq {
    63111        /** Hash table link. */
    64112        link_t link;
     
    87135        /** Notification configuration structure. */
    88136        ipc_notif_cfg_t notif_cfg;
    89 };
     137} irq_t;
    90138
    91139extern void irq_init(count_t inrs, count_t chains);
     
    97145#endif
    98146
     147#endif
     148
    99149/** @}
    100150 */
  • kernel/generic/include/debug.h

    r1ba41c5 rb3f8fb7  
    4343#ifndef HERE
    4444/** Current Instruction Pointer address */
    45 #  define HERE ((uintptr_t *)0)
     45#  define HERE ((uintptr_t *) 0)
    4646#endif
    4747
  • kernel/generic/include/fpu_context.h

    r1ba41c5 rb3f8fb7  
    3737
    3838#include <arch/fpu_context.h>
    39 #include <typedefs.h>
    4039
    4140#if defined(CONFIG_FPU_LAZY) && !defined(ARCH_HAS_FPU)
  • kernel/generic/include/func.h

    r1ba41c5 rb3f8fb7  
    3737
    3838#include <arch/types.h>
    39 #include <typedefs.h>
    4039#include <atomic.h>
    4140
  • kernel/generic/include/interrupt.h

    r1ba41c5 rb3f8fb7  
    3737
    3838#include <arch/interrupt.h>
    39 #include <typedefs.h>
    4039#include <arch/types.h>
    4140#include <proc/task.h>
     
    4342#include <arch.h>
    4443#include <console/klog.h>
    45 #include <ipc/irq.h>
     44#include <ddi/irq.h>
     45
     46typedef void (* iroutine)(int n, istate_t *istate);
    4647
    4748#define fault_if_from_uspace(istate, cmd, ...) \
     
    5556}
    5657
    57 
    5858extern iroutine exc_register(int n, const char *name, iroutine f);
    5959extern void exc_dispatch(int n, istate_t *t);
  • kernel/generic/include/ipc/ipc.h

    r1ba41c5 rb3f8fb7  
    159159#ifdef KERNEL
    160160
    161 #include <synch/waitq.h>
    162 #include <adt/list.h>
    163 
    164 #define IPC_MAX_PHONES  16
    165 
    166 typedef struct answerbox_s answerbox_t;
    167 typedef struct phone_s phone_t;
     161#include <proc/task.h>
     162
    168163typedef struct {
    169164        unative_t args[IPC_CALL_LEN];
    170165        phone_t *phone;
    171166} ipc_data_t;
    172 
    173 struct answerbox_s {
    174         SPINLOCK_DECLARE(lock);
    175 
    176         task_t *task;
    177 
    178         waitq_t wq;
    179 
    180         link_t connected_phones;        /**< Phones connected to this answerbox */
    181         link_t calls;                   /**< Received calls */
    182         link_t dispatched_calls;        /* Should be hash table in the future */
    183 
    184         link_t answers;                 /**< Answered calls */
    185 
    186         SPINLOCK_DECLARE(irq_lock);
    187         link_t irq_notifs;              /**< Notifications from IRQ handlers */
    188         link_t irq_head;                /**< IRQs with notifications to this answerbox. */
    189 };
    190 
    191 typedef enum {
    192         IPC_PHONE_FREE = 0,     /**< Phone is free and can be allocated */
    193         IPC_PHONE_CONNECTING,   /**< Phone is connecting somewhere */
    194         IPC_PHONE_CONNECTED,    /**< Phone is connected */
    195         IPC_PHONE_HUNGUP,       /**< Phone is hung up, waiting for answers to come */
    196         IPC_PHONE_SLAMMED       /**< Phone was hungup from server */
    197 } ipc_phone_state_t;
    198 
    199 /** Structure identifying phone (in TASK structure) */
    200 struct phone_s {
    201         SPINLOCK_DECLARE(lock);
    202         link_t link;
    203         answerbox_t *callee;
    204         ipc_phone_state_t state;
    205         atomic_t active_calls;
    206 };
    207167
    208168typedef struct {
  • kernel/generic/include/ipc/irq.h

    r1ba41c5 rb3f8fb7  
    3939#define IRQ_MAX_PROG_SIZE 10
    4040
    41 typedef enum {
    42         CMD_MEM_READ_1 = 0,
    43         CMD_MEM_READ_2,
    44         CMD_MEM_READ_4,
    45         CMD_MEM_READ_8,
    46         CMD_MEM_WRITE_1,
    47         CMD_MEM_WRITE_2,
    48         CMD_MEM_WRITE_4,
    49         CMD_MEM_WRITE_8,
    50         CMD_PORT_READ_1,
    51         CMD_PORT_WRITE_1,
    52         CMD_IA64_GETCHAR,
    53         CMD_PPC32_GETCHAR,
    54         CMD_LAST
    55 } irq_cmd_type;
    56 
    57 typedef struct {
    58         irq_cmd_type cmd;
    59         void *addr;
    60         unsigned long long value;
    61         int dstarg;
    62 } irq_cmd_t;
    63 
    64 typedef struct {
    65         unsigned int cmdcount;
    66         irq_cmd_t *cmds;
    67 } irq_code_t;
    68 
    69 #ifdef KERNEL
    70 
    7141#include <ipc/ipc.h>
    72 #include <typedefs.h>
     42#include <ddi/irq.h>
    7343#include <arch/types.h>
    7444#include <adt/list.h>
    75 
    76 /** IPC notification config structure.
    77  *
    78  * Primarily, this structure is encapsulated in the irq_t structure.
    79  * It is protected by irq_t::lock.
    80  */
    81 struct ipc_notif_cfg {
    82         bool notify;                    /**< When false, notifications are not sent. */
    83         answerbox_t *answerbox;         /**< Answerbox for notifications. */
    84         unative_t method;               /**< Method to be used for the notification. */
    85         irq_code_t *code;               /**< Top-half pseudocode. */
    86         count_t counter;                /**< Counter. */
    87         link_t link;                    /**< Link between IRQs that are notifying the
    88                                              same answerbox. The list is protected by
    89                                              the answerbox irq_lock. */
    90 };
    9145
    9246extern int ipc_irq_register(answerbox_t *box, inr_t inr, devno_t devno, unative_t method,
     
    9953#endif
    10054
    101 #endif
    102 
    10355/** @}
    10456 */
  • kernel/generic/include/ipc/sysipc.h

    r1ba41c5 rb3f8fb7  
    3939#include <ipc/irq.h>
    4040#include <arch/types.h>
    41 #include <typedefs.h>
    4241
    4342unative_t sys_ipc_call_sync_fast(unative_t phoneid, unative_t method,
  • kernel/generic/include/lib/elf.h

    r1ba41c5 rb3f8fb7  
    3838#include <arch/elf.h>
    3939#include <arch/types.h>
    40 #include <typedefs.h>
    4140
    4241/**
     
    336335#endif
    337336
    338 extern int elf_load(elf_header_t *header, as_t * as);
    339337extern char *elf_error(int rc);
    340338
  • kernel/generic/include/lib/rd.h

    r1ba41c5 rb3f8fb7  
    3737
    3838#include <arch/types.h>
    39 #include <typedefs.h>
    4039
    4140/**
  • kernel/generic/include/macros.h

    r1ba41c5 rb3f8fb7  
    3737
    3838#include <arch/types.h>
    39 #include <typedefs.h>
    4039
    4140#define is_digit(d)     (((d) >= '0') && ((d) <= '9'))
  • kernel/generic/include/main/main.h

    r1ba41c5 rb3f8fb7  
    3636#define KERN_MAIN_H_
    3737
    38 #include <typedefs.h>
    39 
    4038extern uintptr_t stack_safe;
    4139
  • kernel/generic/include/memstr.h

    r1ba41c5 rb3f8fb7  
    3636#define KERN_MEMSTR_H_
    3737
    38 #include <typedefs.h>
    3938#include <arch/types.h>
    4039#include <arch/memstr.h>
  • kernel/generic/include/mm/as.h

    r1ba41c5 rb3f8fb7  
    4848#include <arch/mm/asid.h>
    4949#include <arch/types.h>
    50 #include <typedefs.h>
    5150#include <synch/spinlock.h>
    5251#include <synch/mutex.h>
     
    6766#define FLAG_AS_KERNEL      (1 << 0)    /**< Kernel address space. */
    6867
    69 /** Address space structure.
    70  *
    71  * as_t contains the list of as_areas of userspace accessible
    72  * pages for one or more tasks. Ranges of kernel memory pages are not
    73  * supposed to figure in the list as they are shared by all tasks and
    74  * set up during system initialization.
    75  */
    76 struct as {
    77         /** Protected by asidlock. */
    78         link_t inactive_as_with_asid_link;
    79 
    80         mutex_t lock;
    81 
    82         /** Number of references (i.e tasks that reference this as). */
    83         count_t refcount;
    84 
    85         /** Number of processors on wich is this address space active. */
    86         count_t cpu_refcount;
    87 
    88         /** B+tree of address space areas. */
    89         btree_t as_area_btree;
    90 
    91         /** Page table pointer. Constant on architectures that use global page hash table. */
    92         pte_t *page_table;
    93 
    94         /** Address space identifier. Constant on architectures that do not support ASIDs.*/
    95         asid_t asid;
    96        
    97         /** Architecture specific content. */
    98         as_arch_t arch;
    99 };
    100 
    101 struct as_operations {
     68/** Address space area attributes. */
     69#define AS_AREA_ATTR_NONE       0
     70#define AS_AREA_ATTR_PARTIAL    1       /**< Not fully initialized area. */
     71
     72#define AS_PF_FAULT             0       /**< The page fault was not resolved by as_page_fault(). */
     73#define AS_PF_OK                1       /**< The page fault was resolved by as_page_fault(). */
     74#define AS_PF_DEFER             2       /**< The page fault was caused by memcpy_from_uspace() or memcpy_to_uspace(). */
     75
     76typedef struct {
    10277        pte_t *(* page_table_create)(int flags);
    10378        void (* page_table_destroy)(pte_t *page_table);
    10479        void (* page_table_lock)(as_t *as, bool lock);
    10580        void (* page_table_unlock)(as_t *as, bool unlock);
    106 };
    107 typedef struct as_operations as_operations_t;
    108 
    109 /** Address space area attributes. */
    110 #define AS_AREA_ATTR_NONE       0
    111 #define AS_AREA_ATTR_PARTIAL    1       /**< Not fully initialized area. */
    112 
    113 #define AS_PF_FAULT             0       /**< The page fault was not resolved by as_page_fault(). */
    114 #define AS_PF_OK                1       /**< The page fault was resolved by as_page_fault(). */
    115 #define AS_PF_DEFER             2       /**< The page fault was caused by memcpy_from_uspace()
    116                                              or memcpy_to_uspace(). */
     81} as_operations_t;
    11782
    11883/** This structure contains information associated with the shared address space area. */
     
    12388} share_info_t;
    12489
    125 /** Address space area backend structure. */
    126 typedef struct {
    127         int (* page_fault)(as_area_t *area, uintptr_t addr, pf_access_t access);
    128         void (* frame_free)(as_area_t *area, uintptr_t page, uintptr_t frame);
    129         void (* share)(as_area_t *area);
    130 } mem_backend_t;
     90/** Page fault access type. */
     91typedef enum {
     92        PF_ACCESS_READ,
     93        PF_ACCESS_WRITE,
     94        PF_ACCESS_EXEC
     95} pf_access_t;
     96
     97struct mem_backend;
    13198
    13299/** Backend data stored in address space area. */
    133 typedef union {
     100typedef union mem_backend_data {
    134101        struct {        /**< elf_backend members */
    135102                elf_header_t *elf;
     
    147114 * In the future, it should not be difficult to support shared areas.
    148115 */
    149 struct as_area {
     116typedef struct {
    150117        mutex_t lock;
    151118        as_t *as;               /**< Containing address space. */
     
    157124        share_info_t *sh_info;  /**< If the address space area has been shared, this pointer will
    158125                                     reference the share info structure. */
    159         mem_backend_t *backend; /**< Memory backend backing this address space area. */
     126        struct mem_backend *backend;    /**< Memory backend backing this address space area. */
    160127
    161128        /** Data to be used by the backend. */
    162129        mem_backend_data_t backend_data;
    163 };
     130} as_area_t;
     131
     132/** Address space area backend structure. */
     133typedef struct mem_backend {
     134        int (* page_fault)(as_area_t *area, uintptr_t addr, pf_access_t access);
     135        void (* frame_free)(as_area_t *area, uintptr_t page, uintptr_t frame);
     136        void (* share)(as_area_t *area);
     137} mem_backend_t;
    164138
    165139extern as_t *AS_KERNEL;
     
    207181#endif /* !def as_deinstall_arch */
    208182
    209 /* Backend declarations. */
     183/* Backend declarations and functions. */
    210184extern mem_backend_t anon_backend;
    211185extern mem_backend_t elf_backend;
    212186extern mem_backend_t phys_backend;
     187
     188extern int elf_load(elf_header_t *header, as_t *as);
    213189
    214190/* Address space area related syscalls. */
  • kernel/generic/include/mm/asid.h

    r1ba41c5 rb3f8fb7  
    4545#include <arch/mm/asid.h>
    4646#include <synch/spinlock.h>
    47 #include <typedefs.h>
     47#include <adt/list.h>
     48#include <mm/as.h>
    4849
    4950#endif
  • kernel/generic/include/mm/buddy.h

    r1ba41c5 rb3f8fb7  
    3737
    3838#include <arch/types.h>
    39 #include <typedefs.h>
     39#include <adt/list.h>
    4040
    4141#define BUDDY_SYSTEM_INNER_BLOCK        0xff
  • kernel/generic/include/mm/frame.h

    r1ba41c5 rb3f8fb7  
    3838
    3939#include <arch/types.h>
    40 #include <typedefs.h>
    4140#include <adt/list.h>
    4241#include <synch/spinlock.h>
  • kernel/generic/include/mm/page.h

    r1ba41c5 rb3f8fb7  
    3636#define KERN_PAGE_H_
    3737
    38 #include <arch/mm/asid.h>
    3938#include <arch/types.h>
    40 #include <typedefs.h>
     39#include <mm/as.h>
    4140#include <memstr.h>
    42 
    43 #define PAGE_CACHEABLE_SHIFT            0
    44 #define PAGE_NOT_CACHEABLE_SHIFT        PAGE_CACHEABLE_SHIFT
    45 #define PAGE_PRESENT_SHIFT              1
    46 #define PAGE_NOT_PRESENT_SHIFT          PAGE_PRESENT_SHIFT
    47 #define PAGE_USER_SHIFT                 2
    48 #define PAGE_KERNEL_SHIFT               PAGE_USER_SHIFT
    49 #define PAGE_READ_SHIFT                 3
    50 #define PAGE_WRITE_SHIFT                4
    51 #define PAGE_EXEC_SHIFT                 5
    52 #define PAGE_GLOBAL_SHIFT               6
    53 
    54 #define PAGE_NOT_CACHEABLE      (0<<PAGE_CACHEABLE_SHIFT)
    55 #define PAGE_CACHEABLE          (1<<PAGE_CACHEABLE_SHIFT)
    56 
    57 #define PAGE_PRESENT            (0<<PAGE_PRESENT_SHIFT)
    58 #define PAGE_NOT_PRESENT        (1<<PAGE_PRESENT_SHIFT)
    59 
    60 #define PAGE_USER               (1<<PAGE_USER_SHIFT)
    61 #define PAGE_KERNEL             (0<<PAGE_USER_SHIFT)
    62 
    63 #define PAGE_READ               (1<<PAGE_READ_SHIFT)
    64 #define PAGE_WRITE              (1<<PAGE_WRITE_SHIFT)
    65 #define PAGE_EXEC               (1<<PAGE_EXEC_SHIFT)
    66 
    67 #define PAGE_GLOBAL             (1<<PAGE_GLOBAL_SHIFT)
    68 
    6941
    7042/**
     
    7345#define PAGE_COLOR(va)  (((va) >> PAGE_WIDTH) & ((1 << PAGE_COLOR_BITS) - 1))
    7446
    75 /** Page fault access type. */
    76 enum pf_access {
    77         PF_ACCESS_READ,
    78         PF_ACCESS_WRITE,
    79         PF_ACCESS_EXEC
    80 };
    81 typedef enum pf_access pf_access_t;
    82 
    8347/** Operations to manipulate page mappings. */
    84 struct page_mapping_operations {
    85         void (* mapping_insert)(as_t *as, uintptr_t page, uintptr_t frame, int
    86                 flags);
     48typedef struct {
     49        void (* mapping_insert)(as_t *as, uintptr_t page, uintptr_t frame,
     50                int flags);
    8751        void (* mapping_remove)(as_t *as, uintptr_t page);
    8852        pte_t *(* mapping_find)(as_t *as, uintptr_t page);
    89 };
    90 typedef struct page_mapping_operations page_mapping_operations_t;
     53} page_mapping_operations_t;
    9154
    9255extern page_mapping_operations_t *page_mapping_operations;
     
    9558extern void page_table_lock(as_t *as, bool lock);
    9659extern void page_table_unlock(as_t *as, bool unlock);
    97 extern void page_mapping_insert(as_t *as, uintptr_t page, uintptr_t frame, int
    98         flags);
     60extern void page_mapping_insert(as_t *as, uintptr_t page, uintptr_t frame,
     61        int flags);
    9962extern void page_mapping_remove(as_t *as, uintptr_t page);
    10063extern pte_t *page_mapping_find(as_t *as, uintptr_t page);
  • kernel/generic/include/mm/tlb.h

    r1ba41c5 rb3f8fb7  
    3838#include <arch/mm/asid.h>
    3939#include <arch/types.h>
    40 #include <typedefs.h>
    4140
    4241/**
     
    4746
    4847/** Type of TLB shootdown message. */
    49 enum tlb_invalidate_type {
     48typedef enum {
    5049        TLB_INVL_INVALID = 0,           /**< Invalid type. */
    5150        TLB_INVL_ALL,                   /**< Invalidate all entries in TLB. */
    5251        TLB_INVL_ASID,                  /**< Invalidate all entries belonging to one address space. */
    5352        TLB_INVL_PAGES                  /**< Invalidate specified page range belonging to one address space. */
    54 };
    55 typedef enum tlb_invalidate_type tlb_invalidate_type_t;
     53} tlb_invalidate_type_t;
    5654
    5755/** TLB shootdown message. */
    58 struct tlb_shootdown_msg {
     56typedef struct {
    5957        tlb_invalidate_type_t type;     /**< Message type. */
    6058        asid_t asid;                    /**< Address space identifier. */
    6159        uintptr_t page;                 /**< Page address. */
    6260        count_t count;                  /**< Number of pages to invalidate. */
    63 };
    64 typedef struct tlb_shootdown_msg tlb_shootdown_msg_t;
     61} tlb_shootdown_msg_t;
    6562
    6663extern void tlb_init(void);
  • kernel/generic/include/printf/printf_core.h

    r1ba41c5 rb3f8fb7  
    3636#define KERN_PRINTF_CORE_H_
    3737
    38 #include <typedefs.h>
     38#include <arch/types.h>
    3939#include <arch/arg.h>
    4040
  • kernel/generic/include/proc/scheduler.h

    r1ba41c5 rb3f8fb7  
    3838#include <synch/spinlock.h>
    3939#include <time/clock.h>         /* HZ */
    40 #include <typedefs.h>
    4140#include <atomic.h>
    4241#include <adt/list.h>
  • kernel/generic/include/proc/task.h

    r1ba41c5 rb3f8fb7  
    1 /*
     1/*3D
    22 * Copyright (c) 2001-2004 Jakub Jermar
    33 * All rights reserved.
     
    3636#define KERN_TASK_H_
    3737
    38 #include <typedefs.h>
    3938#include <synch/spinlock.h>
    4039#include <synch/mutex.h>
     40#include <synch/rwlock.h>
    4141#include <synch/futex.h>
    4242#include <adt/btree.h>
    4343#include <adt/list.h>
    44 #include <ipc/ipc.h>
    4544#include <security/cap.h>
    4645#include <arch/proc/task.h>
     46#include <arch/proc/thread.h>
     47#include <arch/context.h>
     48#include <arch/fpu_context.h>
     49#include <arch/cpu.h>
     50#include <mm/tlb.h>
     51#include <proc/scheduler.h>
     52
     53#define IPC_MAX_PHONES  16
     54#define THREAD_NAME_BUFLEN      20
     55
     56struct answerbox;
     57struct task;
     58struct thread;
     59
     60typedef enum {
     61        IPC_PHONE_FREE = 0,     /**< Phone is free and can be allocated */
     62        IPC_PHONE_CONNECTING,   /**< Phone is connecting somewhere */
     63        IPC_PHONE_CONNECTED,    /**< Phone is connected */
     64        IPC_PHONE_HUNGUP,       /**< Phone is hung up, waiting for answers to come */
     65        IPC_PHONE_SLAMMED       /**< Phone was hungup from server */
     66} ipc_phone_state_t;
     67
     68/** Structure identifying phone (in TASK structure) */
     69typedef struct {
     70        SPINLOCK_DECLARE(lock);
     71        link_t link;
     72        struct answerbox *callee;
     73        ipc_phone_state_t state;
     74        atomic_t active_calls;
     75} phone_t;
     76
     77typedef struct answerbox {
     78        SPINLOCK_DECLARE(lock);
     79
     80        struct task *task;
     81
     82        waitq_t wq;
     83
     84        link_t connected_phones;        /**< Phones connected to this answerbox */
     85        link_t calls;                   /**< Received calls */
     86        link_t dispatched_calls;        /* Should be hash table in the future */
     87
     88        link_t answers;                 /**< Answered calls */
     89
     90        SPINLOCK_DECLARE(irq_lock);
     91        link_t irq_notifs;              /**< Notifications from IRQ handlers */
     92        link_t irq_head;                /**< IRQs with notifications to this answerbox. */
     93} answerbox_t;
    4794
    4895/** Task structure. */
    49 struct task {
     96typedef struct task {
    5097        /** Task lock.
    5198         *
     
    55102       
    56103        char *name;
    57         thread_t *main_thread;  /**< Pointer to the main thread. */
     104        struct thread *main_thread;     /**< Pointer to the main thread. */
    58105        link_t th_head;         /**< List of threads contained in this task. */
    59106        as_t *as;               /**< Address space. */
     
    85132       
    86133        uint64_t cycles;        /**< Accumulated accounting. */
    87 };
     134} task_t;
     135
     136/** CPU structure.
     137 *
     138 * There is one structure like this for every processor.
     139 */
     140typedef struct {
     141        SPINLOCK_DECLARE(lock);
     142
     143        tlb_shootdown_msg_t tlb_messages[TLB_MESSAGE_QUEUE_LEN];
     144        count_t tlb_messages_count;
     145       
     146        context_t saved_context;
     147
     148        atomic_t nrdy;
     149        runq_t rq[RQ_COUNT];
     150        volatile count_t needs_relink;
     151
     152        SPINLOCK_DECLARE(timeoutlock);
     153        link_t timeout_active_head;
     154
     155        count_t missed_clock_ticks;     /**< When system clock loses a tick, it is recorded here
     156                                             so that clock() can react. This variable is
     157                                             CPU-local and can be only accessed when interrupts
     158                                             are disabled. */
     159
     160        /**
     161         * Processor ID assigned by kernel.
     162         */
     163        int id;
     164       
     165        int active;
     166        int tlb_active;
     167
     168        uint16_t frequency_mhz;
     169        uint32_t delay_loop_const;
     170
     171        cpu_arch_t arch;
     172
     173        struct thread *fpu_owner;
     174       
     175        /**
     176         * Stack used by scheduler when there is no running thread.
     177         */
     178        uint8_t *stack;
     179} cpu_t;
     180
     181typedef void (* timeout_handler_t)(void *arg);
     182
     183typedef struct {
     184        SPINLOCK_DECLARE(lock);
     185
     186        link_t link;                    /**< Link to the list of active timeouts on THE->cpu */
     187       
     188        uint64_t ticks;                 /**< Timeout will be activated in this amount of clock() ticks. */
     189
     190        timeout_handler_t handler;      /**< Function that will be called on timeout activation. */
     191        void *arg;                      /**< Argument to be passed to handler() function. */
     192       
     193        cpu_t *cpu;                     /**< On which processor is this timeout registered. */
     194} timeout_t;
     195
     196/** Thread states. */
     197typedef enum {
     198        Invalid,        /**< It is an error, if thread is found in this state. */
     199        Running,        /**< State of a thread that is currently executing on some CPU. */
     200        Sleeping,       /**< Thread in this state is waiting for an event. */
     201        Ready,          /**< State of threads in a run queue. */
     202        Entering,       /**< Threads are in this state before they are first readied. */
     203        Exiting,        /**< After a thread calls thread_exit(), it is put into Exiting state. */
     204        Undead          /**< Threads that were not detached but exited are in the Undead state. */
     205} state_t;
     206
     207/** Join types. */
     208typedef enum {
     209        None,
     210        TaskClnp,       /**< The thread will be joined by ktaskclnp thread. */
     211        TaskGC          /**< The thread will be joined by ktaskgc thread. */
     212} thread_join_type_t;
     213
     214/** Thread structure. There is one per thread. */
     215typedef struct thread {
     216        link_t rq_link;                         /**< Run queue link. */
     217        link_t wq_link;                         /**< Wait queue link. */
     218        link_t th_link;                         /**< Links to threads within containing task. */
     219       
     220        /** Lock protecting thread structure.
     221         *
     222         * Protects the whole thread structure except list links above.
     223         */
     224        SPINLOCK_DECLARE(lock);
     225
     226        char name[THREAD_NAME_BUFLEN];
     227
     228        void (* thread_code)(void *);           /**< Function implementing the thread. */
     229        void *thread_arg;                       /**< Argument passed to thread_code() function. */
     230
     231        /** From here, the stored context is restored when the thread is scheduled. */
     232        context_t saved_context;
     233        /** From here, the stored timeout context is restored when sleep times out. */
     234        context_t sleep_timeout_context;
     235        /** From here, the stored interruption context is restored when sleep is interrupted. */
     236        context_t sleep_interruption_context;
     237
     238        bool sleep_interruptible;               /**< If true, the thread can be interrupted from sleep. */
     239        waitq_t *sleep_queue;                   /**< Wait queue in which this thread sleeps. */
     240        timeout_t sleep_timeout;                /**< Timeout used for timeoutable sleeping.  */
     241        volatile int timeout_pending;           /**< Flag signalling sleep timeout in progress. */
     242
     243        /** True if this thread is executing copy_from_uspace(). False otherwise. */
     244        bool in_copy_from_uspace;
     245        /** True if this thread is executing copy_to_uspace(). False otherwise. */
     246        bool in_copy_to_uspace;
     247       
     248        /**
     249         * If true, the thread will not go to sleep at all and will
     250         * call thread_exit() before returning to userspace.
     251         */
     252        bool interrupted;                       
     253       
     254        thread_join_type_t      join_type;      /**< Who joinins the thread. */
     255        bool detached;                          /**< If true, thread_join_timeout() cannot be used on this thread. */
     256        waitq_t join_wq;                        /**< Waitq for thread_join_timeout(). */
     257
     258        fpu_context_t *saved_fpu_context;
     259        int fpu_context_exists;
     260
     261        /*
     262         * Defined only if thread doesn't run.
     263         * It means that fpu context is in CPU that last time executes this thread.
     264         * This disables migration.
     265         */
     266        int fpu_context_engaged;
     267
     268        rwlock_type_t rwlock_holder_type;
     269
     270        void (* call_me)(void *);               /**< Funtion to be called in scheduler before the thread is put asleep. */
     271        void *call_me_with;                     /**< Argument passed to call_me(). */
     272
     273        state_t state;                          /**< Thread's state. */
     274        int flags;                              /**< Thread's flags. */
     275       
     276        cpu_t *cpu;                             /**< Thread's CPU. */
     277        task_t *task;                           /**< Containing task. */
     278
     279        uint64_t ticks;                         /**< Ticks before preemption. */
     280       
     281        uint64_t cycles;                        /**< Thread accounting. */
     282        uint64_t last_cycle;            /**< Last sampled cycle. */
     283        bool uncounted;                         /**< Thread doesn't affect accumulated accounting. */
     284
     285        int priority;                           /**< Thread's priority. Implemented as index to CPU->rq */
     286        uint32_t tid;                           /**< Thread ID. */
     287       
     288        thread_arch_t arch;                     /**< Architecture-specific data. */
     289
     290        uint8_t *kstack;                        /**< Thread's kernel stack. */
     291} thread_t;
    88292
    89293extern spinlock_t tasks_lock;
     
    98302extern uint64_t task_get_accounting(task_t *t);
    99303
     304extern void cap_set(task_t *t, cap_t caps);
     305extern cap_t cap_get(task_t *t);
     306
    100307
    101308#ifndef task_create_arch
  • kernel/generic/include/proc/thread.h

    r1ba41c5 rb3f8fb7  
    3636#define KERN_THREAD_H_
    3737
    38 #include <arch/proc/thread.h>
    39 #include <synch/spinlock.h>
    40 #include <arch/context.h>
    41 #include <fpu_context.h>
    42 #include <arch/types.h>
    43 #include <typedefs.h>
    44 #include <time/timeout.h>
     38#include <synch/waitq.h>
     39#include <proc/task.h>
     40#include <cpu.h>
    4541#include <synch/rwlock.h>
    46 #include <synch/synch.h>
    47 #include <config.h>
    4842#include <adt/btree.h>
    49 #include <adt/list.h>
    5043#include <mm/slab.h>
     44#include <arch/cpu.h>
     45#include <mm/tlb.h>
    5146#include <proc/uarg.h>
    5247
    5348#define THREAD_STACK_SIZE       STACK_SIZE
    5449
    55 /** Thread states. */
    56 typedef enum {
    57         Invalid,        /**< It is an error, if thread is found in this state. */
    58         Running,        /**< State of a thread that is currently executing on some CPU. */
    59         Sleeping,       /**< Thread in this state is waiting for an event. */
    60         Ready,          /**< State of threads in a run queue. */
    61         Entering,       /**< Threads are in this state before they are first readied. */
    62         Exiting,        /**< After a thread calls thread_exit(), it is put into Exiting state. */
    63         Undead          /**< Threads that were not detached but exited are in the Undead state. */
    64 } state_t;
    65 
    6650extern char *thread_states[];
    6751
    68 /** Join types. */
    69 typedef enum {
    70         None,
    71         TaskClnp,       /**< The thread will be joined by ktaskclnp thread. */
    72         TaskGC          /**< The thread will be joined by ktaskgc thread. */
    73 } thread_join_type_t;
    74 
    7552/* Thread flags */
    76 #define THREAD_FLAG_WIRED       (1<<0)  /**< Thread cannot be migrated to another CPU. */
    77 #define THREAD_FLAG_STOLEN      (1<<1)  /**< Thread was migrated to another CPU and has not run yet. */
    78 #define THREAD_FLAG_USPACE      (1<<2)  /**< Thread executes in userspace. */
    79 
    80 #define THREAD_NAME_BUFLEN      20
    81 
    82 /** Thread structure. There is one per thread. */
    83 struct thread {
    84         link_t rq_link;                         /**< Run queue link. */
    85         link_t wq_link;                         /**< Wait queue link. */
    86         link_t th_link;                         /**< Links to threads within containing task. */
    87        
    88         /** Lock protecting thread structure.
    89          *
    90          * Protects the whole thread structure except list links above.
    91          */
    92         SPINLOCK_DECLARE(lock);
    93 
    94         char name[THREAD_NAME_BUFLEN];
    95 
    96         void (* thread_code)(void *);           /**< Function implementing the thread. */
    97         void *thread_arg;                       /**< Argument passed to thread_code() function. */
    98 
    99         /** From here, the stored context is restored when the thread is scheduled. */
    100         context_t saved_context;
    101         /** From here, the stored timeout context is restored when sleep times out. */
    102         context_t sleep_timeout_context;
    103         /** From here, the stored interruption context is restored when sleep is interrupted. */
    104         context_t sleep_interruption_context;
    105 
    106         bool sleep_interruptible;               /**< If true, the thread can be interrupted from sleep. */
    107         waitq_t *sleep_queue;                   /**< Wait queue in which this thread sleeps. */
    108         timeout_t sleep_timeout;                /**< Timeout used for timeoutable sleeping.  */
    109         volatile int timeout_pending;           /**< Flag signalling sleep timeout in progress. */
    110 
    111         /** True if this thread is executing copy_from_uspace(). False otherwise. */
    112         bool in_copy_from_uspace;
    113         /** True if this thread is executing copy_to_uspace(). False otherwise. */
    114         bool in_copy_to_uspace;
    115        
    116         /**
    117          * If true, the thread will not go to sleep at all and will
    118          * call thread_exit() before returning to userspace.
    119          */
    120         bool interrupted;                       
    121        
    122         thread_join_type_t      join_type;      /**< Who joinins the thread. */
    123         bool detached;                          /**< If true, thread_join_timeout() cannot be used on this thread. */
    124         waitq_t join_wq;                        /**< Waitq for thread_join_timeout(). */
    125 
    126         fpu_context_t *saved_fpu_context;
    127         int fpu_context_exists;
    128 
    129         /*
    130          * Defined only if thread doesn't run.
    131          * It means that fpu context is in CPU that last time executes this thread.
    132          * This disables migration.
    133          */
    134         int fpu_context_engaged;
    135 
    136         rwlock_type_t rwlock_holder_type;
    137 
    138         void (* call_me)(void *);               /**< Funtion to be called in scheduler before the thread is put asleep. */
    139         void *call_me_with;                     /**< Argument passed to call_me(). */
    140 
    141         state_t state;                          /**< Thread's state. */
    142         int flags;                              /**< Thread's flags. */
    143        
    144         cpu_t *cpu;                             /**< Thread's CPU. */
    145         task_t *task;                           /**< Containing task. */
    146 
    147         uint64_t ticks;                         /**< Ticks before preemption. */
    148        
    149         uint64_t cycles;                        /**< Thread accounting. */
    150         uint64_t last_cycle;            /**< Last sampled cycle. */
    151         bool uncounted;                         /**< Thread doesn't affect accumulated accounting. */
    152 
    153         int priority;                           /**< Thread's priority. Implemented as index to CPU->rq */
    154         uint32_t tid;                           /**< Thread ID. */
    155        
    156         thread_arch_t arch;                     /**< Architecture-specific data. */
    157 
    158         uint8_t *kstack;                        /**< Thread's kernel stack. */
    159 };
     53#define THREAD_FLAG_WIRED       (1 << 0)        /**< Thread cannot be migrated to another CPU. */
     54#define THREAD_FLAG_STOLEN      (1 << 1)        /**< Thread was migrated to another CPU and has not run yet. */
     55#define THREAD_FLAG_USPACE      (1 << 2)        /**< Thread executes in userspace. */
    16056
    16157/** Thread list lock.
     
    19692extern void thread_update_accounting(void);
    19793extern bool thread_exists(thread_t *t);
     94extern void thread_interrupt_sleep(thread_t *t);
    19895
    19996/* Fpu context slab cache */
  • kernel/generic/include/security/cap.h

    r1ba41c5 rb3f8fb7  
    5050#include <syscall/sysarg64.h>
    5151#include <arch/types.h>
    52 #include <typedefs.h>
    5352
    5453/**
     
    8281typedef uint32_t cap_t;
    8382
    84 extern void cap_set(task_t *t, cap_t caps);
    85 extern cap_t cap_get(task_t *t);
    86 
    8783extern unative_t sys_cap_grant(sysarg64_t *uspace_taskid_arg, cap_t caps);
    8884extern unative_t sys_cap_revoke(sysarg64_t *uspace_taskid_arg, cap_t caps);
  • kernel/generic/include/synch/futex.h

    r1ba41c5 rb3f8fb7  
    3737
    3838#include <arch/types.h>
    39 #include <typedefs.h>
    4039#include <synch/waitq.h>
    4140#include <genarch/mm/page_ht.h>
  • kernel/generic/include/synch/mutex.h

    r1ba41c5 rb3f8fb7  
    3737
    3838#include <arch/types.h>
    39 #include <typedefs.h>
    4039#include <synch/semaphore.h>
    4140#include <synch/synch.h>
  • kernel/generic/include/synch/rwlock.h

    r1ba41c5 rb3f8fb7  
    3737
    3838#include <arch/types.h>
    39 #include <typedefs.h>
    4039#include <synch/mutex.h>
    4140#include <synch/synch.h>
  • kernel/generic/include/synch/semaphore.h

    r1ba41c5 rb3f8fb7  
    3737
    3838#include <arch/types.h>
    39 #include <typedefs.h>
    4039#include <synch/waitq.h>
    4140#include <synch/synch.h>
     
    4645
    4746#define semaphore_down(s) \
    48         _semaphore_down_timeout((s),SYNCH_NO_TIMEOUT,SYNCH_FLAGS_NONE)
     47        _semaphore_down_timeout((s), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE)
    4948#define semaphore_trydown(s) \
    50         _semaphore_down_timeout((s),SYNCH_NO_TIMEOUT,SYNCH_FLAGS_NON_BLOCKING) 
    51 #define semaphore_down_timeout(s,usec) \
    52         _semaphore_down_timeout((s),(usec),SYNCH_FLAGS_NONE)
     49        _semaphore_down_timeout((s), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NON_BLOCKING)       
     50#define semaphore_down_timeout(s, usec) \
     51        _semaphore_down_timeout((s), (usec), SYNCH_FLAGS_NONE)
    5352
    5453extern void semaphore_initialize(semaphore_t *s, int val);
  • kernel/generic/include/synch/spinlock.h

    r1ba41c5 rb3f8fb7  
    3737
    3838#include <arch/types.h>
    39 #include <typedefs.h>
    4039#include <preemption.h>
    4140#include <atomic.h>
     
    9897        CS_LEAVE_BARRIER();
    9998       
    100         atomic_set(&sl->val,0);
     99        atomic_set(&sl->val, 0);
    101100        preemption_enable();
    102101}
     
    110109#define SPINLOCK_INITIALIZE(name)
    111110
    112 #define spinlock_initialize(x,name)
     111#define spinlock_initialize(x, name)
    113112#define spinlock_lock(x)                preemption_disable()
    114113#define spinlock_trylock(x)             (preemption_disable(), 1)
  • kernel/generic/include/synch/waitq.h

    r1ba41c5 rb3f8fb7  
    3737
    3838#include <arch/types.h>
    39 #include <typedefs.h>
    4039#include <synch/spinlock.h>
    4140#include <synch/synch.h>
     
    5958
    6059#define waitq_sleep(wq) \
    61         waitq_sleep_timeout((wq),SYNCH_NO_TIMEOUT,SYNCH_FLAGS_NONE)
     60        waitq_sleep_timeout((wq), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE)
    6261
    6362extern void waitq_initialize(waitq_t *wq);
     
    6867extern void waitq_wakeup(waitq_t *wq, bool all);
    6968extern void _waitq_wakeup_unsafe(waitq_t *wq, bool all);
    70 extern void waitq_interrupt_sleep(thread_t *t);
    7169
    7270#endif
  • kernel/generic/include/syscall/copy.h

    r1ba41c5 rb3f8fb7  
    3636#define KERN_COPY_H_
    3737
    38 #include <typedefs.h>
     38#include <arch/types.h>
    3939
    4040/** Label within memcpy_from_uspace() that contains return -1. */
  • kernel/generic/include/syscall/syscall.h

    r1ba41c5 rb3f8fb7  
    7272
    7373#include <arch/types.h>
    74 #include <typedefs.h>
    7574
    7675typedef unative_t (*syshandler_t)();
  • kernel/generic/include/time/timeout.h

    r1ba41c5 rb3f8fb7  
    3737
    3838#include <arch/types.h>
    39 #include <cpu.h>
    40 #include <synch/spinlock.h>
    41 #include <adt/list.h>
     39#include <proc/task.h>
    4240
    43 #define us2ticks(us)    ((uint64_t)(((uint32_t) (us)/(1000000/HZ))))
    44 
    45 typedef void (* timeout_handler_t)(void *arg);
    46 
    47 typedef struct {
    48         SPINLOCK_DECLARE(lock);
    49 
    50         link_t link;                    /**< Link to the list of active timeouts on THE->cpu */
    51        
    52         uint64_t ticks;                 /**< Timeout will be activated in this amount of clock() ticks. */
    53 
    54         timeout_handler_t handler;      /**< Function that will be called on timeout activation. */
    55         void *arg;                      /**< Argument to be passed to handler() function. */
    56        
    57         cpu_t *cpu;                     /**< On which processor is this timeout registered. */
    58 } timeout_t;
     41#define us2ticks(us)    ((uint64_t) (((uint32_t) (us) / (1000000 / HZ))))
    5942
    6043extern void timeout_init(void);
  • kernel/generic/include/typedefs.h

    r1ba41c5 rb3f8fb7  
    3636#define KERN_TYPEDEFS_H_
    3737
    38 #define false 0
    39 #define true 1
    40 
    41 typedef short bool;
    42 
    43 typedef unsigned long size_t;
    44 typedef unsigned long count_t;
    45 typedef unsigned long index_t;
    46 
    47 typedef unsigned long long task_id_t;
    48 typedef unsigned long context_id_t;
    49 
    50 typedef struct task task_t;
    51 typedef struct thread thread_t;
    52 
    53 typedef struct as_area as_area_t;
    54 typedef struct as as_t;
    55 
    56 typedef struct link link_t;
    57 
    58 typedef struct chardev chardev_t;
    59 
    60 typedef enum cmd_arg_type cmd_arg_type_t;
    61 typedef struct cmd_arg cmd_arg_t;
    62 typedef struct cmd_info cmd_info_t;
    63 
    64 typedef struct istate istate_t;
    6538typedef void (* function)();
    66 typedef void (* iroutine)(int n, istate_t *istate);
    67 
    68 typedef struct hash_table hash_table_t;
    69 typedef struct hash_table_operations hash_table_operations_t;
    70 
    71 typedef struct btree_node btree_node_t;
    72 typedef struct btree btree_t;
    73 
    74 typedef signed int inr_t;
    75 typedef signed int devno_t;
    76 typedef struct irq irq_t;
    77 typedef struct ipc_notif_cfg ipc_notif_cfg_t;
    7839
    7940#endif
Note: See TracChangeset for help on using the changeset viewer.