Rev 983 | Rev 1044 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 983 | Rev 1026 | ||
---|---|---|---|
Line 117... | Line 117... | ||
117 | /** Create address space area of common attributes. |
117 | /** Create address space area of common attributes. |
118 | * |
118 | * |
119 | * The created address space area is added to the target address space. |
119 | * The created address space area is added to the target address space. |
120 | * |
120 | * |
121 | * @param as Target address space. |
121 | * @param as Target address space. |
122 | * @param type Type of area. |
122 | * @param flags Flags of the area. |
123 | * @param size Size of area in multiples of PAGE_SIZE. |
123 | * @param size Size of area in multiples of PAGE_SIZE. |
124 | * @param base Base address of area. |
124 | * @param base Base address of area. |
125 | * |
125 | * |
126 | * @return Address space area on success or NULL on failure. |
126 | * @return Address space area on success or NULL on failure. |
127 | */ |
127 | */ |
128 | as_area_t *as_area_create(as_t *as, as_area_type_t type, size_t size, __address base) |
128 | as_area_t *as_area_create(as_t *as, int flags, size_t size, __address base) |
129 | { |
129 | { |
130 | ipl_t ipl; |
130 | ipl_t ipl; |
131 | as_area_t *a; |
131 | as_area_t *a; |
132 | 132 | ||
133 | if (base % PAGE_SIZE) |
133 | if (base % PAGE_SIZE) |
Line 143... | Line 143... | ||
143 | a = (as_area_t *) malloc(sizeof(as_area_t), 0); |
143 | a = (as_area_t *) malloc(sizeof(as_area_t), 0); |
144 | 144 | ||
145 | spinlock_initialize(&a->lock, "as_area_lock"); |
145 | spinlock_initialize(&a->lock, "as_area_lock"); |
146 | 146 | ||
147 | link_initialize(&a->link); |
147 | link_initialize(&a->link); |
148 | a->type = type; |
148 | a->flags = flags; |
149 | a->size = size; |
149 | a->size = size; |
150 | a->base = base; |
150 | a->base = base; |
151 | 151 | ||
152 | list_append(&a->link, &as->as_area_head); |
152 | list_append(&a->link, &as->as_area_head); |
153 | 153 | ||
Line 324... | Line 324... | ||
324 | */ |
324 | */ |
325 | int get_area_flags(as_area_t *a) |
325 | int get_area_flags(as_area_t *a) |
326 | { |
326 | { |
327 | int flags; |
327 | int flags; |
328 | 328 | ||
329 | switch (a->type) { |
- | |
330 | case AS_AREA_TEXT: |
- | |
331 | flags = PAGE_EXEC | PAGE_READ | PAGE_USER | PAGE_PRESENT | PAGE_CACHEABLE; |
329 | flags = PAGE_USER | PAGE_PRESENT | PAGE_CACHEABLE; |
332 | break; |
330 | |
333 | case AS_AREA_DATA: |
331 | if (a->flags & AS_AREA_READ) |
334 | case AS_AREA_STACK: |
332 | flags |= PAGE_READ; |
335 | flags = PAGE_READ | PAGE_WRITE | PAGE_USER | PAGE_PRESENT | PAGE_CACHEABLE; |
- | |
336 | break; |
333 | |
337 | default: |
334 | if (a->flags & AS_AREA_WRITE) |
338 | panic("unexpected as_area_type_t %d", a->type); |
335 | flags |= PAGE_WRITE; |
339 | } |
336 | |
- | 337 | if (a->flags & AS_AREA_EXEC) |
|
- | 338 | flags |= PAGE_EXEC; |
|
340 | 339 | ||
341 | return flags; |
340 | return flags; |
342 | } |
341 | } |
343 | 342 | ||
344 | /** Create page table. |
343 | /** Create page table. |