Changeset bd5f3b7 in mainline for kernel/generic


Ignore:
Timestamp:
2011-08-21T13:07:35Z (14 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
00aece0, f1a9e87
Parents:
86a34d3e (diff), a6480d5 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

Location:
kernel/generic
Files:
1 added
32 edited

Legend:

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

    r86a34d3e rbd5f3b7  
    6363
    6464extern void klog_init(void);
    65 extern void klog_update(void);
     65extern void klog_update(void *);
    6666
    6767extern wchar_t getc(indev_t *indev);
  • kernel/generic/include/ddi/ddi.h

    r86a34d3e rbd5f3b7  
    3636#define KERN_DDI_H_
    3737
    38 #include <ddi/ddi_arg.h>
    3938#include <typedefs.h>
     39#include <abi/ddi/arg.h>
    4040#include <proc/task.h>
    4141#include <adt/list.h>
  • kernel/generic/include/ddi/irq.h

    r86a34d3e rbd5f3b7  
    3333 */
    3434
    35 #ifndef KERN_IRQ_H_
    36 #define KERN_IRQ_H_
    37 
    38 #ifdef KERNEL
     35#ifndef KERN_DDI_IRQ_H_
     36#define KERN_DDI_IRQ_H_
    3937
    4038#include <typedefs.h>
     39#include <abi/ddi/irq.h>
    4140#include <adt/list.h>
    4241#include <adt/hash_table.h>
     
    4443#include <proc/task.h>
    4544#include <ipc/ipc.h>
    46 
    47 #endif /* KERNEL */
    48 
    49 typedef enum {
    50         /** Read 1 byte from the I/O space. */
    51         CMD_PIO_READ_8 = 1,
    52         /** Read 2 bytes from the I/O space. */
    53         CMD_PIO_READ_16,
    54         /** Read 4 bytes from the I/O space. */
    55         CMD_PIO_READ_32,
    56        
    57         /** Write 1 byte to the I/O space. */
    58         CMD_PIO_WRITE_8,
    59         /** Write 2 bytes to the I/O space. */
    60         CMD_PIO_WRITE_16,
    61         /** Write 4 bytes to the I/O space. */
    62         CMD_PIO_WRITE_32,
    63        
    64         /**
    65          * Write 1 byte from the source argument
    66          * to the I/O space.
    67          */
    68         CMD_PIO_WRITE_A_8,
    69         /**
    70          * Write 2 bytes from the source argument
    71          * to the I/O space.
    72          */
    73         CMD_PIO_WRITE_A_16,
    74         /**
    75          * Write 4 bytes from the source argument
    76          * to the I/O space.
    77          */
    78         CMD_PIO_WRITE_A_32,
    79 
    80         /** Read 1 byte from the memory space. */
    81         CMD_MEM_READ_8,
    82         /** Read 2 bytes from the memory space. */
    83         CMD_MEM_READ_16,
    84         /** Read 4 bytes from the memory space. */
    85         CMD_MEM_READ_32,
    86 
    87         /** Write 1 byte to the memory space. */
    88         CMD_MEM_WRITE_8,
    89         /** Write 2 bytes to the memory space. */
    90         CMD_MEM_WRITE_16,
    91         /** Write 4 bytes to the memory space. */
    92         CMD_MEM_WRITE_32,
    93 
    94         /** Write 1 byte from the source argument to the memory space. */
    95         CMD_MEM_WRITE_A_8,
    96         /** Write 2 bytes from the source argument to the memory space. */
    97         CMD_MEM_WRITE_A_16,
    98         /** Write 4 bytes from the source argument to the memory space. */
    99         CMD_MEM_WRITE_A_32,
    100 
    101         /**
    102          * Perform a bit masking on the source argument
    103          * and store the result into the destination argument.
    104          */
    105         CMD_BTEST,
    106        
    107         /**
    108          * Predicate the execution of the following
    109          * N commands by the boolean value of the source
    110          * argument.
    111          */
    112         CMD_PREDICATE,
    113        
    114         /** Accept the interrupt. */
    115         CMD_ACCEPT,
    116        
    117         /** Decline the interrupt. */
    118         CMD_DECLINE,
    119         CMD_LAST
    120 } irq_cmd_type;
    121 
    122 typedef struct {
    123         irq_cmd_type cmd;
    124         void *addr;
    125         uint32_t value;
    126         uintptr_t srcarg;
    127         uintptr_t dstarg;
    128 } irq_cmd_t;
    129 
    130 typedef struct {
    131         size_t cmdcount;
    132         irq_cmd_t *cmds;
    133 } irq_code_t;
    134 
    135 #ifdef KERNEL
    13645
    13746typedef enum {
     
    14655
    14756struct irq;
     57
    14858typedef void (* irq_handler_t)(struct irq *);
    14959
     
    224134        /** Notification configuration structure. */
    225135        ipc_notif_cfg_t notif_cfg;
    226 
     136       
    227137        as_t *driver_as;
    228138} irq_t;
     
    238148extern irq_t *irq_dispatch_and_lock(inr_t);
    239149
    240 #endif /* KERNEL */
    241 
    242150#endif
    243151
  • kernel/generic/include/errno.h

    r86a34d3e rbd5f3b7  
    2727 */
    2828
    29 /** @addtogroup generic 
     29/** @addtogroup generic
    3030 * @{
    3131 */
     
    3636#define KERN_ERRNO_H_
    3737
    38 /* 1-255 are kernel error codes, 256-512 are user error codes */
    39 
    40 #define EOK             0       /* No error */
    41 #define ENOENT          -1      /* No such entry */
    42 #define ENOMEM          -2      /* Not enough memory */
    43 #define ELIMIT          -3      /* Limit exceeded */
    44 #define EREFUSED        -4      /* Connection refused */
    45 #define EFORWARD        -5      /* Forward error */
    46 #define EPERM           -6      /* Permission denied */
    47 #define EHANGUP         -7      /* Answerbox closed connection, call
    48                                  * sys_ipc_hangup() to close the connection.
    49                                  * Used by answerbox to close the connection.
    50                                  */
    51 #define EPARTY          -8      /* The other party encountered an error when
    52                                  * receiving the call.
    53                                  */
    54 #define EEXISTS         -9      /* Entry already exists */
    55 #define EBADMEM         -10     /* Bad memory pointer */
    56 #define ENOTSUP         -11     /* Not supported */
    57 #define EADDRNOTAVAIL   -12     /* Address not available. */
    58 #define ETIMEOUT        -13     /* Timeout expired */
    59 #define EINVAL          -14     /* Invalid value */
    60 #define EBUSY           -15     /* Resource is busy */
    61 #define EOVERFLOW       -16     /* The result does not fit its size. */
    62 #define EINTR           -17     /* Operation was interrupted. */
     38#include <abi/errno.h>
    6339
    6440#endif
  • kernel/generic/include/ipc/event.h

    r86a34d3e rbd5f3b7  
    3636#define KERN_EVENT_H_
    3737
    38 #include <ipc/event_types.h>
     38#include <abi/ipc/event.h>
    3939#include <typedefs.h>
    4040#include <synch/spinlock.h>
    4141#include <ipc/ipc.h>
    4242
    43 typedef void (*event_callback_t)(void);
     43struct task;
     44
     45typedef void (*event_callback_t)(void *);
    4446
    4547/** Event notification structure. */
     
    6163
    6264extern void event_init(void);
     65extern void event_task_init(struct task *);
    6366extern void event_cleanup_answerbox(answerbox_t *);
    6467extern void event_set_unmask_callback(event_type_t, event_callback_t);
     68extern void event_task_set_unmask_callback(struct task *, event_task_type_t,
     69    event_callback_t);
    6570
    6671#define event_notify_0(e, m) \
     
    7782        event_notify((e), (m), (a1), (a2), (a3), (a4), (a5))
    7883
     84#define event_task_notify_0(t, e, m) \
     85        event_task_notify((t), (e), (m), 0, 0, 0, 0, 0)
     86#define event_task_notify_1(t, e, m, a1) \
     87        event_task_notify((t), (e), (m), (a1), 0, 0, 0, 0)
     88#define event_task_notify_2(t, e, m, a1, a2) \
     89        event_task_notify((t), (e), (m), (a1), (a2), 0, 0, 0)
     90#define event_task_notify_3(t, e, m, a1, a2, a3) \
     91        event_task_notify((t), (e), (m), (a1), (a2), (a3), 0, 0)
     92#define event_task_notify_4(t, e, m, a1, a2, a3, a4) \
     93        event_task_notify((t), (e), (m), (a1), (a2), (a3), (a4), 0)
     94#define event_task_notify_5(t, e, m, a1, a2, a3, a4, a5) \
     95        event_task_notify((t), (e), (m), (a1), (a2), (a3), (a4), (a5))
     96
    7997extern int event_notify(event_type_t, bool, sysarg_t, sysarg_t, sysarg_t,
    8098    sysarg_t, sysarg_t);
     99extern int event_task_notify(struct task *, event_task_type_t, bool, sysarg_t, sysarg_t,
     100    sysarg_t, sysarg_t, sysarg_t);
    81101
    82102extern sysarg_t sys_event_subscribe(sysarg_t, sysarg_t);
  • kernel/generic/include/ipc/ipc.h

    r86a34d3e rbd5f3b7  
    3636#define KERN_IPC_H_
    3737
    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
    44 
    45 /** Maximum active async calls per phone */
    46 #define IPC_MAX_ASYNC_CALLS  4
    47 
    48 /* Flags for calls */
    49 
    50 /** This is answer to a call */
    51 #define IPC_CALL_ANSWERED  (1 << 0)
    52 
    53 /** Answer will not be passed to userspace, will be discarded */
    54 #define IPC_CALL_DISCARD_ANSWER  (1 << 1)
    55 
    56 /** Call was forwarded */
    57 #define IPC_CALL_FORWARDED  (1 << 2)
    58 
    59 /** Identify connect_me_to answer */
    60 #define IPC_CALL_CONN_ME_TO  (1 << 3)
    61 
    62 /** Interrupt notification */
    63 #define IPC_CALL_NOTIF  (1 << 4)
    64 
    65 
    66 /** Bits used in call hashes.
    67  *
    68  * The addresses are aligned at least to 4 that is why we can use the 2 least
    69  * significant bits of the call address.
    70  *
    71  */
    72 
    73 /** Type of this call is 'answer' */
    74 #define IPC_CALLID_ANSWERED  1
    75 
    76 /** Type of this call is 'notification' */
    77 #define IPC_CALLID_NOTIFICATION  2
    78 
    79 /* Return values from sys_ipc_call_async(). */
    80 #define IPC_CALLRET_FATAL      -1
    81 #define IPC_CALLRET_TEMPORARY  -2
    82 
    83 
    84 /* Macros for manipulating calling data */
    85 #define IPC_SET_RETVAL(data, retval)  ((data).args[0] = (retval))
    86 #define IPC_SET_IMETHOD(data, val)    ((data).args[0] = (val))
    87 #define IPC_SET_ARG1(data, val)       ((data).args[1] = (val))
    88 #define IPC_SET_ARG2(data, val)       ((data).args[2] = (val))
    89 #define IPC_SET_ARG3(data, val)       ((data).args[3] = (val))
    90 #define IPC_SET_ARG4(data, val)       ((data).args[4] = (val))
    91 #define IPC_SET_ARG5(data, val)       ((data).args[5] = (val))
    92 
    93 #define IPC_GET_IMETHOD(data)  ((data).args[0])
    94 #define IPC_GET_RETVAL(data)   ((data).args[0])
    95 
    96 #define IPC_GET_ARG1(data)  ((data).args[1])
    97 #define IPC_GET_ARG2(data)  ((data).args[2])
    98 #define IPC_GET_ARG3(data)  ((data).args[3])
    99 #define IPC_GET_ARG4(data)  ((data).args[4])
    100 #define IPC_GET_ARG5(data)  ((data).args[5])
    101 
    102 /* Forwarding flags. */
    103 #define IPC_FF_NONE  0
    104 
    105 /**
    106  * The call will be routed as though it was initially sent via the phone used to
    107  * forward it. This feature is intended to support the situation in which the
    108  * forwarded call needs to be handled by the same connection fibril as any other
    109  * calls that were initially sent by the forwarder to the same destination. This
    110  * flag has no imapct on routing replies.
    111  *
    112  */
    113 #define IPC_FF_ROUTE_FROM_ME  (1 << 0)
    114 
    115 /* Data transfer flags. */
    116 #define IPC_XF_NONE  0
    117 
    118 /** Restrict the transfer size if necessary. */
    119 #define IPC_XF_RESTRICT  (1 << 0)
    120 
    121 /** User-defined IPC methods */
    122 #define IPC_FIRST_USER_METHOD  1024
    123 
    124 #ifdef KERNEL
    125 
    126 #define IPC_MAX_PHONES  32
    127 
     38#include <abi/ipc/ipc.h>
    12839#include <synch/spinlock.h>
    12940#include <synch/mutex.h>
    13041#include <synch/waitq.h>
     42#include <typedefs.h>
     43
     44#define IPC_MAX_PHONES  32
    13145
    13246struct answerbox;
     
    18498typedef struct {
    18599        sysarg_t args[IPC_CALL_LEN];
    186         /** Task which made or forwarded the call with IPC_FF_ROUTE_FROM_ME. */
    187         struct task *task;
     100        /**
     101         * Task which made or forwarded the call with IPC_FF_ROUTE_FROM_ME,
     102         * or the task which answered the call.
     103         */
     104        task_id_t task_id;
    188105        /** Phone which made or last masqueraded this call. */
    189106        phone_t *phone;
     
    247164extern void ipc_print_task(task_id_t);
    248165
    249 #endif /* KERNEL */
    250 
    251166#endif
    252167
  • kernel/generic/include/lib/elf.h

    r86a34d3e rbd5f3b7  
    3636#define KERN_ELF_H_
    3737
     38#include <typedefs.h>
     39#include <abi/elf.h>
    3840#include <arch/elf.h>
    39 #include <typedefs.h>
    40 
    41 /**
    42  * current ELF version
    43  */
    44 #define EV_CURRENT  1
    45 
    46 /**
    47  * ELF types
    48  */
    49 #define ET_NONE    0       /* No type */
    50 #define ET_REL     1       /* Relocatable file */
    51 #define ET_EXEC    2       /* Executable */
    52 #define ET_DYN     3       /* Shared object */
    53 #define ET_CORE    4       /* Core */
    54 #define ET_LOPROC  0xff00  /* Processor specific */
    55 #define ET_HIPROC  0xffff  /* Processor specific */
    56 
    57 /**
    58  * ELF machine types
    59  */
    60 #define EM_NO           0   /* No machine */
    61 #define EM_SPARC        2   /* SPARC */
    62 #define EM_386          3   /* i386 */
    63 #define EM_MIPS         8   /* MIPS RS3000 */
    64 #define EM_MIPS_RS3_LE  10  /* MIPS RS3000 LE */
    65 #define EM_PPC          20  /* PPC32 */
    66 #define EM_PPC64        21  /* PPC64 */
    67 #define EM_ARM          40  /* ARM */
    68 #define EM_SPARCV9      43  /* SPARC64 */
    69 #define EM_IA_64        50  /* IA-64 */
    70 #define EM_X86_64       62  /* AMD64/EMT64 */
    71 
    72 /**
    73  * ELF identification indexes
    74  */
    75 #define EI_MAG0        0
    76 #define EI_MAG1        1
    77 #define EI_MAG2        2
    78 #define EI_MAG3        3
    79 #define EI_CLASS       4   /* File class */
    80 #define EI_DATA        5   /* Data encoding */
    81 #define EI_VERSION     6   /* File version */
    82 #define EI_OSABI       7
    83 #define EI_ABIVERSION  8
    84 #define EI_PAD         9   /* Start of padding bytes */
    85 #define EI_NIDENT      16  /* ELF identification table size */
    86 
    87 /**
    88  * ELF magic number
    89  */
    90 #define ELFMAG0  0x7f
    91 #define ELFMAG1  'E'
    92 #define ELFMAG2  'L'
    93 #define ELFMAG3  'F'
    94 
    95 /**
    96  * ELF file classes
    97  */
    98 #define ELFCLASSNONE  0
    99 #define ELFCLASS32    1
    100 #define ELFCLASS64    2
    101 
    102 /**
    103  * ELF data encoding types
    104  */
    105 #define ELFDATANONE  0
    106 #define ELFDATA2LSB  1  /* Least significant byte first (little endian) */
    107 #define ELFDATA2MSB  2  /* Most signigicant byte first (big endian) */
    108 
    109 /**
    110  * ELF error return codes
    111  */
    112 #define EE_OK             0  /* No error */
    113 #define EE_INVALID        1  /* Invalid ELF image */
    114 #define EE_MEMORY         2  /* Cannot allocate address space */
    115 #define EE_INCOMPATIBLE   3  /* ELF image is not compatible with current architecture */
    116 #define EE_UNSUPPORTED    4  /* Non-supported ELF (e.g. dynamic ELFs) */
    117 #define EE_LOADER         5  /* The image is actually a program loader */
    118 #define EE_IRRECOVERABLE  6
    119 
    120 /**
    121  * ELF section types
    122  */
    123 #define SHT_NULL      0
    124 #define SHT_PROGBITS  1
    125 #define SHT_SYMTAB    2
    126 #define SHT_STRTAB    3
    127 #define SHT_RELA      4
    128 #define SHT_HASH      5
    129 #define SHT_DYNAMIC   6
    130 #define SHT_NOTE      7
    131 #define SHT_NOBITS    8
    132 #define SHT_REL       9
    133 #define SHT_SHLIB     10
    134 #define SHT_DYNSYM    11
    135 #define SHT_LOOS      0x60000000
    136 #define SHT_HIOS      0x6fffffff
    137 #define SHT_LOPROC    0x70000000
    138 #define SHT_HIPROC    0x7fffffff
    139 #define SHT_LOUSER    0x80000000
    140 #define SHT_HIUSER    0xffffffff
    141 
    142 /**
    143  * ELF section flags
    144  */
    145 #define SHF_WRITE      0x1
    146 #define SHF_ALLOC      0x2
    147 #define SHF_EXECINSTR  0x4
    148 #define SHF_TLS        0x400
    149 #define SHF_MASKPROC   0xf0000000
    150 
    151 /**
    152  * Symbol binding
    153  */
    154 #define STB_LOCAL   0
    155 #define STB_GLOBAL  1
    156 #define STB_WEAK    2
    157 #define STB_LOPROC  13
    158 #define STB_HIPROC  15
    159 
    160 /**
    161  * Symbol types
    162  */
    163 #define STT_NOTYPE   0
    164 #define STT_OBJECT   1
    165 #define STT_FUNC     2
    166 #define STT_SECTION  3
    167 #define STT_FILE     4
    168 #define STT_LOPROC   13
    169 #define STT_HIPROC   15
    170 
    171 /**
    172  * Program segment types
    173  */
    174 #define PT_NULL     0
    175 #define PT_LOAD     1
    176 #define PT_DYNAMIC  2
    177 #define PT_INTERP   3
    178 #define PT_NOTE     4
    179 #define PT_SHLIB    5
    180 #define PT_PHDR     6
    181 #define PT_LOPROC   0x70000000
    182 #define PT_HIPROC   0x7fffffff
    183 
    184 /**
    185  * Program segment attributes.
    186  */
    187 #define PF_X  1
    188 #define PF_W  2
    189 #define PF_R  4
    190 
    191 /**
    192  * ELF data types
    193  *
    194  * These types are found to be identical in both 32-bit and 64-bit
    195  * ELF object file specifications. They are the only types used
    196  * in ELF header.
    197  *
    198  */
    199 typedef uint64_t elf_xword;
    200 typedef int64_t elf_sxword;
    201 typedef uint32_t elf_word;
    202 typedef int32_t elf_sword;
    203 typedef uint16_t elf_half;
    204 
    205 /**
    206  * 32-bit ELF data types.
    207  *
    208  * These types are specific for 32-bit format.
    209  *
    210  */
    211 typedef uint32_t elf32_addr;
    212 typedef uint32_t elf32_off;
    213 
    214 /**
    215  * 64-bit ELF data types.
    216  *
    217  * These types are specific for 64-bit format.
    218  *
    219  */
    220 typedef uint64_t elf64_addr;
    221 typedef uint64_t elf64_off;
    222 
    223 /** ELF header */
    224 struct elf32_header {
    225         uint8_t e_ident[EI_NIDENT];
    226         elf_half e_type;
    227         elf_half e_machine;
    228         elf_word e_version;
    229         elf32_addr e_entry;
    230         elf32_off e_phoff;
    231         elf32_off e_shoff;
    232         elf_word e_flags;
    233         elf_half e_ehsize;
    234         elf_half e_phentsize;
    235         elf_half e_phnum;
    236         elf_half e_shentsize;
    237         elf_half e_shnum;
    238         elf_half e_shstrndx;
    239 };
    240 
    241 struct elf64_header {
    242         uint8_t e_ident[EI_NIDENT];
    243         elf_half e_type;
    244         elf_half e_machine;
    245         elf_word e_version;
    246         elf64_addr e_entry;
    247         elf64_off e_phoff;
    248         elf64_off e_shoff;
    249         elf_word e_flags;
    250         elf_half e_ehsize;
    251         elf_half e_phentsize;
    252         elf_half e_phnum;
    253         elf_half e_shentsize;
    254         elf_half e_shnum;
    255         elf_half e_shstrndx;
    256 };
    257 
    258 /**
    259  * ELF segment header.
    260  * Segments headers are also known as program headers.
    261  */
    262 struct elf32_segment_header {
    263         elf_word p_type;
    264         elf32_off p_offset;
    265         elf32_addr p_vaddr;
    266         elf32_addr p_paddr;
    267         elf_word p_filesz;
    268         elf_word p_memsz;
    269         elf_word p_flags;
    270         elf_word p_align;
    271 };
    272 
    273 struct elf64_segment_header {
    274         elf_word p_type;
    275         elf_word p_flags;
    276         elf64_off p_offset;
    277         elf64_addr p_vaddr;
    278         elf64_addr p_paddr;
    279         elf_xword p_filesz;
    280         elf_xword p_memsz;
    281         elf_xword p_align;
    282 };
    283 
    284 /**
    285  * ELF section header
    286  */
    287 struct elf32_section_header {
    288         elf_word sh_name;
    289         elf_word sh_type;
    290         elf_word sh_flags;
    291         elf32_addr sh_addr;
    292         elf32_off sh_offset;
    293         elf_word sh_size;
    294         elf_word sh_link;
    295         elf_word sh_info;
    296         elf_word sh_addralign;
    297         elf_word sh_entsize;
    298 };
    299 
    300 struct elf64_section_header {
    301         elf_word sh_name;
    302         elf_word sh_type;
    303         elf_xword sh_flags;
    304         elf64_addr sh_addr;
    305         elf64_off sh_offset;
    306         elf_xword sh_size;
    307         elf_word sh_link;
    308         elf_word sh_info;
    309         elf_xword sh_addralign;
    310         elf_xword sh_entsize;
    311 };
    312 
    313 /**
    314  * ELF symbol table entry
    315  */
    316 struct elf32_symbol {
    317         elf_word st_name;
    318         elf32_addr st_value;
    319         elf_word st_size;
    320         uint8_t st_info;
    321         uint8_t st_other;
    322         elf_half st_shndx;
    323 };
    324 
    325 struct elf64_symbol {
    326         elf_word st_name;
    327         uint8_t st_info;
    328         uint8_t st_other;
    329         elf_half st_shndx;
    330         elf64_addr st_value;
    331         elf_xword st_size;
    332 };
    333 
    334 #ifdef __32_BITS__
    335 typedef struct elf32_header elf_header_t;
    336 typedef struct elf32_segment_header elf_segment_header_t;
    337 typedef struct elf32_section_header elf_section_header_t;
    338 typedef struct elf32_symbol elf_symbol_t;
    339 #endif
    340 
    341 #ifdef __64_BITS__
    342 typedef struct elf64_header elf_header_t;
    343 typedef struct elf64_segment_header elf_segment_header_t;
    344 typedef struct elf64_section_header elf_section_header_t;
    345 typedef struct elf64_symbol elf_symbol_t;
    346 #endif
    347 
    348 extern const char *elf_error(unsigned int rc);
    34941
    35042/** Interpreter string used to recognize the program loader */
  • kernel/generic/include/mm/as.h

    r86a34d3e rbd5f3b7  
    3636#define KERN_AS_H_
    3737
    38 #ifdef KERNEL
    39         #include <typedefs.h>
    40 #else
    41         #include <sys/types.h>
    42 #endif
    43 
    44 /** 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
    49 
    50 /** Address space area info exported to userspace. */
    51 typedef struct {
    52         /** Starting address */
    53         uintptr_t start_addr;
    54        
    55         /** Area size */
    56         size_t size;
    57        
    58         /** Area flags */
    59         unsigned int flags;
    60 } as_area_info_t;
    61 
    62 #ifdef KERNEL
    63 
     38#include <typedefs.h>
     39#include <abi/mm/as.h>
    6440#include <arch/mm/page.h>
    6541#include <arch/mm/as.h>
     
    307283extern mem_backend_t phys_backend;
    308284
    309 /**
    310  * This flags is passed when running the loader, otherwise elf_load()
    311  * would return with a EE_LOADER error code.
    312  *
    313  */
    314 #define ELD_F_NONE    0
    315 #define ELD_F_LOADER  1
    316 
    317 extern unsigned int elf_load(elf_header_t *, as_t *, unsigned int);
    318 
    319285/* Address space area related syscalls. */
    320286extern sysarg_t sys_as_area_create(uintptr_t, size_t, unsigned int);
     
    328294extern void as_print(as_t *);
    329295
    330 #endif /* KERNEL */
    331 
    332296#endif
    333297
  • kernel/generic/include/proc/task.h

    r86a34d3e rbd5f3b7  
    3838#include <cpu.h>
    3939#include <ipc/ipc.h>
     40#include <ipc/event.h>
     41#include <ipc/kbox.h>
    4042#include <synch/spinlock.h>
    4143#include <synch/mutex.h>
     
    5355#include <proc/scheduler.h>
    5456#include <udebug/udebug.h>
    55 #include <ipc/kbox.h>
    5657#include <mm/as.h>
    57 #include <sysinfo/abi.h>
     58#include <abi/sysinfo.h>
    5859
    5960struct thread;
     
    9394        phone_t phones[IPC_MAX_PHONES];
    9495        stats_ipc_t ipc_info;   /**< IPC statistics */
    95         /** List of synchronous answerboxes. */
    96         list_t sync_boxes;
     96        list_t sync_boxes;      /**< List of synchronous answerboxes. */
     97        event_t events[EVENT_TASK_END - EVENT_END];
    9798       
    9899#ifdef CONFIG_UDEBUG
  • kernel/generic/include/proc/thread.h

    r86a34d3e rbd5f3b7  
    4545#include <arch/cpu.h>
    4646#include <mm/tlb.h>
    47 #include <proc/uarg.h>
     47#include <abi/proc/uarg.h>
    4848#include <udebug/udebug.h>
    49 #include <sysinfo/abi.h>
     49#include <abi/sysinfo.h>
    5050
    5151#define THREAD_NAME_BUFLEN  20
  • kernel/generic/include/synch/condvar.h

    r86a34d3e rbd5f3b7  
    3939#include <synch/waitq.h>
    4040#include <synch/mutex.h>
    41 #include <synch/synch.h>
     41#include <abi/synch.h>
    4242
    4343typedef struct {
  • kernel/generic/include/synch/mutex.h

    r86a34d3e rbd5f3b7  
    3838#include <typedefs.h>
    3939#include <synch/semaphore.h>
    40 #include <synch/synch.h>
     40#include <abi/synch.h>
    4141
    4242typedef enum {
  • kernel/generic/include/synch/semaphore.h

    r86a34d3e rbd5f3b7  
    3838#include <typedefs.h>
    3939#include <synch/waitq.h>
    40 #include <synch/synch.h>
     40#include <abi/synch.h>
    4141
    4242typedef struct {
  • kernel/generic/include/synch/waitq.h

    r86a34d3e rbd5f3b7  
    3838#include <typedefs.h>
    3939#include <synch/spinlock.h>
    40 #include <synch/synch.h>
     40#include <abi/synch.h>
    4141#include <adt/list.h>
    4242
  • kernel/generic/include/syscall/syscall.h

    r86a34d3e rbd5f3b7  
    3636#define KERN_SYSCALL_H_
    3737
    38 typedef enum {
    39         SYS_KLOG = 0,
    40         SYS_TLS_SET = 1,  /* Hardcoded for AMD64, IA-32 (fibril.S in uspace) */
    41        
    42         SYS_THREAD_CREATE,
    43         SYS_THREAD_EXIT,
    44         SYS_THREAD_GET_ID,
    45         SYS_THREAD_USLEEP,
    46         SYS_THREAD_UDELAY,
    47        
    48         SYS_TASK_GET_ID,
    49         SYS_TASK_SET_NAME,
    50         SYS_TASK_KILL,
    51         SYS_TASK_EXIT,
    52         SYS_PROGRAM_SPAWN_LOADER,
    53        
    54         SYS_FUTEX_SLEEP,
    55         SYS_FUTEX_WAKEUP,
    56         SYS_SMC_COHERENCE,
    57        
    58         SYS_AS_AREA_CREATE,
    59         SYS_AS_AREA_RESIZE,
    60         SYS_AS_AREA_CHANGE_FLAGS,
    61         SYS_AS_AREA_DESTROY,
    62         SYS_AS_GET_UNMAPPED_AREA,
    63        
    64         SYS_PAGE_FIND_MAPPING,
    65        
    66         SYS_IPC_CALL_SYNC_FAST,
    67         SYS_IPC_CALL_SYNC_SLOW,
    68         SYS_IPC_CALL_ASYNC_FAST,
    69         SYS_IPC_CALL_ASYNC_SLOW,
    70         SYS_IPC_ANSWER_FAST,
    71         SYS_IPC_ANSWER_SLOW,
    72         SYS_IPC_FORWARD_FAST,
    73         SYS_IPC_FORWARD_SLOW,
    74         SYS_IPC_WAIT,
    75         SYS_IPC_POKE,
    76         SYS_IPC_HANGUP,
    77         SYS_IPC_CONNECT_KBOX,
    78        
    79         SYS_EVENT_SUBSCRIBE,
    80         SYS_EVENT_UNMASK,
    81        
    82         SYS_CAP_GRANT,
    83         SYS_CAP_REVOKE,
    84        
    85         SYS_DEVICE_ASSIGN_DEVNO,
    86         SYS_PHYSMEM_MAP,
    87         SYS_IOSPACE_ENABLE,
    88         SYS_REGISTER_IRQ,
    89         SYS_UNREGISTER_IRQ,
    90        
    91         SYS_SYSINFO_GET_TAG,
    92         SYS_SYSINFO_GET_VALUE,
    93         SYS_SYSINFO_GET_DATA_SIZE,
    94         SYS_SYSINFO_GET_DATA,
    95        
    96         SYS_DEBUG_ACTIVATE_CONSOLE,
    97        
    98         SYSCALL_END
    99 } syscall_t;
    100 
    101 #ifdef KERNEL
    102 
    10338#include <typedefs.h>
     39#include <abi/syscall.h>
    10440
    10541typedef sysarg_t (*syshandler_t)(sysarg_t, sysarg_t, sysarg_t, sysarg_t,
     
    11349#endif
    11450
    115 #endif
    116 
    11751/** @}
    11852 */
  • kernel/generic/include/udebug/udebug.h

    r86a34d3e rbd5f3b7  
    3636#define KERN_UDEBUG_H_
    3737
    38 #define UDEBUG_EVMASK(event)  (1 << ((event) - 1))
    39 
    40 typedef enum { /* udebug_method_t */
    41        
    42         /** Start debugging the recipient.
    43          *
    44          * Causes all threads in the receiving task to stop. When they
    45          * are all stoped, an answer with retval 0 is generated.
    46          *
    47          */
    48         UDEBUG_M_BEGIN = 1,
    49        
    50         /** Finish debugging the recipient.
    51          *
    52          * Answers all pending GO and GUARD messages.
    53          *
    54          */
    55         UDEBUG_M_END,
    56        
    57         /** Set which events should be captured. */
    58         UDEBUG_M_SET_EVMASK,
    59        
    60         /** Make sure the debugged task is still there.
    61          *
    62          * This message is answered when the debugged task dies
    63          * or the debugging session ends.
    64          *
    65          */
    66         UDEBUG_M_GUARD,
    67        
    68         /** Run a thread until a debugging event occurs.
    69          *
    70          * This message is answered when the thread stops
    71          * in a debugging event.
    72          *
    73          * - ARG2 - id of the thread to run
    74          *
    75          */
    76         UDEBUG_M_GO,
    77        
    78         /** Stop a thread being debugged.
    79          *
    80          * Creates a special STOP event in the thread, causing
    81          * it to answer a pending GO message (if any).
    82          *
    83          */
    84         UDEBUG_M_STOP,
    85        
    86         /** Read arguments of a syscall.
    87          *
    88          * - ARG2 - thread identification
    89          * - ARG3 - destination address in the caller's address space
    90          *
    91          */
    92         UDEBUG_M_ARGS_READ,
    93        
    94         /** Read thread's userspace register state (istate_t).
    95          *
    96          * - ARG2 - thread identification
    97          * - ARG3 - destination address in the caller's address space
    98          *
    99          * or, on error, retval will be
    100          * - ENOENT - thread does not exist
    101          * - EBUSY - register state not available
    102          */
    103         UDEBUG_M_REGS_READ,
    104        
    105         /** Read the list of the debugged tasks's threads.
    106          *
    107          * - ARG2 - destination address in the caller's address space
    108          * - ARG3 - size of receiving buffer in bytes
    109          *
    110          * The kernel fills the buffer with a series of sysarg_t values
    111          * (thread ids). On answer, the kernel will set:
    112          *
    113          * - ARG2 - number of bytes that were actually copied
    114          * - ARG3 - number of bytes of the complete data
    115          *
    116          */
    117         UDEBUG_M_THREAD_READ,
    118        
    119         /** Read the name of the debugged task.
    120          *
    121          * - ARG2 - destination address in the caller's address space
    122          * - ARG3 - size of receiving buffer in bytes
    123          *
    124          * The kernel fills the buffer with a non-terminated string.
    125          *
    126          * - ARG2 - number of bytes that were actually copied
    127          * - ARG3 - number of bytes of the complete data
    128          *
    129          */
    130         UDEBUG_M_NAME_READ,
    131        
    132         /** Read the list of the debugged task's address space areas.
    133          *
    134          * - ARG2 - destination address in the caller's address space
    135          * - ARG3 - size of receiving buffer in bytes
    136          *
    137          * The kernel fills the buffer with a series of as_area_info_t structures.
    138          * Upon answer, the kernel will set:
    139          *
    140          * - ARG2 - number of bytes that were actually copied
    141          * - ARG3 - number of bytes of the complete data
    142          *
    143          */
    144         UDEBUG_M_AREAS_READ,
    145        
    146         /** Read the debugged tasks's memory.
    147          *
    148          * - ARG2 - destination address in the caller's address space
    149          * - ARG3 - source address in the recipient's address space
    150          * - ARG4 - size of receiving buffer in bytes
    151          *
    152          */
    153         UDEBUG_M_MEM_READ
    154 } udebug_method_t;
    155 
    156 typedef enum {
    157         UDEBUG_EVENT_FINISHED = 1,  /**< Debuging session has finished */
    158         UDEBUG_EVENT_STOP,          /**< Stopped on DEBUG_STOP request */
    159         UDEBUG_EVENT_SYSCALL_B,     /**< Before beginning syscall execution */
    160         UDEBUG_EVENT_SYSCALL_E,     /**< After finishing syscall execution */
    161         UDEBUG_EVENT_THREAD_B,      /**< The task created a new thread */
    162         UDEBUG_EVENT_THREAD_E       /**< A thread exited */
    163 } udebug_event_t;
    164 
    165 typedef enum {
    166         UDEBUG_EM_FINISHED = UDEBUG_EVMASK(UDEBUG_EVENT_FINISHED),
    167         UDEBUG_EM_STOP = UDEBUG_EVMASK(UDEBUG_EVENT_STOP),
    168         UDEBUG_EM_SYSCALL_B = UDEBUG_EVMASK(UDEBUG_EVENT_SYSCALL_B),
    169         UDEBUG_EM_SYSCALL_E = UDEBUG_EVMASK(UDEBUG_EVENT_SYSCALL_E),
    170         UDEBUG_EM_THREAD_B = UDEBUG_EVMASK(UDEBUG_EVENT_THREAD_B),
    171         UDEBUG_EM_THREAD_E = UDEBUG_EVMASK(UDEBUG_EVENT_THREAD_E),
    172         UDEBUG_EM_ALL =
    173             (UDEBUG_EVMASK(UDEBUG_EVENT_FINISHED) |
    174             UDEBUG_EVMASK(UDEBUG_EVENT_STOP) |
    175             UDEBUG_EVMASK(UDEBUG_EVENT_SYSCALL_B) |
    176             UDEBUG_EVMASK(UDEBUG_EVENT_SYSCALL_E) |
    177             UDEBUG_EVMASK(UDEBUG_EVENT_THREAD_B) |
    178             UDEBUG_EVMASK(UDEBUG_EVENT_THREAD_E))
    179 } udebug_evmask_t;
    180 
    181 #ifdef KERNEL
    182 
     38#include <abi/udebug.h>
    18339#include <ipc/ipc.h>
    18440#include <synch/mutex.h>
     
    251107#endif
    252108
    253 #endif
    254 
    255109/** @}
    256110 */
  • kernel/generic/src/console/console.c

    r86a34d3e rbd5f3b7  
    248248}
    249249
    250 void klog_update(void)
     250void klog_update(void *event)
    251251{
    252252        if (!atomic_get(&klog_inited))
     
    327327        /* Force notification on newline */
    328328        if (ch == '\n')
    329                 klog_update();
     329                klog_update(NULL);
    330330}
    331331
     
    358358                free(data);
    359359        } else
    360                 klog_update();
     360                klog_update(NULL);
    361361       
    362362        return size;
  • kernel/generic/src/ddi/ddi.c

    r86a34d3e rbd5f3b7  
    4141
    4242#include <ddi/ddi.h>
    43 #include <ddi/ddi_arg.h>
    4443#include <proc/task.h>
    4544#include <security/cap.h>
  • kernel/generic/src/ipc/event.c

    r86a34d3e rbd5f3b7  
    3636
    3737#include <ipc/event.h>
    38 #include <ipc/event_types.h>
    3938#include <mm/slab.h>
    4039#include <typedefs.h>
    4140#include <synch/spinlock.h>
    4241#include <console/console.h>
     42#include <proc/task.h>
    4343#include <memstr.h>
    4444#include <errno.h>
     
    4848static event_t events[EVENT_END];
    4949
     50static void event_initialize(event_t *event)
     51{
     52        spinlock_initialize(&event->lock, "event.lock");
     53        event->answerbox = NULL;
     54        event->counter = 0;
     55        event->imethod = 0;
     56        event->masked = false;
     57        event->unmask_callback = NULL;
     58}
     59
     60static event_t *evno2event(int evno, task_t *t)
     61{
     62        ASSERT(evno < EVENT_TASK_END);
     63
     64        event_t *event;
     65
     66        if (evno < EVENT_END)
     67                event = &events[(event_type_t) evno];
     68        else
     69                event = &t->events[(event_task_type_t) evno - EVENT_END];
     70
     71        return event;
     72}
     73
    5074/** Initialize kernel events.
    5175 *
     
    5377void event_init(void)
    5478{
    55         for (unsigned int i = 0; i < EVENT_END; i++) {
    56                 spinlock_initialize(&events[i].lock, "event.lock");
    57                 events[i].answerbox = NULL;
    58                 events[i].counter = 0;
    59                 events[i].imethod = 0;
    60                 events[i].masked = false;
    61                 events[i].unmask_callback = NULL;
    62         }
    63 }
     79        for (unsigned int i = 0; i < EVENT_END; i++)
     80                event_initialize(evno2event(i, NULL));
     81}
     82
     83void event_task_init(task_t *task)
     84{
     85        for (unsigned int i = EVENT_END; i < EVENT_TASK_END; i++)
     86                event_initialize(evno2event(i, task));
     87}
     88
    6489
    6590/** Unsubscribe kernel events associated with an answerbox
     
    84109}
    85110
     111static void _event_set_unmask_callback(event_t *event, event_callback_t callback)
     112{
     113        spinlock_lock(&event->lock);
     114        event->unmask_callback = callback;
     115        spinlock_unlock(&event->lock);
     116}
     117
    86118/** Define a callback function for the event unmask event.
    87119 *
     
    95127        ASSERT(evno < EVENT_END);
    96128       
    97         spinlock_lock(&events[evno].lock);
    98         events[evno].unmask_callback = callback;
    99         spinlock_unlock(&events[evno].lock);
     129        _event_set_unmask_callback(evno2event(evno, NULL), callback);
     130}
     131
     132void event_task_set_unmask_callback(task_t *task, event_task_type_t evno,
     133    event_callback_t callback)
     134{
     135        ASSERT(evno >= (int) EVENT_END);
     136        ASSERT(evno < EVENT_TASK_END);
     137               
     138        _event_set_unmask_callback(evno2event(evno, task), callback);
     139}
     140
     141static int event_enqueue(event_t *event, bool mask, sysarg_t a1, sysarg_t a2,
     142    sysarg_t a3, sysarg_t a4, sysarg_t a5)
     143{
     144        int res;
     145
     146        spinlock_lock(&event->lock);
     147       
     148        if (event->answerbox != NULL) {
     149                if (!event->masked) {
     150                        call_t *call = ipc_call_alloc(FRAME_ATOMIC);
     151                       
     152                        if (call) {
     153                                call->flags |= IPC_CALL_NOTIF;
     154                                call->priv = ++event->counter;
     155                               
     156                                IPC_SET_IMETHOD(call->data, event->imethod);
     157                                IPC_SET_ARG1(call->data, a1);
     158                                IPC_SET_ARG2(call->data, a2);
     159                                IPC_SET_ARG3(call->data, a3);
     160                                IPC_SET_ARG4(call->data, a4);
     161                                IPC_SET_ARG5(call->data, a5);
     162                               
     163                                call->data.task_id = TASK ? TASK->taskid : 0;
     164                               
     165                                irq_spinlock_lock(&event->answerbox->irq_lock, true);
     166                                list_append(&call->link, &event->answerbox->irq_notifs);
     167                                irq_spinlock_unlock(&event->answerbox->irq_lock, true);
     168                               
     169                                waitq_wakeup(&event->answerbox->wq, WAKEUP_FIRST);
     170                               
     171                                if (mask)
     172                                        event->masked = true;
     173                               
     174                                res = EOK;
     175                        } else
     176                                res = ENOMEM;
     177                } else
     178                        res = EBUSY;
     179        } else
     180                res = ENOENT;
     181       
     182        spinlock_unlock(&event->lock);
     183        return res;
    100184}
    101185
     
    124208        ASSERT(evno < EVENT_END);
    125209       
    126         spinlock_lock(&events[evno].lock);
    127        
    128         int ret;
    129        
    130         if (events[evno].answerbox != NULL) {
    131                 if (!events[evno].masked) {
    132                         call_t *call = ipc_call_alloc(FRAME_ATOMIC);
    133                        
    134                         if (call) {
    135                                 call->flags |= IPC_CALL_NOTIF;
    136                                 call->priv = ++events[evno].counter;
    137                                
    138                                 IPC_SET_IMETHOD(call->data, events[evno].imethod);
    139                                 IPC_SET_ARG1(call->data, a1);
    140                                 IPC_SET_ARG2(call->data, a2);
    141                                 IPC_SET_ARG3(call->data, a3);
    142                                 IPC_SET_ARG4(call->data, a4);
    143                                 IPC_SET_ARG5(call->data, a5);
    144                                
    145                                 irq_spinlock_lock(&events[evno].answerbox->irq_lock, true);
    146                                 list_append(&call->link, &events[evno].answerbox->irq_notifs);
    147                                 irq_spinlock_unlock(&events[evno].answerbox->irq_lock, true);
    148                                
    149                                 waitq_wakeup(&events[evno].answerbox->wq, WAKEUP_FIRST);
    150                                
    151                                 if (mask)
    152                                         events[evno].masked = true;
    153                                
    154                                 ret = EOK;
    155                         } else
    156                                 ret = ENOMEM;
    157                 } else
    158                         ret = EBUSY;
    159         } else
    160                 ret = ENOENT;
    161        
    162         spinlock_unlock(&events[evno].lock);
    163        
    164         return ret;
     210        return event_enqueue(evno2event(evno, NULL), mask, a1, a2, a3, a4, a5);
     211}
     212
     213/** Send per-task kernel notification event
     214 *
     215 * @param task Destination task.
     216 * @param evno Event type.
     217 * @param mask Mask further notifications after a successful
     218 *             sending.
     219 * @param a1   First argument.
     220 * @param a2   Second argument.
     221 * @param a3   Third argument.
     222 * @param a4   Fourth argument.
     223 * @param a5   Fifth argument.
     224 *
     225 * @return EOK if notification was successfully sent.
     226 * @return ENOMEM if the notification IPC message failed to allocate.
     227 * @return EBUSY if the notifications of the given type are
     228 *         currently masked.
     229 * @return ENOENT if the notifications of the given type are
     230 *         currently not subscribed.
     231 *
     232 */
     233int event_task_notify(task_t *task, event_task_type_t evno, bool mask,
     234    sysarg_t a1, sysarg_t a2, sysarg_t a3, sysarg_t a4, sysarg_t a5)
     235{
     236        ASSERT(evno >= (int) EVENT_END);
     237        ASSERT(evno < EVENT_TASK_END);
     238       
     239        return event_enqueue(evno2event(evno, task), mask, a1, a2, a3, a4, a5);
    165240}
    166241
     
    177252 *
    178253 */
    179 static int event_subscribe(event_type_t evno, sysarg_t imethod,
     254static int event_subscribe(event_t *event, sysarg_t imethod,
    180255    answerbox_t *answerbox)
    181256{
    182         ASSERT(evno < EVENT_END);
    183        
    184         spinlock_lock(&events[evno].lock);
    185        
    186257        int res;
    187        
    188         if (events[evno].answerbox == NULL) {
    189                 events[evno].answerbox = answerbox;
    190                 events[evno].imethod = imethod;
    191                 events[evno].counter = 0;
    192                 events[evno].masked = false;
     258
     259        spinlock_lock(&event->lock);
     260       
     261        if (event->answerbox == NULL) {
     262                event->answerbox = answerbox;
     263                event->imethod = imethod;
     264                event->counter = 0;
     265                event->masked = false;
    193266                res = EOK;
    194267        } else
    195268                res = EEXISTS;
    196269       
    197         spinlock_unlock(&events[evno].lock);
     270        spinlock_unlock(&event->lock);
    198271       
    199272        return res;
     
    205278 *
    206279 */
    207 static void event_unmask(event_type_t evno)
    208 {
    209         ASSERT(evno < EVENT_END);
    210        
    211         spinlock_lock(&events[evno].lock);
    212         events[evno].masked = false;
    213         event_callback_t callback = events[evno].unmask_callback;
    214         spinlock_unlock(&events[evno].lock);
     280static void event_unmask(event_t *event)
     281{
     282        spinlock_lock(&event->lock);
     283        event->masked = false;
     284        event_callback_t callback = event->unmask_callback;
     285        spinlock_unlock(&event->lock);
    215286       
    216287        /*
     
    219290         */
    220291        if (callback != NULL)
    221                 callback();
     292                callback(event);
    222293}
    223294
     
    236307sysarg_t sys_event_subscribe(sysarg_t evno, sysarg_t imethod)
    237308{
    238         if (evno >= EVENT_END)
     309        if (evno >= EVENT_TASK_END)
    239310                return ELIMIT;
    240311       
    241         return (sysarg_t) event_subscribe((event_type_t) evno, (sysarg_t)
    242             imethod, &TASK->answerbox);
     312        return (sysarg_t) event_subscribe(evno2event(evno, TASK),
     313            (sysarg_t) imethod, &TASK->answerbox);
    243314}
    244315
     
    258329sysarg_t sys_event_unmask(sysarg_t evno)
    259330{
    260         if (evno >= EVENT_END)
     331        if (evno >= EVENT_TASK_END)
    261332                return ELIMIT;
    262333       
    263         event_unmask((event_type_t) evno);
     334        event_unmask(evno2event(evno, TASK));
     335
    264336        return EOK;
    265337}
  • kernel/generic/src/ipc/ipc.c

    r86a34d3e rbd5f3b7  
    3838 */
    3939
    40 #include <synch/synch.h>
    4140#include <synch/spinlock.h>
    4241#include <synch/mutex.h>
    4342#include <synch/waitq.h>
    44 #include <synch/synch.h>
    4543#include <ipc/ipc.h>
    46 #include <ipc/ipc_methods.h>
     44#include <abi/ipc/methods.h>
    4745#include <ipc/kbox.h>
    4846#include <ipc/event.h>
     
    232230                }
    233231        }
     232
     233        call->data.task_id = TASK->taskid;
    234234       
    235235        if (do_lock)
     
    296296                atomic_inc(&phone->active_calls);
    297297                call->data.phone = phone;
    298                 call->data.task = TASK;
     298                call->data.task_id = TASK->taskid;
    299299        }
    300300       
     
    408408                        call->caller_phone = call->data.phone;
    409409                call->data.phone = newphone;
    410                 call->data.task = TASK;
     410                call->data.task_id = TASK->taskid;
    411411        }
    412412       
  • kernel/generic/src/ipc/kbox.c

    r86a34d3e rbd5f3b7  
    3333 */
    3434
    35 #include <synch/synch.h>
    3635#include <synch/spinlock.h>
    3736#include <synch/mutex.h>
    3837#include <ipc/ipc.h>
    39 #include <ipc/ipc_methods.h>
     38#include <abi/ipc/methods.h>
    4039#include <ipc/ipcrsc.h>
    4140#include <arch.h>
  • kernel/generic/src/ipc/sysipc.c

    r86a34d3e rbd5f3b7  
    4040#include <debug.h>
    4141#include <ipc/ipc.h>
    42 #include <ipc/ipc_methods.h>
     42#include <abi/ipc/methods.h>
    4343#include <ipc/sysipc.h>
    4444#include <ipc/irq.h>
    4545#include <ipc/ipcrsc.h>
     46#include <ipc/event.h>
    4647#include <ipc/kbox.h>
    4748#include <synch/waitq.h>
     
    5354#include <mm/as.h>
    5455#include <print.h>
     56#include <macros.h>
    5557
    5658/**
     
    134136        case IPC_M_DATA_WRITE:
    135137        case IPC_M_DATA_READ:
     138        case IPC_M_STATE_CHANGE_AUTHORIZE:
    136139                return true;
    137140        default:
     
    164167        case IPC_M_DATA_WRITE:
    165168        case IPC_M_DATA_READ:
     169        case IPC_M_STATE_CHANGE_AUTHORIZE:
    166170                return true;
    167171        default:
     
    249253                        /* The connection was accepted */
    250254                        phone_connect(phoneid, &answer->sender->answerbox);
    251                         /* Set 'task hash' as arg4 of response */
    252                         IPC_SET_ARG4(answer->data, (sysarg_t) TASK);
    253255                        /* Set 'phone hash' as arg5 of response */
    254256                        IPC_SET_ARG5(answer->data,
     
    334336                free(answer->buffer);
    335337                answer->buffer = NULL;
     338        } else if (IPC_GET_IMETHOD(*olddata) == IPC_M_STATE_CHANGE_AUTHORIZE) {
     339                if (!IPC_GET_RETVAL(answer->data)) {
     340                        /* The recipient authorized the change of state. */
     341                        phone_t *recipient_phone;
     342                        task_t *other_task_s;
     343                        task_t *other_task_r;
     344                        int rc;
     345
     346                        rc = phone_get(IPC_GET_ARG1(answer->data),
     347                            &recipient_phone);
     348                        if (rc != EOK) {
     349                                IPC_SET_RETVAL(answer->data, ENOENT);
     350                                return ENOENT;
     351                        }
     352
     353                        mutex_lock(&recipient_phone->lock);
     354                        if (recipient_phone->state != IPC_PHONE_CONNECTED) {
     355                                mutex_unlock(&recipient_phone->lock);
     356                                IPC_SET_RETVAL(answer->data, EINVAL);
     357                                return EINVAL;
     358                        }
     359
     360                        other_task_r = recipient_phone->callee->task;
     361                        other_task_s = (task_t *) IPC_GET_ARG5(*olddata);
     362
     363                        /*
     364                         * See if both the sender and the recipient meant the
     365                         * same third party task.
     366                         */
     367                        if (other_task_r != other_task_s) {
     368                                IPC_SET_RETVAL(answer->data, EINVAL);
     369                                rc = EINVAL;
     370                        } else {
     371                                rc = event_task_notify_5(other_task_r,
     372                                    EVENT_TASK_STATE_CHANGE, false,
     373                                    IPC_GET_ARG1(*olddata),
     374                                    IPC_GET_ARG2(*olddata),
     375                                    IPC_GET_ARG3(*olddata),
     376                                    LOWER32(olddata->task_id),
     377                                    UPPER32(olddata->task_id));
     378                                IPC_SET_RETVAL(answer->data, rc);
     379                        }
     380
     381                        mutex_unlock(&recipient_phone->lock);
     382                        return rc;
     383                }
    336384        }
    337385       
     
    427475        case IPC_M_DATA_READ: {
    428476                size_t size = IPC_GET_ARG2(call->data);
    429                 if (size <= 0)
    430                         return ELIMIT;
    431477                if (size > DATA_XFER_LIMIT) {
    432478                        int flags = IPC_GET_ARG3(call->data);
     
    458504                }
    459505               
     506                break;
     507        }
     508        case IPC_M_STATE_CHANGE_AUTHORIZE: {
     509                phone_t *sender_phone;
     510                task_t *other_task_s;
     511
     512                if (phone_get(IPC_GET_ARG5(call->data), &sender_phone) != EOK)
     513                        return ENOENT;
     514
     515                mutex_lock(&sender_phone->lock);
     516                if (sender_phone->state != IPC_PHONE_CONNECTED) {
     517                        mutex_unlock(&sender_phone->lock);
     518                        return EINVAL;
     519                }
     520
     521                other_task_s = sender_phone->callee->task;
     522
     523                mutex_unlock(&sender_phone->lock);
     524
     525                /* Remember the third party task hash. */
     526                IPC_SET_ARG5(call->data, (sysarg_t) other_task_s);
    460527                break;
    461528        }
  • kernel/generic/src/lib/elf.c

    r86a34d3e rbd5f3b7  
    4747#include <macros.h>
    4848#include <arch.h>
     49
     50#include <lib/elf_load.h>
    4951
    5052static const char *error_codes[] = {
  • kernel/generic/src/proc/program.c

    r86a34d3e rbd5f3b7  
    4040#include <proc/thread.h>
    4141#include <proc/task.h>
    42 #include <proc/uarg.h>
    4342#include <mm/as.h>
    4443#include <mm/slab.h>
     
    4847#include <ipc/ipcrsc.h>
    4948#include <security/cap.h>
    50 #include <lib/elf.h>
     49#include <lib/elf_load.h>
    5150#include <errno.h>
    5251#include <print.h>
  • kernel/generic/src/proc/task.c

    r86a34d3e rbd5f3b7  
    5050#include <ipc/ipc.h>
    5151#include <ipc/ipcrsc.h>
     52#include <ipc/event.h>
    5253#include <print.h>
    5354#include <errno.h>
     
    5758#include <syscall/copy.h>
    5859#include <macros.h>
    59 #include <ipc/event.h>
    6060
    6161/** Spinlock protecting the tasks_tree AVL tree. */
     
    201201        task->ipc_info.irq_notif_received = 0;
    202202        task->ipc_info.forwarded = 0;
     203
     204        event_task_init(task);
    203205       
    204206#ifdef CONFIG_UDEBUG
  • kernel/generic/src/proc/thread.c

    r86a34d3e rbd5f3b7  
    3939#include <proc/thread.h>
    4040#include <proc/task.h>
    41 #include <proc/uarg.h>
    4241#include <mm/frame.h>
    4342#include <mm/page.h>
     
    4544#include <arch/cycle.h>
    4645#include <arch.h>
    47 #include <synch/synch.h>
    4846#include <synch/spinlock.h>
    4947#include <synch/waitq.h>
  • kernel/generic/src/synch/condvar.c

    r86a34d3e rbd5f3b7  
    3939#include <synch/mutex.h>
    4040#include <synch/waitq.h>
    41 #include <synch/synch.h>
    4241#include <arch.h>
    4342
  • kernel/generic/src/synch/futex.c

    r86a34d3e rbd5f3b7  
    3939#include <synch/mutex.h>
    4040#include <synch/spinlock.h>
    41 #include <synch/synch.h>
    4241#include <mm/frame.h>
    4342#include <mm/page.h>
  • kernel/generic/src/synch/mutex.c

    r86a34d3e rbd5f3b7  
    3838#include <synch/mutex.h>
    3939#include <synch/semaphore.h>
    40 #include <synch/synch.h>
    4140#include <debug.h>
    4241#include <arch.h>
  • kernel/generic/src/synch/semaphore.c

    r86a34d3e rbd5f3b7  
    3939#include <synch/waitq.h>
    4040#include <synch/spinlock.h>
    41 #include <synch/synch.h>
    4241#include <arch/asm.h>
    4342#include <arch.h>
  • kernel/generic/src/synch/waitq.c

    r86a34d3e rbd5f3b7  
    4545
    4646#include <synch/waitq.h>
    47 #include <synch/synch.h>
    4847#include <synch/spinlock.h>
    4948#include <proc/thread.h>
  • kernel/generic/src/sysinfo/stats.c

    r86a34d3e rbd5f3b7  
    3535
    3636#include <typedefs.h>
    37 #include <sysinfo/abi.h>
     37#include <abi/sysinfo.h>
    3838#include <sysinfo/stats.h>
    3939#include <sysinfo/sysinfo.h>
Note: See TracChangeset for help on using the changeset viewer.