Changeset 7242a78e in mainline


Ignore:
Timestamp:
2006-05-11T16:05:02Z (19 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8d4f2ae
Parents:
cfffb000
Message:

Add SYS_AS_AREA_DESTROY syscall.
Add few error codes to errno.h
and change as.c accordingly.

Location:
generic
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • generic/include/errno.h

    rcfffb000 r7242a78e  
    3232/* 1-255 are kernel error codes, 256-512 are user error codes */
    3333
    34 #define ENOENT     -1  /* No such entry */
    35 #define ENOMEM     -2  /* Not enough memory */
    36 #define ELIMIT     -3  /* Limit exceeded */
    37 #define EREFUSED   -4  /* Connection refused */
    38 #define EFORWARD   -5  /* Forward error */
    39 #define EPERM      -6  /* Permission denied */
    40 #define EHANGUP    -7  /* Answerbox closed connection, call sys_ipc_hangup
    41                         * to close the connection. Used by answerbox
    42                         * to close the connection.  */
    43 #define EEXISTS    -8  /* Entry already exists */
    44 #define EBADMEM    -9  /* Bad memory pointer */
     34#define ENOENT          -1      /* No such entry */
     35#define ENOMEM          -2      /* Not enough memory */
     36#define ELIMIT          -3      /* Limit exceeded */
     37#define EREFUSED        -4      /* Connection refused */
     38#define EFORWARD        -5      /* Forward error */
     39#define EPERM           -6      /* Permission denied */
     40#define EHANGUP         -7      /* Answerbox closed connection, call sys_ipc_hangup
     41                                 * to close the connection. Used by answerbox
     42                                 * to close the connection.  */
     43#define EEXISTS         -8      /* Entry already exists */
     44#define EBADMEM         -9      /* Bad memory pointer */
     45#define ENOTSUP         -10     /* Not supported */
     46#define EADDRNOTAVAIL   -11     /* Address not available. */
    4547
    4648#endif
  • generic/include/mm/as.h

    rcfffb000 r7242a78e  
    123123extern as_t *as_create(int flags);
    124124extern as_area_t *as_area_create(as_t *as, int flags, size_t size, __address base, int attrs);
    125 extern __address as_area_resize(as_t *as, __address address, size_t size, int flags);
     125extern int as_area_resize(as_t *as, __address address, size_t size, int flags);
     126extern int as_area_destroy(as_t *as, __address address);
    126127int as_area_send(task_id_t dst_id, __address base);
    127128extern void as_set_mapping(as_t *as, __address page, __address frame);
     
    138139extern __native sys_as_area_create(__address address, size_t size, int flags);
    139140extern __native sys_as_area_resize(__address address, size_t size, int flags);
     141extern __native sys_as_area_destroy(__address address);
    140142extern __native sys_as_area_accept(as_area_acptsnd_arg_t *uspace_accept_arg);
    141143extern __native sys_as_area_send(as_area_acptsnd_arg_t *uspace_send_arg);
  • generic/include/syscall/syscall.h

    rcfffb000 r7242a78e  
    4040        SYS_AS_AREA_CREATE,
    4141        SYS_AS_AREA_RESIZE,
     42        SYS_AS_AREA_DESTROY,
    4243        SYS_AS_AREA_ACCEPT,
    4344        SYS_AS_AREA_SEND,
  • generic/src/mm/as.c

    rcfffb000 r7242a78e  
    195195 * @param flags Flags influencing the remap operation. Currently unused.
    196196 *
    197  * @return address on success, (__address) -1 otherwise.
     197 * @return Zero on success or a value from @ref errno.h otherwise.
    198198 */
    199 __address as_area_resize(as_t *as, __address address, size_t size, int flags)
    200 {
    201         as_area_t *area = NULL;
     199int as_area_resize(as_t *as, __address address, size_t size, int flags)
     200{
     201        as_area_t *area;
    202202        ipl_t ipl;
    203203        size_t pages;
     
    213213                spinlock_unlock(&as->lock);
    214214                interrupts_restore(ipl);
    215                 return (__address) -1;
     215                return ENOENT;
    216216        }
    217217
     
    224224                spinlock_unlock(&as->lock);
    225225                interrupts_restore(ipl);
    226                 return (__address) -1;
     226                return ENOTSUP;
    227227        }
    228228
     
    235235                spinlock_unlock(&as->lock);
    236236                interrupts_restore(ipl);
    237                 return (__address) -1;
     237                return EPERM;
    238238        }
    239239       
     
    282282                        spinlock_unlock(&as->lock);             
    283283                        interrupts_restore(ipl);
    284                         return (__address) -1;
     284                        return EADDRNOTAVAIL;
    285285                }
    286286        }
     
    292292        interrupts_restore(ipl);
    293293
    294         return address;
     294        return 0;
     295}
     296
     297/** Destroy address space area.
     298 *
     299 * @param as Address space.
     300 * @param address Address withing the area to be deleted.
     301 *
     302 * @return Zero on success or a value from @ref errno.h on failure.
     303 */
     304int as_area_destroy(as_t *as, __address address)
     305{
     306        as_area_t *area;
     307        __address base;
     308        ipl_t ipl;
     309        int i;
     310
     311        ipl = interrupts_disable();
     312        spinlock_lock(&as->lock);
     313
     314        area = find_area_and_lock(as, address);
     315        if (!area) {
     316                spinlock_unlock(&as->lock);
     317                interrupts_restore(ipl);
     318                return ENOENT;
     319        }
     320
     321        base = area->base;     
     322        for (i = 0; i < area->pages; i++) {
     323                pte_t *pte;
     324
     325                /*
     326                 * Releasing physical memory.
     327                 * Areas mapping memory-mapped devices are treated differently than
     328                 * areas backing frame_alloc()'ed memory.
     329                 */
     330                page_table_lock(as, false);
     331                pte = page_mapping_find(as, area->base + i*PAGE_SIZE);
     332                if (pte && PTE_VALID(pte)) {
     333                        ASSERT(PTE_PRESENT(pte));
     334                        page_mapping_remove(as, area->base + i*PAGE_SIZE);
     335                        if (area->flags & AS_AREA_DEVICE) {
     336                                __address frame;
     337                                frame = PTE_GET_FRAME(pte);
     338                                frame_free(ADDR2PFN(frame));
     339                        }
     340                        page_table_unlock(as, false);
     341                } else {
     342                        page_table_unlock(as, false);
     343                }
     344        }
     345        /*
     346         * Invalidate TLB's.
     347         */
     348        tlb_shootdown_start(TLB_INVL_PAGES, AS->asid, area->base, area->pages);
     349        tlb_invalidate_pages(AS->asid, area->base, area->pages);
     350        tlb_shootdown_finalize();
     351
     352        spinlock_unlock(&area->lock);
     353
     354        /*
     355         * Remove the empty area from address space.
     356         */
     357        btree_remove(&AS->as_area_btree, base, NULL);
     358       
     359        spinlock_unlock(&AS->lock);
     360        interrupts_restore(ipl);
     361        return 0;
    295362}
    296363
     
    308375 * @param src_base Base address of the source address space area.
    309376 *
    310  * @return 0 on success or ENOENT if there is no such task or
     377 * @return Zero on success or ENOENT if there is no such task or
    311378 *         if there is no such address space area,
    312379 *         EPERM if there was a problem in accepting the area or
     
    892959__native sys_as_area_resize(__address address, size_t size, int flags)
    893960{
    894         return as_area_resize(AS, address, size, 0);
     961        return (__native) as_area_resize(AS, address, size, 0);
     962}
     963
     964/** Wrapper for as_area_destroy. */
     965__native sys_as_area_destroy(__address address)
     966{
     967        return (__native) as_area_destroy(AS, address);
    895968}
    896969
  • generic/src/syscall/syscall.c

    rcfffb000 r7242a78e  
    8585        sys_as_area_create,
    8686        sys_as_area_resize,
     87        sys_as_area_destroy,
    8788        sys_as_area_accept,
    8889        sys_as_area_send,
Note: See TracChangeset for help on using the changeset viewer.