Changeset df29f24 in mainline for kernel/generic/include


Ignore:
Timestamp:
2011-06-01T09:04:08Z (15 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0a7627b, c9f0975
Parents:
e51a514 (diff), 5d1b3aa (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

Conflicts - trivial to solve
In kernel/generic/src/mm/page.c - sys_page_find_mapping does
not use locking when accessing page tables (hope that is correct).

Location:
kernel/generic/include
Files:
14 edited

Legend:

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

    re51a514 rdf29f24  
    4141/** Doubly linked list head and link type. */
    4242typedef struct link {
    43         struct link *prev;      /**< Pointer to the previous item in the list. */
    44         struct link *next;      /**< Pointer to the next item in the list. */
     43        struct link *prev;  /**< Pointer to the previous item in the list. */
     44        struct link *next;  /**< Pointer to the next item in the list. */
    4545} link_t;
    4646
     
    4848 *
    4949 * @param name Name of the new statically allocated list.
     50 *
    5051 */
    5152#define LIST_INITIALIZE(name) \
    52         link_t name = { .prev = &name, .next = &name }
     53        link_t name = { \
     54                .prev = &name, \
     55                .next = &name \
     56        }
     57
     58#define list_get_instance(link, type, member) \
     59        ((type *) (((void *)(link)) - ((void *) &(((type *) NULL)->member))))
     60
     61#define list_foreach(list, iterator) \
     62        for (link_t *iterator = (list).next; \
     63            iterator != &(list); iterator = iterator->next)
    5364
    5465/** Initialize doubly-linked circular list link
     
    5768 *
    5869 * @param link Pointer to link_t structure to be initialized.
     70 *
    5971 */
    6072NO_TRACE static inline void link_initialize(link_t *link)
     
    6880 * Initialize doubly-linked circular list.
    6981 *
    70  * @param head Pointer to link_t structure representing head of the list.
    71  */
    72 NO_TRACE static inline void list_initialize(link_t *head)
    73 {
    74         head->prev = head;
    75         head->next = head;
     82 * @param list Pointer to link_t structure representing the list.
     83 *
     84 */
     85NO_TRACE static inline void list_initialize(link_t *list)
     86{
     87        list->prev = list;
     88        list->next = list;
    7689}
    7790
     
    8194 *
    8295 * @param link Pointer to link_t structure to be added.
    83  * @param head Pointer to link_t structure representing head of the list.
    84  */
    85 NO_TRACE static inline void list_prepend(link_t *link, link_t *head)
    86 {
    87         link->next = head->next;
    88         link->prev = head;
    89         head->next->prev = link;
    90         head->next = link;
     96 * @param list Pointer to link_t structure representing the list.
     97 *
     98 */
     99NO_TRACE static inline void list_prepend(link_t *link, link_t *list)
     100{
     101        link->next = list->next;
     102        link->prev = list;
     103        list->next->prev = link;
     104        list->next = link;
    91105}
    92106
     
    96110 *
    97111 * @param link Pointer to link_t structure to be added.
    98  * @param head Pointer to link_t structure representing head of the list.
    99  */
    100 NO_TRACE static inline void list_append(link_t *link, link_t *head)
    101 {
    102         link->prev = head->prev;
    103         link->next = head;
    104         head->prev->next = link;
    105         head->prev = link;
     112 * @param list Pointer to link_t structure representing the list.
     113 *
     114 */
     115NO_TRACE static inline void list_append(link_t *link, link_t *list)
     116{
     117        link->prev = list->prev;
     118        link->next = list;
     119        list->prev->next = link;
     120        list->prev = link;
     121}
     122
     123/** Insert item before another item in doubly-linked circular list.
     124 *
     125 */
     126static inline void list_insert_before(link_t *link, link_t *list)
     127{
     128        list_append(link, list);
     129}
     130
     131/** Insert item after another item in doubly-linked circular list.
     132 *
     133 */
     134static inline void list_insert_after(link_t *link, link_t *list)
     135{
     136        list_prepend(list, link);
    106137}
    107138
     
    110141 * Remove item from doubly-linked circular list.
    111142 *
    112  * @param link  Pointer to link_t structure to be removed from the list it is
    113  *              contained in.
     143 * @param link Pointer to link_t structure to be removed from the list
     144 *             it is contained in.
     145 *
    114146 */
    115147NO_TRACE static inline void list_remove(link_t *link)
     
    124156 * Query emptiness of doubly-linked circular list.
    125157 *
    126  * @param head Pointer to link_t structure representing head of the list.
    127  */
    128 NO_TRACE static inline bool list_empty(link_t *head)
    129 {
    130         return head->next == head ? true : false;
    131 }
    132 
     158 * @param list Pointer to link_t structure representing the list.
     159 *
     160 */
     161NO_TRACE static inline int list_empty(link_t *list)
     162{
     163        return (list->next == list);
     164}
     165
     166/** Get head item of a list.
     167 *
     168 * @param list Pointer to link_t structure representing the list.
     169 *
     170 * @return Head item of the list.
     171 * @return NULL if the list is empty.
     172 *
     173 */
     174static inline link_t *list_head(link_t *list)
     175{
     176        return ((list->next == list) ? NULL : list->next);
     177}
    133178
    134179/** Split or concatenate headless doubly-linked circular list
     
    139184 * concatenates splitted lists and splits concatenated lists.
    140185 *
    141  * @param part1 Pointer to link_t structure leading the first (half of the
    142  *              headless) list.
    143  * @param part2 Pointer to link_t structure leading the second (half of the
    144  *              headless) list.
     186 * @param part1 Pointer to link_t structure leading the first
     187 *              (half of the headless) list.
     188 * @param part2 Pointer to link_t structure leading the second
     189 *              (half of the headless) list.
     190 *
    145191 */
    146192NO_TRACE static inline void headless_list_split_or_concat(link_t *part1, link_t *part2)
    147193{
    148         link_t *hlp;
    149 
    150194        part1->prev->next = part2;
    151         part2->prev->next = part1;     
    152         hlp = part1->prev;
     195        part2->prev->next = part1;
     196       
     197        link_t *hlp = part1->prev;
     198       
    153199        part1->prev = part2->prev;
    154200        part2->prev = hlp;
    155201}
    156202
    157 
    158203/** Split headless doubly-linked circular list
    159204 *
    160205 * Split headless doubly-linked circular list.
    161206 *
    162  * @param part1 Pointer to link_t structure leading the first half of the
    163  *              headless list.
    164  * @param part2 Pointer to link_t structure leading the second half of the
    165  *              headless list.
     207 * @param part1 Pointer to link_t structure leading
     208 *              the first half of the headless list.
     209 * @param part2 Pointer to link_t structure leading
     210 *              the second half of the headless list.
     211 *
    166212 */
    167213NO_TRACE static inline void headless_list_split(link_t *part1, link_t *part2)
     
    174220 * Concatenate two headless doubly-linked circular lists.
    175221 *
    176  * @param part1 Pointer to link_t structure leading the first headless list.
    177  * @param part2 Pointer to link_t structure leading the second headless list.
     222 * @param part1 Pointer to link_t structure leading
     223 *              the first headless list.
     224 * @param part2 Pointer to link_t structure leading
     225 *              the second headless list.
     226 *
    178227 */
    179228NO_TRACE static inline void headless_list_concat(link_t *part1, link_t *part2)
     
    182231}
    183232
    184 #define list_get_instance(link, type, member) \
    185         ((type *)(((uint8_t *)(link)) - ((uint8_t *)&(((type *)NULL)->member))))
    186 
    187 extern bool list_member(const link_t *link, const link_t *head);
    188 extern void list_concat(link_t *head1, link_t *head2);
     233/** Get n-th item of a list.
     234 *
     235 * @param list Pointer to link_t structure representing the list.
     236 * @param n    Item number (indexed from zero).
     237 *
     238 * @return n-th item of the list.
     239 * @return NULL if no n-th item found.
     240 *
     241 */
     242static inline link_t *list_nth(link_t *list, unsigned int n)
     243{
     244        unsigned int cnt = 0;
     245       
     246        list_foreach(*list, link) {
     247                if (cnt == n)
     248                        return link;
     249               
     250                cnt++;
     251        }
     252       
     253        return NULL;
     254}
     255
     256extern int list_member(const link_t *, const link_t *);
     257extern void list_concat(link_t *, link_t *);
     258extern unsigned int list_count(const link_t *);
    189259
    190260#endif
  • kernel/generic/include/arch.h

    re51a514 rdf29f24  
    4141#include <mm/as.h>
    4242
    43 #define DEFAULT_CONTEXT  0
     43/*
     44 * THE is not an abbreviation, but the English definite article written in
     45 * capital letters. It means the current pointer to something, e.g. thread,
     46 * processor or address space. Kind reader of this comment shall appreciate
     47 * the wit of constructs like THE->thread and similar.
     48 */
     49#define THE  ((the_t * )(get_stack_base()))
    4450
    4551#define CPU                  THE->cpu
     
    4753#define TASK                 THE->task
    4854#define AS                   THE->as
    49 #define CONTEXT              (THE->task ? THE->task->context : DEFAULT_CONTEXT)
    5055#define PREEMPTION_DISABLED  THE->preemption_disabled
     56#define MAGIC                UINT32_C(0xfacefeed)
    5157
    52 #define context_check(ctx1, ctx2)  ((ctx1) == (ctx2))
     58#define container_check(ctn1, ctn2)  ((ctn1) == (ctn2))
     59
     60#define DEFAULT_CONTAINER  0
     61#define CONTAINER \
     62        ((THE->task) ? (THE->task->container) : (DEFAULT_CONTAINER))
    5363
    5464/**
     
    6373        cpu_t *cpu;                  /**< Executing cpu. */
    6474        as_t *as;                    /**< Current address space. */
     75        uint32_t magic;              /**< Magic value */
    6576} the_t;
    66 
    67 /*
    68  * THE is not an abbreviation, but the English definite article written in
    69  * capital letters. It means the current pointer to something, e.g. thread,
    70  * processor or address space. Kind reader of this comment shall appreciate
    71  * the wit of constructs like THE->thread and similar.
    72  */
    73 #define THE  ((the_t * )(get_stack_base()))
    7477
    7578extern void the_initialize(the_t *);
  • kernel/generic/include/config.h

    re51a514 rdf29f24  
    3636#define KERN_CONFIG_H_
    3737
    38 #include <typedefs.h>
    3938#include <arch/mm/page.h>
    4039
    41 #define STACK_SIZE  PAGE_SIZE
     40#define ONE_FRAME    0
     41#define TWO_FRAMES   1
     42#define FOUR_FRAMES  2
     43
     44#define STACK_FRAMES  TWO_FRAMES
     45#define STACK_SIZE    ((1 << STACK_FRAMES) << PAGE_WIDTH)
    4246
    4347#define CONFIG_INIT_TASKS        32
    4448#define CONFIG_TASK_NAME_BUFLEN  32
     49
     50#ifndef __ASM__
     51
     52#include <typedefs.h>
    4553
    4654typedef struct {
     
    8088extern ballocs_t ballocs;
    8189
     90#endif /* __ASM__ */
     91
    8292#endif
    8393
  • kernel/generic/include/cpu.h

    re51a514 rdf29f24  
    4141#include <arch/cpu.h>
    4242#include <arch/context.h>
    43 
    44 #define CPU_STACK_SIZE  STACK_SIZE
    4543
    4644/** CPU structure.
  • kernel/generic/include/ipc/event.h

    re51a514 rdf29f24  
    4141#include <ipc/ipc.h>
    4242
     43typedef void (*event_callback_t)(void);
     44
    4345/** Event notification structure. */
    4446typedef struct {
     
    5153        /** Counter. */
    5254        size_t counter;
     55       
    5356        /** Masked flag. */
    5457        bool masked;
    5558        /** Unmask callback. */
    56         void (*unmask_cb)(void);
     59        event_callback_t unmask_callback;
    5760} event_t;
    5861
    5962extern void event_init(void);
    6063extern void event_cleanup_answerbox(answerbox_t *);
    61 extern void event_set_unmask_callback(event_type_t, void (*)(void));
     64extern void event_set_unmask_callback(event_type_t, event_callback_t);
    6265
    6366#define event_notify_0(e, m) \
  • kernel/generic/include/mm/as.h

    re51a514 rdf29f24  
    8484#define USER_ADDRESS_SPACE_END      USER_ADDRESS_SPACE_END_ARCH
    8585
    86 #define USTACK_ADDRESS  USTACK_ADDRESS_ARCH
     86#ifdef USTACK_ADDRESS_ARCH
     87        #define USTACK_ADDRESS  USTACK_ADDRESS_ARCH
     88#else
     89        #define USTACK_ADDRESS  (USER_ADDRESS_SPACE_END - (STACK_SIZE - 1))
     90#endif
    8791
    8892/** Kernel address space. */
  • kernel/generic/include/mm/frame.h

    re51a514 rdf29f24  
    4444#include <arch/mm/page.h>
    4545#include <arch/mm/frame.h>
    46 
    47 #define ONE_FRAME    0
    48 #define TWO_FRAMES   1
    49 #define FOUR_FRAMES  2
    50 
    51 
    52 #ifdef ARCH_STACK_FRAMES
    53         #define STACK_FRAMES  ARCH_STACK_FRAMES
    54 #else
    55         #define STACK_FRAMES  ONE_FRAME
    56 #endif
    5746
    5847/** Maximum number of zones in the system. */
  • kernel/generic/include/mm/page.h

    re51a514 rdf29f24  
    3939#include <proc/task.h>
    4040#include <mm/as.h>
    41 #include <memstr.h>
     41#include <arch/mm/page.h>
     42
     43#define P2SZ(pages) \
     44        ((pages) << PAGE_WIDTH)
    4245
    4346/** Operations to manipulate page mappings. */
     
    4548        void (* mapping_insert)(as_t *, uintptr_t, uintptr_t, unsigned int);
    4649        void (* mapping_remove)(as_t *, uintptr_t);
    47         pte_t *(* mapping_find)(as_t *, uintptr_t);
     50        pte_t *(* mapping_find)(as_t *, uintptr_t, bool);
    4851} page_mapping_operations_t;
    4952
     
    5659extern void page_mapping_insert(as_t *, uintptr_t, uintptr_t, unsigned int);
    5760extern void page_mapping_remove(as_t *, uintptr_t);
    58 extern pte_t *page_mapping_find(as_t *, uintptr_t);
     61extern pte_t *page_mapping_find(as_t *, uintptr_t, bool);
    5962extern pte_t *page_table_create(unsigned int);
    6063extern void page_table_destroy(pte_t *);
  • kernel/generic/include/mm/tlb.h

    re51a514 rdf29f24  
    8686extern void tlb_invalidate_asid(asid_t);
    8787extern void tlb_invalidate_pages(asid_t, uintptr_t, size_t);
     88
    8889#endif
    8990
  • kernel/generic/include/proc/task.h

    re51a514 rdf29f24  
    7878        /** Unique identity of task. */
    7979        task_id_t taskid;
    80         /** Task security context. */
    81         context_id_t context;
     80        /** Task security container. */
     81        container_id_t container;
    8282       
    8383        /** Number of references (i.e. threads). */
  • kernel/generic/include/proc/thread.h

    re51a514 rdf29f24  
    4949#include <sysinfo/abi.h>
    5050
    51 #define THREAD_STACK_SIZE   STACK_SIZE
    5251#define THREAD_NAME_BUFLEN  20
    5352
  • kernel/generic/include/proc/uarg.h

    re51a514 rdf29f24  
    4040        void *uspace_entry;
    4141        void *uspace_stack;
    42 
     42       
    4343        void (* uspace_thread_function)();
    4444        void *uspace_thread_arg;
  • kernel/generic/include/synch/waitq.h

    re51a514 rdf29f24  
    6262        int missed_wakeups;
    6363       
    64         /** List of sleeping threads for wich there was no missed_wakeup. */
     64        /** List of sleeping threads for which there was no missed_wakeup. */
    6565        link_t head;
    6666} waitq_t;
  • kernel/generic/include/typedefs.h

    re51a514 rdf29f24  
    6464typedef uint64_t thread_id_t;
    6565typedef uint64_t task_id_t;
    66 typedef uint32_t context_id_t;
     66typedef uint32_t container_id_t;
    6767
    6868typedef int32_t inr_t;
Note: See TracChangeset for help on using the changeset viewer.