Changeset da1bafb in mainline for kernel/generic/include


Ignore:
Timestamp:
2010-05-24T18:57:31Z (15 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0095368
Parents:
666f492
Message:

major code revision

  • replace spinlocks taken with interrupts disabled with irq_spinlocks
  • change spacing (not indendation) to be tab-size independent
  • use unsigned integer types where appropriate (especially bit flags)
  • visual separation
  • remove argument names in function prototypes
  • string changes
  • correct some formating directives
  • replace various cryptic single-character variables (t, a, m, c, b, etc.) with proper identifiers (thread, task, timeout, as, itm, itc, etc.)
  • unify some assembler constructs
  • unused page table levels are now optimized out in compile time
  • replace several ints (with boolean semantics) with bools
  • use specifically sized types instead of generic types where appropriate (size_t, uint32_t, btree_key_t)
  • improve comments
  • split asserts with conjuction into multiple independent asserts
Location:
kernel/generic/include
Files:
25 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/console/chardev.h

    r666f492 rda1bafb  
    5757       
    5858        /** Protects everything below. */
    59         SPINLOCK_DECLARE(lock);
     59        IRQ_SPINLOCK_DECLARE(lock);
    6060        wchar_t buffer[INDEV_BUFLEN];
    6161        size_t counter;
     
    9595} outdev_t;
    9696
    97 extern void indev_initialize(const char *name, indev_t *indev,
    98     indev_operations_t *op);
    99 extern void indev_push_character(indev_t *indev, wchar_t ch);
    100 extern wchar_t indev_pop_character(indev_t *indev);
     97extern void indev_initialize(const char *, indev_t *,
     98    indev_operations_t *);
     99extern void indev_push_character(indev_t *, wchar_t);
     100extern wchar_t indev_pop_character(indev_t *);
    101101
    102 extern void outdev_initialize(const char *name, outdev_t *outdev,
    103     outdev_operations_t *op);
     102extern void outdev_initialize(const char *, outdev_t *,
     103    outdev_operations_t *);
    104104
    105 extern bool check_poll(indev_t *indev);
     105extern bool check_poll(indev_t *);
    106106
    107107#endif /* KERN_CHARDEV_H_ */
  • kernel/generic/include/cpu.h

    r666f492 rda1bafb  
    4242#include <arch/context.h>
    4343
    44 #define CPU_STACK_SIZE  STACK_SIZE
     44#define CPU_STACK_SIZE  STACK_SIZE
    4545
    4646/** CPU structure.
     
    4949 */
    5050typedef struct cpu {
    51         SPINLOCK_DECLARE(lock);
    52 
     51        IRQ_SPINLOCK_DECLARE(lock);
     52       
    5353        tlb_shootdown_msg_t tlb_messages[TLB_MESSAGE_QUEUE_LEN];
    5454        size_t tlb_messages_count;
    5555       
    5656        context_t saved_context;
    57 
     57       
    5858        atomic_t nrdy;
    5959        runq_t rq[RQ_COUNT];
    6060        volatile size_t needs_relink;
    61 
    62         SPINLOCK_DECLARE(timeoutlock);
     61       
     62        IRQ_SPINLOCK_DECLARE(timeoutlock);
    6363        link_t timeout_active_head;
    64 
    65         size_t missed_clock_ticks;      /**< When system clock loses a tick, it is recorded here
    66                                              so that clock() can react. This variable is
    67                                              CPU-local and can be only accessed when interrupts
    68                                              are disabled. */
    69 
     64       
     65        /**
     66         * When system clock loses a tick, it is
     67         * recorded here so that clock() can react.
     68         * This variable is CPU-local and can be
     69         * only accessed when interrupts are
     70         * disabled.
     71         */
     72        size_t missed_clock_ticks;
     73       
    7074        bool idle;
    7175        uint64_t idle_ticks;
    7276        uint64_t busy_ticks;
    73 
     77       
    7478        /**
    7579         * Processor ID assigned by kernel.
    7680         */
    77         unsigned int id;
     81        size_t id;
    7882       
    7983        bool active;
    80         int tlb_active;
    81 
     84        bool tlb_active;
     85       
    8286        uint16_t frequency_mhz;
    8387        uint32_t delay_loop_const;
    84 
     88       
    8589        cpu_arch_t arch;
    86 
     90       
    8791        struct thread *fpu_owner;
    8892       
     
    100104extern void cpu_arch_init(void);
    101105extern void cpu_identify(void);
    102 extern void cpu_print_report(cpu_t *m);
     106extern void cpu_print_report(cpu_t *);
    103107
    104108#endif
  • kernel/generic/include/ddi/ddi.h

    r666f492 rda1bafb  
    5050
    5151extern void ddi_init(void);
    52 extern void ddi_parea_register(parea_t *parea);
     52extern void ddi_parea_register(parea_t *);
    5353
    54 extern unative_t sys_physmem_map(unative_t phys_base, unative_t virt_base,
    55         unative_t pages, unative_t flags);
    56 extern unative_t sys_iospace_enable(ddi_ioarg_t *uspace_io_arg);
    57 extern unative_t sys_preempt_control(int enable);
     54extern unative_t sys_physmem_map(unative_t, unative_t, unative_t, unative_t);
     55extern unative_t sys_iospace_enable(ddi_ioarg_t *);
     56extern unative_t sys_preempt_control(int);
    5857
    5958/*
    6059 * Interface to be implemented by all architectures.
    6160 */
    62 extern int ddi_iospace_enable_arch(task_t *task, uintptr_t ioaddr, size_t size);
     61extern int ddi_iospace_enable_arch(task_t *, uintptr_t, size_t);
    6362
    6463#endif
  • kernel/generic/include/ddi/ddi_arg.h

    r666f492 rda1bafb  
    3636#define KERN_DDI_ARG_H_
    3737
     38#ifdef KERNEL
     39
     40#include <typedefs.h>
     41
     42#endif /* KERNEL */
     43
    3844/** Structure encapsulating arguments for SYS_PHYSMEM_MAP syscall. */
    3945typedef struct {
    4046        /** ID of the destination task. */
    41         unsigned long long task_id;
     47        uint64_t task_id;
    4248        /** Physical address of starting frame. */
    4349        void *phys_base;
     
    4551        void *virt_base;
    4652        /** Number of pages to map. */
    47         unsigned long pages;
     53        size_t pages;
    4854        /** Address space area flags for the mapping. */
    49         int flags;
     55        unsigned int flags;
    5056} ddi_memarg_t;
    5157
    5258/** Structure encapsulating arguments for SYS_ENABLE_IOSPACE syscall. */
    5359typedef struct {
    54         unsigned long long task_id;     /**< ID of the destination task. */
    55         void *ioaddr;                   /**< Starting I/O space address. */
    56         unsigned long size;             /**< Number of bytes. */
     60        uint64_t task_id;  /**< ID of the destination task. */
     61        void *ioaddr;      /**< Starting I/O space address. */
     62        size_t size;       /**< Number of bytes. */
    5763} ddi_ioarg_t;
    5864
  • kernel/generic/include/ddi/irq.h

    r666f492 rda1bafb  
    3535#ifndef KERN_IRQ_H_
    3636#define KERN_IRQ_H_
     37
     38#ifdef KERNEL
     39
     40#include <typedefs.h>
     41#include <adt/list.h>
     42#include <adt/hash_table.h>
     43#include <synch/spinlock.h>
     44#include <proc/task.h>
     45#include <ipc/ipc.h>
     46
     47#endif /* KERNEL */
    3748
    3849typedef enum {
     
    4960        /** Write 4 bytes to the I/O space. */
    5061        CMD_PIO_WRITE_32,
     62       
    5163        /**
    5264         * Perform a bit test on the source argument and store the result into
     
    5466         */
    5567        CMD_BTEST,
     68       
    5669        /**
    5770         * Predicate the execution of the following N commands by the boolean
     
    5972         */
    6073        CMD_PREDICATE,
     74       
    6175        /** Accept the interrupt. */
    6276        CMD_ACCEPT,
     
    6983        irq_cmd_type cmd;
    7084        void *addr;
    71         unsigned long long value;
    72         unsigned int srcarg;
    73         unsigned int dstarg;
     85        uint32_t value;
     86        uintptr_t srcarg;
     87        uintptr_t dstarg;
    7488} irq_cmd_t;
    7589
    7690typedef struct {
    77         unsigned int cmdcount;
     91        size_t cmdcount;
    7892        irq_cmd_t *cmds;
    7993} irq_code_t;
     
    8195#ifdef KERNEL
    8296
    83 #include <typedefs.h>
    84 #include <adt/list.h>
    85 #include <adt/hash_table.h>
    86 #include <synch/spinlock.h>
    87 #include <proc/task.h>
    88 #include <ipc/ipc.h>
    89 
    9097typedef enum {
    91         IRQ_DECLINE,            /**< Decline to service. */
    92         IRQ_ACCEPT              /**< Accept to service. */
     98        IRQ_DECLINE,  /**< Decline to service. */
     99        IRQ_ACCEPT    /**< Accept to service. */
    93100} irq_ownership_t;
    94101
     
    108115 * Primarily, this structure is encapsulated in the irq_t structure.
    109116 * It is protected by irq_t::lock.
     117 *
    110118 */
    111119typedef struct {
     
    117125        unative_t method;
    118126        /** Arguments that will be sent if the IRQ is claimed. */
    119         unative_t scratch[IPC_CALL_LEN];
     127        uint32_t scratch[IPC_CALL_LEN];
    120128        /** Top-half pseudocode. */
    121129        irq_code_t *code;
    122130        /** Counter. */
    123131        size_t counter;
     132       
    124133        /**
    125134         * Link between IRQs that are notifying the same answerbox. The list is
     
    133142 * If one device has multiple interrupts, there will be multiple irq_t
    134143 * instantions with the same devno.
     144 *
    135145 */
    136146typedef struct irq {
    137147        /** Hash table link. */
    138148        link_t link;
    139 
     149       
    140150        /** Lock protecting everything in this structure
    141151         *  except the link member. When both the IRQ
     
    143153         *  this lock must not be taken first.
    144154         */
    145         SPINLOCK_DECLARE(lock);
     155        IRQ_SPINLOCK_DECLARE(lock);
    146156       
    147157        /** Send EOI before processing the interrupt.
     
    152162         */
    153163        bool preack;
    154 
     164       
    155165        /** Unique device number. -1 if not yet assigned. */
    156166        devno_t devno;
    157 
     167       
    158168        /** Actual IRQ number. -1 if not yet assigned. */
    159169        inr_t inr;
     
    166176        /** Instance argument for the handler and the claim function. */
    167177        void *instance;
    168 
     178       
    169179        /** Clear interrupt routine. */
    170180        cir_t cir;
    171181        /** First argument to the clear interrupt routine. */
    172182        void *cir_arg;
    173 
     183       
    174184        /** Notification configuration structure. */
    175185        ipc_notif_cfg_t notif_cfg;
    176186} irq_t;
    177187
    178 SPINLOCK_EXTERN(irq_uspace_hash_table_lock);
     188IRQ_SPINLOCK_EXTERN(irq_uspace_hash_table_lock);
    179189extern hash_table_t irq_uspace_hash_table;
    180190
     
    184194extern irq_t *irq_dispatch_and_lock(inr_t);
    185195
     196#endif /* KERNEL */
     197
    186198#endif
    187199
    188 #endif
    189 
    190200/** @}
    191201 */
  • kernel/generic/include/interrupt.h

    r666f492 rda1bafb  
    4444#include <stacktrace.h>
    4545
    46 typedef void (* iroutine)(int n, istate_t *istate);
     46typedef void (* iroutine)(int, istate_t *);
    4747
    48 extern void fault_if_from_uspace(istate_t *istate, const char *fmt, ...);
    49 extern iroutine exc_register(int n, const char *name, iroutine f);
    50 extern void exc_dispatch(int n, istate_t *t);
    51 void exc_init(void);
     48extern void fault_if_from_uspace(istate_t *, const char *, ...);
     49extern iroutine exc_register(int, const char *, iroutine);
     50extern void exc_dispatch(int, istate_t *);
     51extern void exc_init(void);
    5252
    53 extern void irq_initialize_arch(irq_t *irq);
     53extern void irq_initialize_arch(irq_t *);
    5454
    5555#endif
  • kernel/generic/include/ipc/ipc.h

    r666f492 rda1bafb  
    3636#define KERN_IPC_H_
    3737
    38 /* Length of data being transfered with IPC call */
    39 /* - the uspace may not be able to utilize full length */
    40 #define IPC_CALL_LEN            6       
     38/** Length of data being transfered with IPC call
     39 *
     40 * The uspace may not be able to utilize full length
     41 *
     42 */
     43#define IPC_CALL_LEN  6
    4144
    4245/** Maximum active async calls per thread */
    4346#ifdef CONFIG_DEBUG
    44 #define IPC_MAX_ASYNC_CALLS     4
     47        #define IPC_MAX_ASYNC_CALLS  4
    4548#else
    46 #define IPC_MAX_ASYNC_CALLS     4000
     49        #define IPC_MAX_ASYNC_CALLS  4000
    4750#endif
    4851
     
    5053
    5154/** This is answer to a call */
    52 #define IPC_CALL_ANSWERED       (1 << 0)
     55#define IPC_CALL_ANSWERED  (1 << 0)
     56
    5357/** Answer will not be passed to userspace, will be discarded */
    54 #define IPC_CALL_DISCARD_ANSWER (1 << 1)
     58#define IPC_CALL_DISCARD_ANSWER  (1 << 1)
     59
    5560/** Call was forwarded */
    56 #define IPC_CALL_FORWARDED      (1 << 2)
     61#define IPC_CALL_FORWARDED  (1 << 2)
     62
    5763/** Identify connect_me_to answer */
    58 #define IPC_CALL_CONN_ME_TO     (1 << 3)
     64#define IPC_CALL_CONN_ME_TO  (1 << 3)
     65
    5966/** Interrupt notification */
    60 #define IPC_CALL_NOTIF          (1 << 4)
    61 
    62 /*
    63  * Bits used in call hashes.
     67#define IPC_CALL_NOTIF  (1 << 4)
     68
     69
     70/** Bits used in call hashes.
     71 *
    6472 * The addresses are aligned at least to 4 that is why we can use the 2 least
    6573 * significant bits of the call address.
    66  */
     74 *
     75 */
     76
    6777/** Type of this call is 'answer' */
    68 #define IPC_CALLID_ANSWERED     1
     78#define IPC_CALLID_ANSWERED  1
     79
    6980/** Type of this call is 'notification' */
    70 #define IPC_CALLID_NOTIFICATION 2
     81#define IPC_CALLID_NOTIFICATION  2
    7182
    7283/* Return values from sys_ipc_call_async(). */
    73 #define IPC_CALLRET_FATAL       -1
    74 #define IPC_CALLRET_TEMPORARY   -2
     84#define IPC_CALLRET_FATAL      -1
     85#define IPC_CALLRET_TEMPORARY  -2
    7586
    7687
    7788/* Macros for manipulating calling data */
    78 #define IPC_SET_RETVAL(data, retval)    ((data).args[0] = (retval))
    79 #define IPC_SET_METHOD(data, val)       ((data).args[0] = (val))
    80 #define IPC_SET_ARG1(data, val)         ((data).args[1] = (val))
    81 #define IPC_SET_ARG2(data, val)         ((data).args[2] = (val))
    82 #define IPC_SET_ARG3(data, val)         ((data).args[3] = (val))
    83 #define IPC_SET_ARG4(data, val)         ((data).args[4] = (val))
    84 #define IPC_SET_ARG5(data, val)         ((data).args[5] = (val))
    85 
    86 #define IPC_GET_METHOD(data)            ((data).args[0])
    87 #define IPC_GET_RETVAL(data)            ((data).args[0])
    88 
    89 #define IPC_GET_ARG1(data)              ((data).args[1])
    90 #define IPC_GET_ARG2(data)              ((data).args[2])
    91 #define IPC_GET_ARG3(data)              ((data).args[3])
    92 #define IPC_GET_ARG4(data)              ((data).args[4])
    93 #define IPC_GET_ARG5(data)              ((data).args[5])
     89#define IPC_SET_RETVAL(data, retval)  ((data).args[0] = (retval))
     90#define IPC_SET_METHOD(data, val)     ((data).args[0] = (val))
     91#define IPC_SET_ARG1(data, val)       ((data).args[1] = (val))
     92#define IPC_SET_ARG2(data, val)       ((data).args[2] = (val))
     93#define IPC_SET_ARG3(data, val)       ((data).args[3] = (val))
     94#define IPC_SET_ARG4(data, val)       ((data).args[4] = (val))
     95#define IPC_SET_ARG5(data, val)       ((data).args[5] = (val))
     96
     97#define IPC_GET_METHOD(data)  ((data).args[0])
     98#define IPC_GET_RETVAL(data)  ((data).args[0])
     99
     100#define IPC_GET_ARG1(data)  ((data).args[1])
     101#define IPC_GET_ARG2(data)  ((data).args[2])
     102#define IPC_GET_ARG3(data)  ((data).args[3])
     103#define IPC_GET_ARG4(data)  ((data).args[4])
     104#define IPC_GET_ARG5(data)  ((data).args[5])
    94105
    95106/* Well known phone descriptors */
    96 #define PHONE_NS        0
     107#define PHONE_NS  0
    97108
    98109/* Forwarding flags. */
    99 #define IPC_FF_NONE             0
     110#define IPC_FF_NONE  0
     111
    100112/**
    101113 * The call will be routed as though it was initially sent via the phone used to
     
    104116 * calls that were initially sent by the forwarder to the same destination. This
    105117 * flag has no imapct on routing replies.
    106  */
    107 #define IPC_FF_ROUTE_FROM_ME    (1 << 0)
    108 
    109 /* System-specific methods - only through special syscalls
     118 *
     119 */
     120#define IPC_FF_ROUTE_FROM_ME  (1 << 0)
     121
     122/** System-specific methods - only through special syscalls
    110123 * These methods have special behaviour
    111  */
     124 *
     125 */
     126
    112127/** Clone connection.
    113128 *
     
    115130 *
    116131 * - ARG1 - The caller sets ARG1 to the phone of the cloned connection.
    117  *        - The callee gets the new phone from ARG1.
     132 *        - The callee gets the new phone from ARG1.
     133 *
    118134 * - on answer, the callee acknowledges the new connection by sending EOK back
    119135 *   or the kernel closes it
    120  */
    121 #define IPC_M_CONNECTION_CLONE  1
     136 *
     137 */
     138#define IPC_M_CONNECTION_CLONE  1
     139
    122140/** Protocol for CONNECT - ME
    123141 *
    124142 * Through this call, the recipient learns about the new cloned connection.
    125  * 
     143 *
    126144 * - ARG5 - the kernel sets ARG5 to contain the hash of the used phone
    127145 * - on asnwer, the callee acknowledges the new connection by sending EOK back
    128146 *   or the kernel closes it
    129  */
    130 #define IPC_M_CONNECT_ME        2
    131 /** Protocol for CONNECT - TO - ME
     147 *
     148 */
     149#define IPC_M_CONNECT_ME  2
     150
     151/** Protocol for CONNECT - TO - ME
    132152 *
    133153 * Calling process asks the callee to create a callback connection,
     
    144164 *                     - the allocated phoneid is passed to userspace
    145165 *                       (on the receiving side) as ARG5 of the call.
    146  */
    147 #define IPC_M_CONNECT_TO_ME     3       
     166 *
     167 */
     168#define IPC_M_CONNECT_TO_ME  3
     169
    148170/** Protocol for CONNECT - ME - TO
    149171 *
     
    163185 *
    164186 */
    165 #define IPC_M_CONNECT_ME_TO     4       
    166 /** This message is sent to answerbox when the phone
    167  * is hung up
    168  */
    169 #define IPC_M_PHONE_HUNGUP      5
     187#define IPC_M_CONNECT_ME_TO  4
     188
     189/** This message is sent to answerbox when the phone is hung up
     190 *
     191 */
     192#define IPC_M_PHONE_HUNGUP  5
    170193
    171194/** Send as_area over IPC.
     
    173196 * - ARG2 - size of source as_area (filled automatically by kernel)
    174197 * - ARG3 - flags of the as_area being sent
    175  * 
     198 *
    176199 * on answer, the recipient must set:
    177200 * - ARG1 - dst as_area base adress
    178  */
    179 #define IPC_M_SHARE_OUT         6       
     201 *
     202 */
     203#define IPC_M_SHARE_OUT  6
    180204
    181205/** Receive as_area over IPC.
     
    183207 * - ARG2 - destination as_area size
    184208 * - ARG3 - user defined argument
    185  * 
     209 *
    186210 * on answer, the recipient must set:
    187211 *
    188212 * - ARG1 - source as_area base address
    189213 * - ARG2 - flags that will be used for sharing
    190  */
    191 #define IPC_M_SHARE_IN          7       
     214 *
     215 */
     216#define IPC_M_SHARE_IN  7
    192217
    193218/** Send data to another address space over IPC.
     
    199224 * - ARG1 - final destination address space virtual address
    200225 * - ARG2 - final size of data to be copied
    201  */
    202 #define IPC_M_DATA_WRITE        8
     226 *
     227 */
     228#define IPC_M_DATA_WRITE  8
    203229
    204230/** Receive data from another address space over IPC.
     
    210236 * - ARG1 - source virtual address in the destination address space
    211237 * - ARG2 - final size of data to be copied
    212  */
    213 #define IPC_M_DATA_READ         9
     238 *
     239 */
     240#define IPC_M_DATA_READ  9
    214241
    215242/** Debug the recipient.
    216243 * - ARG1 - specifies the debug method (from udebug_method_t)
    217244 * - other arguments are specific to the debug method
    218  */
    219 #define IPC_M_DEBUG_ALL         10
     245 *
     246 */
     247#define IPC_M_DEBUG_ALL  10
    220248
    221249/* Well-known methods */
    222 #define IPC_M_LAST_SYSTEM       511
    223 #define IPC_M_PING              512
     250#define IPC_M_LAST_SYSTEM  511
     251#define IPC_M_PING         512
     252
    224253/* User methods */
    225 #define IPC_FIRST_USER_METHOD   1024
     254#define IPC_FIRST_USER_METHOD  1024
    226255
    227256#ifdef KERNEL
     
    259288
    260289typedef struct answerbox {
    261         SPINLOCK_DECLARE(lock);
    262 
     290        IRQ_SPINLOCK_DECLARE(lock);
     291       
    263292        struct task *task;
    264 
     293       
    265294        waitq_t wq;
    266 
     295       
    267296        /** Linkage for the list of task's synchronous answerboxes. */
    268297        link_t sync_box_link;
    269 
     298       
    270299        /** Phones connected to this answerbox. */
    271300        link_t connected_phones;
    272301        /** Received calls. */
    273         link_t calls;                   
    274         link_t dispatched_calls;        /* Should be hash table in the future */
    275 
     302        link_t calls;
     303        link_t dispatched_calls;  /* Should be hash table in the future */
     304       
    276305        /** Answered calls. */
    277306        link_t answers;
    278 
    279         SPINLOCK_DECLARE(irq_lock);
     307       
     308        IRQ_SPINLOCK_DECLARE(irq_lock);
     309       
    280310        /** Notifications from IRQ handlers. */
    281311        link_t irq_notifs;
     
    291321typedef struct {
    292322        link_t link;
    293 
    294         int flags;
    295 
     323       
     324        unsigned int flags;
     325       
    296326        /** Identification of the caller. */
    297327        struct task *sender;
    298         /** The caller box is different from sender->answerbox for synchronous
    299          *  calls. */
     328       
     329        /*
     330         * The caller box is different from sender->answerbox
     331         * for synchronous calls.
     332         *
     333         */
    300334        answerbox_t *callerbox;
    301 
     335       
    302336        /** Private data to internal IPC. */
    303337        unative_t priv;
    304 
     338       
    305339        /** Data passed from/to userspace. */
    306340        ipc_data_t data;
    307 
     341       
    308342        /** Buffer for IPC_M_DATA_WRITE and IPC_M_DATA_READ. */
    309343        uint8_t *buffer;
    310 
     344       
    311345        /*
    312346         * The forward operation can masquerade the caller phone. For those
    313347         * cases, we must keep it aside so that the answer is processed
    314348         * correctly.
     349         *
    315350         */
    316351        phone_t *caller_phone;
    317352} call_t;
    318353
    319 
    320354extern answerbox_t *ipc_phone_0;
    321355
    322 
    323356extern void ipc_init(void);
    324357
    325 extern call_t * ipc_call_alloc(int);
     358extern call_t *ipc_call_alloc(unsigned int);
    326359extern void ipc_call_free(call_t *);
    327360
    328361extern int ipc_call(phone_t *, call_t *);
    329362extern int ipc_call_sync(phone_t *, call_t *);
    330 extern call_t * ipc_wait_for_call(answerbox_t *, uint32_t, int);
    331 extern int ipc_forward(call_t *, phone_t *, answerbox_t *, int);
     363extern call_t * ipc_wait_for_call(answerbox_t *, uint32_t, unsigned int);
     364extern int ipc_forward(call_t *, phone_t *, answerbox_t *, unsigned int);
    332365extern void ipc_answer(answerbox_t *, call_t *);
    333366
     
    345378extern void ipc_print_task(task_id_t);
    346379
     380#endif /* KERNEL */
     381
    347382#endif
    348383
    349 #endif
    350 
    351384/** @}
    352385 */
  • kernel/generic/include/ipc/irq.h

    r666f492 rda1bafb  
    3737
    3838/** Maximum length of IPC IRQ program */
    39 #define IRQ_MAX_PROG_SIZE       20
     39#define IRQ_MAX_PROG_SIZE  20
    4040
    4141#include <ipc/ipc.h>
     
    5858 */
    5959#define ipc_irq_send_msg_0(irq) \
    60     ipc_irq_send_msg((irq), 0, 0, 0, 0, 0)
     60        ipc_irq_send_msg((irq), 0, 0, 0, 0, 0)
     61
    6162#define ipc_irq_send_msg_1(irq, a1) \
    62     ipc_irq_send_msg((irq), (a1), 0, 0, 0, 0)
     63        ipc_irq_send_msg((irq), (a1), 0, 0, 0, 0)
     64
    6365#define ipc_irq_send_msg_2(irq, a1, a2) \
    64     ipc_irq_send_msg((irq), (a1), (a2), 0, 0, 0)
     66        ipc_irq_send_msg((irq), (a1), (a2), 0, 0, 0)
     67
    6568#define ipc_irq_send_msg_3(irq, a1, a2, a3) \
    66     ipc_irq_send_msg((irq), (a1), (a2), (a3), 0, 0)
     69        ipc_irq_send_msg((irq), (a1), (a2), (a3), 0, 0)
     70
    6771#define ipc_irq_send_msg_4(irq, a1, a2, a3, a4) \
    68     ipc_irq_send_msg((irq), (a1), (a2), (a3), (a4), 0)
     72        ipc_irq_send_msg((irq), (a1), (a2), (a3), (a4), 0)
     73
    6974#define ipc_irq_send_msg_5(irq, a1, a2, a3, a4, a5) \
    70     ipc_irq_send_msg((irq), (a1), (a2), (a3), (a4), (a5))
     75        ipc_irq_send_msg((irq), (a1), (a2), (a3), (a4), (a5))
    7176
    7277extern void ipc_irq_send_msg(irq_t *, unative_t, unative_t, unative_t, unative_t,
  • kernel/generic/include/ipc/sysipc.h

    r666f492 rda1bafb  
    4040#include <typedefs.h>
    4141
    42 unative_t sys_ipc_call_sync_fast(unative_t phoneid, unative_t method,
     42extern unative_t sys_ipc_call_sync_fast(unative_t phoneid, unative_t method,
    4343    unative_t arg1, unative_t arg2, unative_t arg3, ipc_data_t *data);
    44 unative_t sys_ipc_call_sync_slow(unative_t phoneid, ipc_data_t *question,
     44extern unative_t sys_ipc_call_sync_slow(unative_t phoneid, ipc_data_t *question,
    4545    ipc_data_t *reply);
    46 unative_t sys_ipc_call_async_fast(unative_t phoneid, unative_t method,
     46extern unative_t sys_ipc_call_async_fast(unative_t phoneid, unative_t method,
    4747    unative_t arg1, unative_t arg2, unative_t arg3, unative_t arg4);
    48 unative_t sys_ipc_call_async_slow(unative_t phoneid, ipc_data_t *data);
    49 unative_t sys_ipc_answer_fast(unative_t callid, unative_t retval,
     48extern unative_t sys_ipc_call_async_slow(unative_t phoneid, ipc_data_t *data);
     49extern unative_t sys_ipc_answer_fast(unative_t callid, unative_t retval,
    5050    unative_t arg1, unative_t arg2, unative_t arg3, unative_t arg4);
    51 unative_t sys_ipc_answer_slow(unative_t callid, ipc_data_t *data);
    52 unative_t sys_ipc_wait_for_call(ipc_data_t *calldata, uint32_t usec,
    53     int nonblocking);
    54 unative_t sys_ipc_poke(void);
    55 unative_t sys_ipc_forward_fast(unative_t callid, unative_t phoneid,
    56     unative_t method, unative_t arg1, unative_t arg2, int mode);
    57 unative_t sys_ipc_forward_slow(unative_t callid, unative_t phoneid,
    58     ipc_data_t *data, int mode);
    59 unative_t sys_ipc_hangup(unative_t phoneid);
    60 unative_t sys_ipc_register_irq(inr_t inr, devno_t devno, unative_t method,
     51extern unative_t sys_ipc_answer_slow(unative_t callid, ipc_data_t *data);
     52extern unative_t sys_ipc_wait_for_call(ipc_data_t *calldata, uint32_t usec,
     53    unsigned int nonblocking);
     54extern unative_t sys_ipc_poke(void);
     55extern unative_t sys_ipc_forward_fast(unative_t callid, unative_t phoneid,
     56    unative_t method, unative_t arg1, unative_t arg2, unsigned int mode);
     57extern unative_t sys_ipc_forward_slow(unative_t callid, unative_t phoneid,
     58    ipc_data_t *data, unsigned int mode);
     59extern unative_t sys_ipc_hangup(unative_t phoneid);
     60extern unative_t sys_ipc_register_irq(inr_t inr, devno_t devno, unative_t method,
    6161    irq_code_t *ucode);
    62 unative_t sys_ipc_unregister_irq(inr_t inr, devno_t devno);
    63 unative_t sys_ipc_connect_kbox(sysarg64_t *task_id);
     62extern unative_t sys_ipc_unregister_irq(inr_t inr, devno_t devno);
     63extern unative_t sys_ipc_connect_kbox(sysarg64_t *task_id);
    6464
    6565#endif
  • kernel/generic/include/mm/as.h

    r666f492 rda1bafb  
    4343
    4444/** Address space area flags. */
    45 #define AS_AREA_READ            1
    46 #define AS_AREA_WRITE           2
    47 #define AS_AREA_EXEC            4
    48 #define AS_AREA_CACHEABLE       8
     45#define AS_AREA_READ       1
     46#define AS_AREA_WRITE      2
     47#define AS_AREA_EXEC       4
     48#define AS_AREA_CACHEABLE  8
    4949
    5050/** Address space area info exported to userspace. */
     
    5252        /** Starting address */
    5353        uintptr_t start_addr;
    54 
     54       
    5555        /** Area size */
    5656        size_t size;
    57 
     57       
    5858        /** Area flags */
    59         int flags;
     59        unsigned int flags;
    6060} as_area_info_t;
    6161
     
    7575 * Defined to be true if user address space and kernel address space shadow each
    7676 * other.
    77  */
    78 #define KERNEL_ADDRESS_SPACE_SHADOWED   KERNEL_ADDRESS_SPACE_SHADOWED_ARCH
    79 
    80 #define KERNEL_ADDRESS_SPACE_START      KERNEL_ADDRESS_SPACE_START_ARCH
    81 #define KERNEL_ADDRESS_SPACE_END        KERNEL_ADDRESS_SPACE_END_ARCH
    82 #define USER_ADDRESS_SPACE_START        USER_ADDRESS_SPACE_START_ARCH
    83 #define USER_ADDRESS_SPACE_END          USER_ADDRESS_SPACE_END_ARCH
    84 
    85 #define USTACK_ADDRESS                  USTACK_ADDRESS_ARCH
     77 *
     78 */
     79#define KERNEL_ADDRESS_SPACE_SHADOWED  KERNEL_ADDRESS_SPACE_SHADOWED_ARCH
     80
     81#define KERNEL_ADDRESS_SPACE_START  KERNEL_ADDRESS_SPACE_START_ARCH
     82#define KERNEL_ADDRESS_SPACE_END    KERNEL_ADDRESS_SPACE_END_ARCH
     83#define USER_ADDRESS_SPACE_START    USER_ADDRESS_SPACE_START_ARCH
     84#define USER_ADDRESS_SPACE_END      USER_ADDRESS_SPACE_END_ARCH
     85
     86#define USTACK_ADDRESS  USTACK_ADDRESS_ARCH
    8687
    8788/** Kernel address space. */
    88 #define FLAG_AS_KERNEL                  (1 << 0)       
     89#define FLAG_AS_KERNEL  (1 << 0)
    8990
    9091/* Address space area attributes. */
    91 #define AS_AREA_ATTR_NONE       0
    92 #define AS_AREA_ATTR_PARTIAL    1       /**< Not fully initialized area. */
     92#define AS_AREA_ATTR_NONE     0
     93#define AS_AREA_ATTR_PARTIAL  1  /**< Not fully initialized area. */
    9394
    9495/** The page fault was not resolved by as_page_fault(). */
    95 #define AS_PF_FAULT             0
     96#define AS_PF_FAULT  0
     97
    9698/** The page fault was resolved by as_page_fault(). */
    97 #define AS_PF_OK                1
     99#define AS_PF_OK  1
     100
    98101/** The page fault was caused by memcpy_from_uspace() or memcpy_to_uspace(). */
    99 #define AS_PF_DEFER             2
     102#define AS_PF_DEFER  2
    100103
    101104/** Address space structure.
     
    105108 * supposed to figure in the list as they are shared by all tasks and
    106109 * set up during system initialization.
     110 *
    107111 */
    108112typedef struct as {
    109113        /** Protected by asidlock. */
    110114        link_t inactive_as_with_asid_link;
     115       
    111116        /**
    112117         * Number of processors on wich is this address space active.
     
    114119         */
    115120        size_t cpu_refcount;
     121       
    116122        /**
    117123         * Address space identifier.
     
    120126         */
    121127        asid_t asid;
    122 
     128       
    123129        /** Number of references (i.e tasks that reference this as). */
    124130        atomic_t refcount;
    125 
     131       
    126132        mutex_t lock;
    127 
     133       
    128134        /** B+tree of address space areas. */
    129135        btree_t as_area_btree;
     
    131137        /** Non-generic content. */
    132138        as_genarch_t genarch;
    133 
     139       
    134140        /** Architecture specific content. */
    135141        as_arch_t arch;
     
    137143
    138144typedef struct {
    139         pte_t *(* page_table_create)(int flags);
    140         void (* page_table_destroy)(pte_t *page_table);
    141         void (* page_table_lock)(as_t *as, bool lock);
    142         void (* page_table_unlock)(as_t *as, bool unlock);
     145        pte_t *(* page_table_create)(unsigned int);
     146        void (* page_table_destroy)(pte_t *);
     147        void (* page_table_lock)(as_t *, bool);
     148        void (* page_table_unlock)(as_t *, bool);
    143149} as_operations_t;
    144150
     
    146152 * This structure contains information associated with the shared address space
    147153 * area.
     154 *
    148155 */
    149156typedef struct {
    150157        /** This lock must be acquired only when the as_area lock is held. */
    151         mutex_t lock;           
     158        mutex_t lock;
    152159        /** This structure can be deallocated if refcount drops to 0. */
    153160        size_t refcount;
     161       
    154162        /**
    155163         * B+tree containing complete map of anonymous pages of the shared area.
     
    169177/** Backend data stored in address space area. */
    170178typedef union mem_backend_data {
    171         struct {        /**< elf_backend members */
     179        /** elf_backend members */
     180        struct {
    172181                elf_header_t *elf;
    173182                elf_segment_header_t *segment;
    174183        };
    175         struct {        /**< phys_backend members */
     184       
     185        /** phys_backend members */
     186        struct {
    176187                uintptr_t base;
    177188                size_t frames;
     
    182193 *
    183194 * Each as_area_t structure describes one contiguous area of virtual memory.
     195 *
    184196 */
    185197typedef struct {
    186198        mutex_t lock;
    187199        /** Containing address space. */
    188         as_t *as;               
     200        as_t *as;
     201       
    189202        /**
    190203         * Flags related to the memory represented by the address space area.
    191204         */
    192         int flags;
     205        unsigned int flags;
     206       
    193207        /** Attributes related to the address space area itself. */
    194         int attributes;
     208        unsigned int attributes;
    195209        /** Size of this area in multiples of PAGE_SIZE. */
    196210        size_t pages;
     
    199213        /** Map of used space. */
    200214        btree_t used_space;
    201 
     215       
    202216        /**
    203217         * If the address space area has been shared, this pointer will
     
    205219         */
    206220        share_info_t *sh_info;
    207 
     221       
    208222        /** Memory backend backing this address space area. */
    209223        struct mem_backend *backend;
    210 
     224       
    211225        /** Data to be used by the backend. */
    212226        mem_backend_data_t backend_data;
     
    215229/** Address space area backend structure. */
    216230typedef struct mem_backend {
    217         int (* page_fault)(as_area_t *area, uintptr_t addr, pf_access_t access);
    218         void (* frame_free)(as_area_t *area, uintptr_t page, uintptr_t frame);
    219         void (* share)(as_area_t *area);
     231        int (* page_fault)(as_area_t *, uintptr_t, pf_access_t);
     232        void (* frame_free)(as_area_t *, uintptr_t, uintptr_t);
     233        void (* share)(as_area_t *);
    220234} mem_backend_t;
    221235
     
    227241extern void as_init(void);
    228242
    229 extern as_t *as_create(int);
     243extern as_t *as_create(unsigned int);
    230244extern void as_destroy(as_t *);
    231245extern void as_hold(as_t *);
     
    234248extern int as_page_fault(uintptr_t, pf_access_t, istate_t *);
    235249
    236 extern as_area_t *as_area_create(as_t *, int, size_t, uintptr_t, int,
    237     mem_backend_t *, mem_backend_data_t *);
     250extern as_area_t *as_area_create(as_t *, unsigned int, size_t, uintptr_t,
     251    unsigned int, mem_backend_t *, mem_backend_data_t *);
    238252extern int as_area_destroy(as_t *, uintptr_t);
    239 extern int as_area_resize(as_t *, uintptr_t, size_t, int);
    240 extern int as_area_share(as_t *, uintptr_t, size_t, as_t *, uintptr_t, int);
    241 extern int as_area_change_flags(as_t *, int, uintptr_t);
    242 
    243 extern int as_area_get_flags(as_area_t *);
     253extern int as_area_resize(as_t *, uintptr_t, size_t, unsigned int);
     254extern int as_area_share(as_t *, uintptr_t, size_t, as_t *, uintptr_t,
     255    unsigned int);
     256extern int as_area_change_flags(as_t *, unsigned int, uintptr_t);
     257
     258extern unsigned int as_area_get_flags(as_area_t *);
    244259extern bool as_area_check_access(as_area_t *, pf_access_t);
    245260extern size_t as_area_get_size(uintptr_t);
     
    249264
    250265/* Interface to be implemented by architectures. */
     266
    251267#ifndef as_constructor_arch
    252 extern int as_constructor_arch(as_t *, int);
     268extern int as_constructor_arch(as_t *, unsigned int);
    253269#endif /* !def as_constructor_arch */
     270
    254271#ifndef as_destructor_arch
    255272extern int as_destructor_arch(as_t *);
    256273#endif /* !def as_destructor_arch */
     274
    257275#ifndef as_create_arch
    258 extern int as_create_arch(as_t *, int);
     276extern int as_create_arch(as_t *, unsigned int);
    259277#endif /* !def as_create_arch */
     278
    260279#ifndef as_install_arch
    261280extern void as_install_arch(as_t *);
    262281#endif /* !def as_install_arch */
     282
    263283#ifndef as_deinstall_arch
    264284extern void as_deinstall_arch(as_t *);
     
    270290extern mem_backend_t phys_backend;
    271291
    272 /** 
     292/**
    273293 * This flags is passed when running the loader, otherwise elf_load()
    274294 * would return with a EE_LOADER error code.
    275  */
    276 #define ELD_F_NONE      0
    277 #define ELD_F_LOADER    1
    278 
    279 extern unsigned int elf_load(elf_header_t *, as_t *, int);
     295 *
     296 */
     297#define ELD_F_NONE    0
     298#define ELD_F_LOADER  1
     299
     300extern unsigned int elf_load(elf_header_t *, as_t *, unsigned int);
    280301
    281302/* Address space area related syscalls. */
    282 extern unative_t sys_as_area_create(uintptr_t, size_t, int);
    283 extern unative_t sys_as_area_resize(uintptr_t, size_t, int);
    284 extern unative_t sys_as_area_change_flags(uintptr_t, int);
     303extern unative_t sys_as_area_create(uintptr_t, size_t, unsigned int);
     304extern unative_t sys_as_area_resize(uintptr_t, size_t, unsigned int);
     305extern unative_t sys_as_area_change_flags(uintptr_t, unsigned int);
    285306extern unative_t sys_as_area_destroy(uintptr_t);
    286307
  • kernel/generic/include/mm/frame.h

    r666f492 rda1bafb  
    8181
    8282typedef struct {
    83         size_t refcount;     /**< Tracking of shared frames */
     83        size_t refcount;      /**< Tracking of shared frames */
    8484        uint8_t buddy_order;  /**< Buddy system block order */
    8585        link_t buddy_link;    /**< Link to the next free block inside
     
    9191        pfn_t base;                    /**< Frame_no of the first frame
    9292                                        in the frames array */
    93         size_t count;                 /**< Size of zone */
    94         size_t free_count;            /**< Number of free frame_t
     93        size_t count;                  /**< Size of zone */
     94        size_t free_count;             /**< Number of free frame_t
    9595                                        structures */
    96         size_t busy_count;            /**< Number of busy frame_t
     96        size_t busy_count;             /**< Number of busy frame_t
    9797                                        structures */
    9898        zone_flags_t flags;            /**< Type of the zone */
     
    108108 */
    109109typedef struct {
    110         SPINLOCK_DECLARE(lock);
     110        IRQ_SPINLOCK_DECLARE(lock);
    111111        size_t count;
    112112        zone_t info[ZONES_MAX];
  • kernel/generic/include/mm/page.h

    r666f492 rda1bafb  
    4242/** Operations to manipulate page mappings. */
    4343typedef struct {
    44         void (* mapping_insert)(as_t *as, uintptr_t page, uintptr_t frame,
    45             int flags);
    46         void (* mapping_remove)(as_t *as, uintptr_t page);
    47         pte_t *(* mapping_find)(as_t *as, uintptr_t page);
     44        void (* mapping_insert)(as_t *, uintptr_t, uintptr_t, unsigned int);
     45        void (* mapping_remove)(as_t *, uintptr_t);
     46        pte_t *(* mapping_find)(as_t *, uintptr_t);
    4847} page_mapping_operations_t;
    4948
     
    5150
    5251extern void page_init(void);
    53 extern void page_table_lock(as_t *as, bool lock);
    54 extern void page_table_unlock(as_t *as, bool unlock);
    55 extern void page_mapping_insert(as_t *as, uintptr_t page, uintptr_t frame,
    56     int flags);
    57 extern void page_mapping_remove(as_t *as, uintptr_t page);
    58 extern pte_t *page_mapping_find(as_t *as, uintptr_t page);
    59 extern pte_t *page_table_create(int flags);
    60 extern void page_table_destroy(pte_t *page_table);
    61 extern void map_structure(uintptr_t s, size_t size);
     52extern void page_table_lock(as_t *, bool);
     53extern void page_table_unlock(as_t *, bool);
     54extern void page_mapping_insert(as_t *, uintptr_t, uintptr_t, unsigned int);
     55extern void page_mapping_remove(as_t *, uintptr_t);
     56extern pte_t *page_mapping_find(as_t *, uintptr_t);
     57extern pte_t *page_table_create(unsigned int);
     58extern void page_table_destroy(pte_t *);
     59extern void map_structure(uintptr_t, size_t);
    6260
    63 extern uintptr_t hw_map(uintptr_t physaddr, size_t size);
     61extern uintptr_t hw_map(uintptr_t, size_t);
    6462
    6563#endif
  • kernel/generic/include/mm/slab.h

    r666f492 rda1bafb  
    8484} slab_mag_cache_t;
    8585
    86 
    8786typedef struct {
    8887        const char *name;
     
    9493        size_t size;
    9594       
    96         int (*constructor)(void *obj, int kmflag);
    97         int (*destructor)(void *obj);
     95        int (*constructor)(void *obj, unsigned int kmflag);
     96        size_t (*destructor)(void *obj);
    9897       
    9998        /** Flags changing behaviour of cache */
    100         int flags;
     99        unsigned int flags;
    101100       
    102101        /* Computed values */
    103         uint8_t order;         /**< Order of frames to be allocated */
    104         unsigned int objects;  /**< Number of objects that fit in */
     102        uint8_t order;   /**< Order of frames to be allocated */
     103        size_t objects;  /**< Number of objects that fit in */
    105104       
    106105        /* Statistics */
     
    109108        atomic_t cached_objs;
    110109        /** How many magazines in magazines list */
    111         atomic_t magazine_counter; 
     110        atomic_t magazine_counter;
    112111       
    113112        /* Slabs */
     
    124123
    125124extern slab_cache_t *slab_cache_create(const char *, size_t, size_t,
    126     int (*)(void *, int), int (*)(void *), int);
     125    int (*)(void *, unsigned int), size_t (*)(void *), unsigned int);
    127126extern void slab_cache_destroy(slab_cache_t *);
    128127
    129 extern void * slab_alloc(slab_cache_t *, int);
     128extern void * slab_alloc(slab_cache_t *, unsigned int);
    130129extern void slab_free(slab_cache_t *, void *);
    131 extern size_t slab_reclaim(int);
     130extern size_t slab_reclaim(unsigned int);
    132131
    133132/* slab subsytem initialization */
     
    139138
    140139/* malloc support */
    141 extern void *malloc(unsigned int, int);
    142 extern void *realloc(void *, unsigned int, int);
     140extern void *malloc(size_t, unsigned int);
     141extern void *realloc(void *, size_t, unsigned int);
    143142extern void free(void *);
    144143
  • kernel/generic/include/proc/scheduler.h

    r666f492 rda1bafb  
    4747/** Scheduler run queue structure. */
    4848typedef struct {
    49         SPINLOCK_DECLARE(lock);
    50         link_t rq_head;          /**< List of ready threads. */
    51         size_t n;                /**< Number of threads in rq_ready. */
     49        IRQ_SPINLOCK_DECLARE(lock);
     50        link_t rq_head;              /**< List of ready threads. */
     51        size_t n;                    /**< Number of threads in rq_ready. */
    5252} runq_t;
    5353
  • kernel/generic/include/proc/task.h

    r666f492 rda1bafb  
    7070         * threads.
    7171         */
    72         SPINLOCK_DECLARE(lock);
    73 
     72        IRQ_SPINLOCK_DECLARE(lock);
     73       
    7474        char name[TASK_NAME_BUFLEN];
    7575        /** List of threads contained in this task. */
     
    8181        /** Task security context. */
    8282        context_id_t context;
    83 
     83       
    8484        /** Number of references (i.e. threads). */
    8585        atomic_t refcount;
    8686        /** Number of threads that haven't exited yet. */
    8787        atomic_t lifecount;
    88 
     88       
    8989        /** Task capabilities. */
    9090        cap_t capabilities;
    91 
     91       
    9292        /* IPC stuff */
    9393        answerbox_t answerbox;  /**< Communication endpoint */
     
    101101        /** List of synchronous answerboxes. */
    102102        link_t sync_box_head;
    103 
     103       
    104104#ifdef CONFIG_UDEBUG
    105105        /** Debugging stuff. */
    106106        udebug_task_t udebug;
    107 
     107       
    108108        /** Kernel answerbox. */
    109109        kbox_t kb;
    110 #endif
    111 
     110#endif /* CONFIG_UDEBUG */
     111       
    112112        /** Architecture specific task data. */
    113113        task_arch_t arch;
     
    126126} task_t;
    127127
    128 SPINLOCK_EXTERN(tasks_lock);
     128IRQ_SPINLOCK_EXTERN(tasks_lock);
    129129extern avltree_t tasks_tree;
    130130
  • kernel/generic/include/proc/thread.h

    r666f492 rda1bafb  
    5050#include <sysinfo/abi.h>
    5151
    52 #define THREAD_STACK_SIZE       STACK_SIZE
    53 #define THREAD_NAME_BUFLEN      20
     52#define THREAD_STACK_SIZE   STACK_SIZE
     53#define THREAD_NAME_BUFLEN  20
    5454
    5555extern const char *thread_states[];
     
    6161 * When using this flag, the caller must set cpu in the thread_t
    6262 * structure manually before calling thread_ready (even on uniprocessor).
    63  */
    64 #define THREAD_FLAG_WIRED       (1 << 0)
     63 *
     64 */
     65#define THREAD_FLAG_WIRED  (1 << 0)
     66
    6567/** Thread was migrated to another CPU and has not run yet. */
    66 #define THREAD_FLAG_STOLEN      (1 << 1)
     68#define THREAD_FLAG_STOLEN  (1 << 1)
     69
    6770/** Thread executes in userspace. */
    68 #define THREAD_FLAG_USPACE      (1 << 2)
     71#define THREAD_FLAG_USPACE  (1 << 2)
     72
    6973/** Thread will be attached by the caller. */
    70 #define THREAD_FLAG_NOATTACH    (1 << 3)
     74#define THREAD_FLAG_NOATTACH  (1 << 3)
    7175
    7276/** Thread structure. There is one per thread. */
    7377typedef struct thread {
    74         link_t rq_link;         /**< Run queue link. */
    75         link_t wq_link;         /**< Wait queue link. */
    76         link_t th_link;         /**< Links to threads within containing task. */
    77 
     78        link_t rq_link;  /**< Run queue link. */
     79        link_t wq_link;  /**< Wait queue link. */
     80        link_t th_link;  /**< Links to threads within containing task. */
     81       
    7882        /** Threads linkage to the threads_tree. */
    7983        avltree_node_t threads_tree_node;
     
    8387         * Protects the whole thread structure except list links above.
    8488         */
    85         SPINLOCK_DECLARE(lock);
    86 
     89        IRQ_SPINLOCK_DECLARE(lock);
     90       
    8791        char name[THREAD_NAME_BUFLEN];
    88 
     92       
    8993        /** Function implementing the thread. */
    9094        void (* thread_code)(void *);
    9195        /** Argument passed to thread_code() function. */
    9296        void *thread_arg;
    93 
     97       
    9498        /**
    9599         * From here, the stored context is restored when the thread is
     
    107111         */
    108112        context_t sleep_interruption_context;
    109 
     113       
    110114        /** If true, the thread can be interrupted from sleep. */
    111115        bool sleep_interruptible;
     
    115119        timeout_t sleep_timeout;
    116120        /** Flag signalling sleep timeout in progress. */
    117         volatile int timeout_pending;
    118 
     121        volatile bool timeout_pending;
     122       
    119123        /**
    120124         * True if this thread is executing copy_from_uspace().
     
    132136         * thread_exit() before returning to userspace.
    133137         */
    134         bool interrupted;                       
     138        bool interrupted;
    135139       
    136140        /** If true, thread_join_timeout() cannot be used on this thread. */
     
    140144        /** Link used in the joiner_head list. */
    141145        link_t joiner_link;
    142 
     146       
    143147        fpu_context_t *saved_fpu_context;
    144148        int fpu_context_exists;
    145 
     149       
    146150        /*
    147151         * Defined only if thread doesn't run.
     
    150154         */
    151155        int fpu_context_engaged;
    152 
     156       
    153157        rwlock_type_t rwlock_holder_type;
    154 
     158       
    155159        /** Callback fired in scheduler before the thread is put asleep. */
    156160        void (* call_me)(void *);
    157161        /** Argument passed to call_me(). */
    158162        void *call_me_with;
    159 
     163       
    160164        /** Thread's state. */
    161165        state_t state;
    162166        /** Thread's flags. */
    163         int flags;
     167        unsigned int flags;
    164168       
    165169        /** Thread's CPU. */
     
    167171        /** Containing task. */
    168172        task_t *task;
    169 
     173       
    170174        /** Ticks before preemption. */
    171175        uint64_t ticks;
     
    176180        /** Last sampled cycle. */
    177181        uint64_t last_cycle;
    178         /** Thread doesn't affect accumulated accounting. */   
     182        /** Thread doesn't affect accumulated accounting. */
    179183        bool uncounted;
    180 
     184       
    181185        /** Thread's priority. Implemented as index to CPU->rq */
    182186        int priority;
     
    186190        /** Architecture-specific data. */
    187191        thread_arch_t arch;
    188 
     192       
    189193        /** Thread's kernel stack. */
    190194        uint8_t *kstack;
    191 
     195       
    192196#ifdef CONFIG_UDEBUG
    193197        /** Debugging stuff */
    194198        udebug_thread_t udebug;
    195 #endif
    196 
     199#endif /* CONFIG_UDEBUG */
    197200} thread_t;
    198201
     
    203206 *
    204207 */
    205 SPINLOCK_EXTERN(threads_lock);
     208IRQ_SPINLOCK_EXTERN(threads_lock);
    206209
    207210/** AVL tree containing all threads. */
     
    209212
    210213extern void thread_init(void);
    211 extern thread_t *thread_create(void (*)(void *), void *, task_t *, int,
    212     const char *, bool);
     214extern thread_t *thread_create(void (*)(void *), void *, task_t *,
     215    unsigned int, const char *, bool);
    213216extern void thread_attach(thread_t *, task_t *);
    214217extern void thread_ready(thread_t *);
     
    218221extern void thread_create_arch(thread_t *);
    219222#endif
     223
    220224#ifndef thr_constructor_arch
    221225extern void thr_constructor_arch(thread_t *);
    222226#endif
     227
    223228#ifndef thr_destructor_arch
    224229extern void thr_destructor_arch(thread_t *);
     
    230235#define thread_join(t) \
    231236        thread_join_timeout((t), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE)
    232 extern int thread_join_timeout(thread_t *, uint32_t, int);
     237
     238extern int thread_join_timeout(thread_t *, uint32_t, unsigned int);
    233239extern void thread_detach(thread_t *);
    234240
    235241extern void thread_register_call_me(void (*)(void *), void *);
    236242extern void thread_print_list(void);
    237 extern void thread_destroy(thread_t *);
     243extern void thread_destroy(thread_t *, bool);
    238244extern thread_t *thread_find_by_id(thread_id_t);
    239245extern void thread_update_accounting(bool);
  • kernel/generic/include/stacktrace.h

    r666f492 rda1bafb  
    3838#include <typedefs.h>
    3939
    40 /* Forward declarations. */
     40/* Forward declaration. */
    4141struct istate;
    4242
  • kernel/generic/include/symtab.h

    r666f492 rda1bafb  
    3838#include <typedefs.h>
    3939
    40 #define MAX_SYMBOL_NAME 64
     40#define MAX_SYMBOL_NAME  64
    4141
    4242struct symtab_entry {
     
    5353#ifdef CONFIG_SYMTAB
    5454
    55 /* Symtable linked together by build process */
     55/** Symtable linked together by build process
     56 *
     57 */
    5658extern struct symtab_entry symbol_table[];
    5759
    58 #endif
     60#endif /* CONFIG_SYMTAB */
    5961
    6062#endif
  • kernel/generic/include/synch/mutex.h

    r666f492 rda1bafb  
    5050} mutex_t;
    5151
    52 #define mutex_lock(mtx)                 \
     52#define mutex_lock(mtx) \
    5353        _mutex_lock_timeout((mtx), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE)
    54 #define mutex_trylock(mtx)              \
     54
     55#define mutex_trylock(mtx) \
    5556        _mutex_lock_timeout((mtx), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NON_BLOCKING)
    56 #define mutex_lock_timeout(mtx, usec)   \
     57
     58#define mutex_lock_timeout(mtx, usec) \
    5759        _mutex_lock_timeout((mtx), (usec), SYNCH_FLAGS_NON_BLOCKING)
    5860
    5961extern void mutex_initialize(mutex_t *, mutex_type_t);
    60 extern int _mutex_lock_timeout(mutex_t *, uint32_t, int);
     62extern int _mutex_lock_timeout(mutex_t *, uint32_t, unsigned int);
    6163extern void mutex_unlock(mutex_t *);
    6264
  • kernel/generic/include/synch/rwlock.h

    r666f492 rda1bafb  
    4848
    4949typedef struct {
    50         SPINLOCK_DECLARE(lock);
     50        IRQ_SPINLOCK_DECLARE(lock);
     51       
    5152        /**
    5253         * Mutex for writers, readers can bypass it if readers_in is positive.
     54         *
    5355         */
    5456        mutex_t exclusive;
     57       
    5558        /** Number of readers in critical section. */
    5659        size_t readers_in;
     
    5962#define rwlock_write_lock(rwl) \
    6063        _rwlock_write_lock_timeout((rwl), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE)
     64
    6165#define rwlock_read_lock(rwl) \
    6266        _rwlock_read_lock_timeout((rwl), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE)
     67
    6368#define rwlock_write_trylock(rwl) \
    6469        _rwlock_write_lock_timeout((rwl), SYNCH_NO_TIMEOUT, \
    6570            SYNCH_FLAGS_NON_BLOCKING)
     71
    6672#define rwlock_read_trylock(rwl) \
    6773        _rwlock_read_lock_timeout((rwl), SYNCH_NO_TIMEOUT, \
    6874            SYNCH_FLAGS_NON_BLOCKING)
     75
    6976#define rwlock_write_lock_timeout(rwl, usec) \
    7077        _rwlock_write_lock_timeout((rwl), (usec), SYNCH_FLAGS_NONE)
     78
    7179#define rwlock_read_lock_timeout(rwl, usec) \
    7280        _rwlock_read_lock_timeout((rwl), (usec), SYNCH_FLAGS_NONE)
    7381
    74 extern void rwlock_initialize(rwlock_t *rwl);
    75 extern void rwlock_read_unlock(rwlock_t *rwl);
    76 extern void rwlock_write_unlock(rwlock_t *rwl);
    77 extern int _rwlock_read_lock_timeout(rwlock_t *rwl, uint32_t usec, int flags);
    78 extern int _rwlock_write_lock_timeout(rwlock_t *rwl, uint32_t usec, int flags);
     82extern void rwlock_initialize(rwlock_t *);
     83extern void rwlock_read_unlock(rwlock_t *);
     84extern void rwlock_write_unlock(rwlock_t *);
     85extern int _rwlock_read_lock_timeout(rwlock_t *, uint32_t, unsigned int);
     86extern int _rwlock_write_lock_timeout(rwlock_t *, uint32_t, unsigned int);
    7987
    8088#endif
  • kernel/generic/include/synch/semaphore.h

    r666f492 rda1bafb  
    4646#define semaphore_down(s) \
    4747        _semaphore_down_timeout((s), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE)
     48
    4849#define semaphore_trydown(s) \
    4950        _semaphore_down_timeout((s), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NON_BLOCKING)
     51
    5052#define semaphore_down_timeout(s, usec) \
    5153        _semaphore_down_timeout((s), (usec), SYNCH_FLAGS_NONE)
    5254
    53 extern void semaphore_initialize(semaphore_t *s, int val);
    54 extern int _semaphore_down_timeout(semaphore_t *s, uint32_t usec, int flags);
    55 extern void semaphore_up(semaphore_t *s);
     55extern void semaphore_initialize(semaphore_t *, int);
     56extern int _semaphore_down_timeout(semaphore_t *, uint32_t, unsigned int);
     57extern void semaphore_up(semaphore_t *);
    5658
    5759#endif
  • kernel/generic/include/synch/spinlock.h

    r666f492 rda1bafb  
    170170#define SPINLOCK_STATIC_INITIALIZE_NAME(name, desc_name)
    171171
    172 #define ASSERT_SPINLOCK(expr, lock)
     172#define ASSERT_SPINLOCK(expr, lock)  ASSERT(expr)
    173173
    174174#define spinlock_initialize(lock, name)
  • kernel/generic/include/synch/waitq.h

    r666f492 rda1bafb  
    4646} wakeup_mode_t;
    4747
    48 /** Wait queue structure. */
     48/** Wait queue structure.
     49 *
     50 */
    4951typedef struct {
    50 
    5152        /** Lock protecting wait queue structure.
    5253         *
    5354         * Must be acquired before T.lock for each T of type thread_t.
    5455         */
    55         SPINLOCK_DECLARE(lock);
    56 
     56        IRQ_SPINLOCK_DECLARE(lock);
     57       
    5758        /**
    5859         * Number of waitq_wakeup() calls that didn't find a thread to wake up.
     60         *
    5961         */
    6062        int missed_wakeups;
     63       
    6164        /** List of sleeping threads for wich there was no missed_wakeup. */
    6265        link_t head;
     
    6972
    7073extern void waitq_initialize(waitq_t *);
    71 extern int waitq_sleep_timeout(waitq_t *, uint32_t, int);
     74extern int waitq_sleep_timeout(waitq_t *, uint32_t, unsigned int);
    7275extern ipl_t waitq_sleep_prepare(waitq_t *);
    73 extern int waitq_sleep_timeout_unsafe(waitq_t *, uint32_t, int);
     76extern int waitq_sleep_timeout_unsafe(waitq_t *, uint32_t, unsigned int);
    7477extern void waitq_sleep_finish(waitq_t *, int, ipl_t);
    7578extern void waitq_wakeup(waitq_t *, wakeup_mode_t);
  • kernel/generic/include/sysinfo/abi.h

    r666f492 rda1bafb  
    3838
    3939/** Number of load components */
    40 #define LOAD_STEPS        3
     40#define LOAD_STEPS  3
    4141
    4242/** Maximum task name size */
     
    6565 */
    6666typedef struct {
    67         unsigned int id;         /**< CPU ID as stored by kernel */
     67        size_t id;               /**< CPU ID as stored by kernel */
    6868        bool active;             /**< CPU is activate */
    6969        uint16_t frequency_mhz;  /**< Frequency in MHz */
  • kernel/generic/include/time/timeout.h

    r666f492 rda1bafb  
    4343
    4444typedef struct {
    45         SPINLOCK_DECLARE(lock);
    46 
     45        IRQ_SPINLOCK_DECLARE(lock);
     46       
    4747        /** Link to the list of active timeouts on THE->cpu */
    4848        link_t link;
    49         /** Timeout will be activated in this amount of clock() ticks. */       
     49        /** Timeout will be activated in this amount of clock() ticks. */
    5050        uint64_t ticks;
    5151        /** Function that will be called on timeout activation. */
     
    5757} timeout_t;
    5858
    59 #define us2ticks(us)    ((uint64_t) (((uint32_t) (us) / (1000000 / HZ))))
     59#define us2ticks(us)  ((uint64_t) (((uint32_t) (us) / (1000000 / HZ))))
    6060
    6161extern void timeout_init(void);
    62 extern void timeout_initialize(timeout_t *t);
    63 extern void timeout_reinitialize(timeout_t *t);
    64 extern void timeout_register(timeout_t *t, uint64_t usec, timeout_handler_t f,
    65     void *arg);
    66 extern bool timeout_unregister(timeout_t *t);
     62extern void timeout_initialize(timeout_t *);
     63extern void timeout_reinitialize(timeout_t *);
     64extern void timeout_register(timeout_t *, uint64_t, timeout_handler_t, void *);
     65extern bool timeout_unregister(timeout_t *);
    6766
    6867#endif
Note: See TracChangeset for help on using the changeset viewer.