Changeset 2c2d54a in mainline for uspace


Ignore:
Timestamp:
2016-09-02T17:58:05Z (9 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4c3602c4
Parents:
4bf0926e (diff), 3233adb (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 from lp:~jakub/helenos/pager

Location:
uspace
Files:
3 added
24 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/tester/Makefile

    r4bf0926e r2c2d54a  
    7474        mm/malloc3.c \
    7575        mm/mapping1.c \
     76        mm/pager1.c \
    7677        hw/misc/virtchar1.c \
    7778        hw/serial/serial1.c
  • uspace/app/tester/mm/common.c

    r4bf0926e r2c2d54a  
    341341       
    342342        area->addr = as_area_create(AS_AREA_ANY, size,
    343             AS_AREA_WRITE | AS_AREA_READ | AS_AREA_CACHEABLE);
     343            AS_AREA_WRITE | AS_AREA_READ | AS_AREA_CACHEABLE,
     344            AS_AREA_UNPAGED);
    344345        if (area->addr == AS_MAP_FAILED) {
    345346                free(area);
  • uspace/app/tester/mm/mapping1.c

    r4bf0926e r2c2d54a  
    4343       
    4444        void *result = as_area_create(AS_AREA_ANY, size,
    45             AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE);
     45            AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE, AS_AREA_UNPAGED);
    4646        if (result == AS_MAP_FAILED)
    4747                return NULL;
  • uspace/app/tester/tester.c

    r4bf0926e r2c2d54a  
    7474#include "mm/malloc3.def"
    7575#include "mm/mapping1.def"
     76#include "mm/pager1.def"
    7677#include "hw/serial/serial1.def"
    7778#include "hw/misc/virtchar1.def"
  • uspace/app/tester/tester.h

    r4bf0926e r2c2d54a  
    107107extern const char *test_malloc3(void);
    108108extern const char *test_mapping1(void);
     109extern const char *test_pager1(void);
    109110extern const char *test_serial1(void);
    110111extern const char *test_virtchar1(void);
  • uspace/app/trace/syscalls.c

    r4bf0926e r2c2d54a  
    4949    [SYS_FUTEX_WAKEUP] = { "futex_wakeup",              1,      V_ERRNO },
    5050
    51     [SYS_AS_AREA_CREATE] = { "as_area_create",          3,      V_ERRNO },
     51    [SYS_AS_AREA_CREATE] = { "as_area_create",          5,      V_ERRNO },
    5252    [SYS_AS_AREA_RESIZE] = { "as_area_resize",          3,      V_ERRNO },
    5353    [SYS_AS_AREA_DESTROY] = { "as_area_destroy",        1,      V_ERRNO },
  • uspace/lib/c/generic/as.c

    r4bf0926e r2c2d54a  
    4545/** Create address space area.
    4646 *
    47  * @param base  Starting virtual address of the area.
    48  *              If set to AS_AREA_ANY ((void *) -1),
    49  *              the kernel finds a mappable area.
    50  * @param size  Size of the area.
    51  * @param flags Flags describing type of the area.
     47 * @param base       Starting virtual address of the area.
     48 *                   If set to AS_AREA_ANY ((void *) -1), the kernel finds a
     49 *                   mappable area.
     50 * @param size       Size of the area.
     51 * @param flags      Flags describing type of the area.
     52 * @param pager_info Pager info structure or AS_AREA_UNPAGED (NULL) if the area
     53 *                   is not paged (i.e. anonymous).
    5254 *
    5355 * @return Starting virtual address of the created area on success.
     
    5557 *
    5658 */
    57 void *as_area_create(void *base, size_t size, unsigned int flags)
     59void *as_area_create(void *base, size_t size, unsigned int flags,
     60    as_area_pager_info_t *pager_info)
    5861{
    59         return (void *) __SYSCALL4(SYS_AS_AREA_CREATE, (sysarg_t) base,
    60             (sysarg_t) size, (sysarg_t) flags, (sysarg_t) __entry);
     62        return (void *) __SYSCALL5(SYS_AS_AREA_CREATE, (sysarg_t) base,
     63            (sysarg_t) size, (sysarg_t) flags, (sysarg_t) __entry,
     64            (sysarg_t) pager_info);
    6165}
    6266
  • uspace/lib/c/generic/async.c

    r4bf0926e r2c2d54a  
    116116#include <stdlib.h>
    117117#include <macros.h>
     118#include <as.h>
     119#include <abi/mm/as.h>
    118120#include "private/libc.h"
    119121
     
    33813383}
    33823384
     3385void *async_as_area_create(void *base, size_t size, unsigned int flags,
     3386    async_sess_t *pager, sysarg_t id1, sysarg_t id2, sysarg_t id3)
     3387{
     3388        as_area_pager_info_t pager_info = {
     3389                .pager = pager->phone,
     3390                .id1 = id1,
     3391                .id2 = id2,
     3392                .id3 = id3
     3393        };
     3394        return as_area_create(base, size, flags, &pager_info);
     3395}
     3396
    33833397/** @}
    33843398 */
  • uspace/lib/c/generic/elf/elf_mod.c

    r4bf0926e r2c2d54a  
    370370         */
    371371        a = as_area_create((uint8_t *) base + bias, mem_sz,
    372             AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE);
     372            AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE,
     373            AS_AREA_UNPAGED);
    373374        if (a == AS_MAP_FAILED) {
    374375                DPRINTF("memory mapping failed (%p, %zu)\n",
  • uspace/lib/c/generic/fibril.c

    r4bf0926e r2c2d54a  
    279279        size_t stack_size = (stksz == FIBRIL_DFLT_STK_SIZE) ?
    280280            stack_size_get() : stksz;
    281         fibril->stack = as_area_create((void *) -1, stack_size,
     281        fibril->stack = as_area_create(AS_AREA_ANY, stack_size,
    282282            AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE | AS_AREA_GUARD |
    283             AS_AREA_LATE_RESERVE);
     283            AS_AREA_LATE_RESERVE, AS_AREA_UNPAGED);
    284284        if (fibril->stack == (void *) -1) {
    285285                fibril_teardown(fibril, false);
  • uspace/lib/c/generic/io/chargrid.c

    r4bf0926e r2c2d54a  
    6060        if ((flags & CHARGRID_FLAG_SHARED) == CHARGRID_FLAG_SHARED) {
    6161                scrbuf = (chargrid_t *) as_area_create(AS_AREA_ANY, size,
    62                     AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE);
     62                    AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE,
     63                    AS_AREA_UNPAGED);
    6364                if (scrbuf == AS_MAP_FAILED)
    6465                        return NULL;
  • uspace/lib/c/generic/malloc.c

    r4bf0926e r2c2d54a  
    354354        size_t asize = ALIGN_UP(size, PAGE_SIZE);
    355355        void *astart = as_area_create(AS_AREA_ANY, asize,
    356             AS_AREA_WRITE | AS_AREA_READ | AS_AREA_CACHEABLE);
     356            AS_AREA_WRITE | AS_AREA_READ | AS_AREA_CACHEABLE, AS_AREA_UNPAGED);
    357357        if (astart == AS_MAP_FAILED)
    358358                return false;
  • uspace/lib/c/generic/thread.c

    r4bf0926e r2c2d54a  
    116116        void *stack = as_area_create(AS_AREA_ANY, stack_size,
    117117            AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE | AS_AREA_GUARD |
    118             AS_AREA_LATE_RESERVE);
     118            AS_AREA_LATE_RESERVE, AS_AREA_UNPAGED);
    119119        if (stack == AS_MAP_FAILED) {
    120120                free(uarg);
  • uspace/lib/c/include/as.h

    r4bf0926e r2c2d54a  
    3838#include <sys/types.h>
    3939#include <abi/mm/as.h>
    40 #include <task.h>
    4140#include <libarch/config.h>
    42 
    43 #define AS_AREA_ANY    ((void *) -1)
    44 #define AS_MAP_FAILED  ((void *) -1)
    4541
    4642static inline size_t SIZE2PAGES(size_t size)
     
    5753}
    5854
    59 extern void *as_area_create(void *, size_t, unsigned int);
     55extern void *as_area_create(void *, size_t, unsigned int,
     56    as_area_pager_info_t *);
    6057extern int as_area_resize(void *, size_t, unsigned int);
    6158extern int as_area_change_flags(void *, unsigned int);
  • uspace/lib/c/include/async.h

    r4bf0926e r2c2d54a  
    488488extern void async_remote_state_release_exchange(async_exch_t *);
    489489
     490extern void *async_as_area_create(void *, size_t, unsigned int, async_sess_t *,
     491    sysarg_t, sysarg_t, sysarg_t);
     492
    490493#endif
    491494
  • uspace/lib/draw/surface.c

    r4bf0926e r2c2d54a  
    6464        if (!pixbuf) {
    6565                if ((flags & SURFACE_FLAG_SHARED) == SURFACE_FLAG_SHARED) {
    66                         pixbuf = (pixel_t *) as_area_create(AS_AREA_ANY, pixbuf_size,
    67                             AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE);
     66                        pixbuf = (pixel_t *) as_area_create(AS_AREA_ANY,
     67                            pixbuf_size,
     68                            AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE,
     69                            AS_AREA_UNPAGED);
    6870                        if (pixbuf == AS_MAP_FAILED) {
    6971                                free(surface);
  • uspace/lib/posix/source/sys/mman.c

    r4bf0926e r2c2d54a  
    5454                return MAP_FAILED;
    5555       
    56         return as_area_create(start, length, prot);
     56        return as_area_create(start, length, prot, AS_AREA_UNPAGED);
    5757}
    5858
  • uspace/srv/hid/compositor/compositor.c

    r4bf0926e r2c2d54a  
    5555#include <async.h>
    5656#include <loc.h>
     57#include <task.h>
    5758
    5859#include <io/keycode.h>
  • uspace/srv/hid/console/console.c

    r4bf0926e r2c2d54a  
    4949#include <malloc.h>
    5050#include <as.h>
     51#include <task.h>
    5152#include <fibril_synch.h>
    5253#include "console.h"
  • uspace/srv/hid/output/output.c

    r4bf0926e r2c2d54a  
    3232#include <macros.h>
    3333#include <as.h>
     34#include <task.h>
    3435#include <ipc/output.h>
    3536#include "port/ega.h"
  • uspace/srv/vfs/Makefile

    r4bf0926e r2c2d54a  
    3838        vfs_ops.c \
    3939        vfs_lookup.c \
    40         vfs_register.c
     40        vfs_register.c \
     41        vfs_pager.c
    4142
    4243include $(USPACE_PREFIX)/Makefile.common
  • uspace/srv/vfs/vfs.c

    r4bf0926e r2c2d54a  
    3737
    3838#include <vfs/vfs.h>
     39#include <stdlib.h>
    3940#include <ipc/services.h>
     41#include <abi/ipc/methods.h>
     42#include <libarch/config.h>
    4043#include <ns.h>
    4144#include <async.h>
     
    5154#define NAME  "vfs"
    5255
     56static void vfs_pager(ipc_callid_t iid, ipc_call_t *icall, void *arg)
     57{
     58        async_answer_0(iid, EOK);
     59
     60        while (true) {
     61                ipc_call_t call;
     62                ipc_callid_t callid = async_get_call(&call);
     63               
     64                if (!IPC_GET_IMETHOD(call))
     65                        break;
     66               
     67                switch (IPC_GET_IMETHOD(call)) {
     68                case IPC_M_PAGE_IN:
     69                        vfs_page_in(callid, &call);
     70                        break;
     71                default:
     72                        async_answer_0(callid, ENOTSUP);
     73                        break;
     74                }
     75        }
     76}
     77
    5378static void vfs_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg)
    5479{
     
    150175int main(int argc, char **argv)
    151176{
     177        int rc;
     178
    152179        printf("%s: HelenOS VFS server\n", NAME);
    153180       
     
    165192         */
    166193        plb = as_area_create(AS_AREA_ANY, PLB_SIZE,
    167             AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE);
     194            AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE, AS_AREA_UNPAGED);
    168195        if (plb == AS_MAP_FAILED) {
    169196                printf("%s: Cannot create address space area\n", NAME);
     
    179206
    180207        /*
     208         * Create a port for the pager.
     209         */
     210        port_id_t port;
     211        rc = async_create_port(INTERFACE_PAGER, vfs_pager, NULL, &port);
     212        if (rc != EOK)
     213                return rc;
     214               
     215        /*
    181216         * Set a connection handling function/fibril.
    182217         */
     
    192227         * Register at the naming service.
    193228         */
    194         int rc = service_register(SERVICE_VFS);
     229        rc = service_register(SERVICE_VFS);
    195230        if (rc != EOK) {
    196231                printf("%s: Cannot register VFS service\n", NAME);
  • uspace/srv/vfs/vfs.h

    r4bf0926e r2c2d54a  
    224224extern void vfs_statfs(ipc_callid_t, ipc_call_t *);
    225225
     226extern void vfs_page_in(ipc_callid_t, ipc_call_t *);
     227
     228typedef struct {
     229        void *buffer;
     230        size_t size;
     231} rdwr_io_chunk_t;
     232
     233extern int vfs_rdwr_internal(int, bool, rdwr_io_chunk_t *);
     234
    226235#endif
    227236
  • uspace/srv/vfs/vfs_ops.c

    r4bf0926e r2c2d54a  
    734734}
    735735
    736 static void vfs_rdwr(ipc_callid_t rid, ipc_call_t *request, bool read)
     736typedef int (* rdwr_ipc_cb_t)(async_exch_t *, vfs_file_t *, ipc_call_t *,
     737    bool, void *);
     738
     739static int rdwr_ipc_client(async_exch_t *exch, vfs_file_t *file,
     740    ipc_call_t *answer, bool read, void *data)
     741{
     742        size_t *bytes = (size_t *) data;
     743        int rc;
     744
     745        /*
     746         * Make a VFS_READ/VFS_WRITE request at the destination FS server
     747         * and forward the IPC_M_DATA_READ/IPC_M_DATA_WRITE request to the
     748         * destination FS server. The call will be routed as if sent by
     749         * ourselves. Note that call arguments are immutable in this case so we
     750         * don't have to bother.
     751         */
     752
     753        if (read) {
     754                rc = async_data_read_forward_4_1(exch, VFS_OUT_READ,
     755                    file->node->service_id, file->node->index,
     756                    LOWER32(file->pos), UPPER32(file->pos), answer);
     757        } else {
     758                rc = async_data_write_forward_4_1(exch, VFS_OUT_WRITE,
     759                    file->node->service_id, file->node->index,
     760                    LOWER32(file->pos), UPPER32(file->pos), answer);
     761        }
     762
     763        *bytes = IPC_GET_ARG1(*answer);
     764        return rc;
     765}
     766
     767static int rdwr_ipc_internal(async_exch_t *exch, vfs_file_t *file,
     768    ipc_call_t *answer, bool read, void *data)
     769{
     770        rdwr_io_chunk_t *chunk = (rdwr_io_chunk_t *) data;
     771
     772        if (exch == NULL)
     773                return ENOENT;
     774       
     775        aid_t msg = async_send_fast(exch, read ? VFS_OUT_READ : VFS_OUT_WRITE,
     776            file->node->service_id, file->node->index, LOWER32(file->pos),
     777            UPPER32(file->pos), answer);
     778        if (msg == 0)
     779                return EINVAL;
     780
     781        int retval = async_data_read_start(exch, chunk->buffer, chunk->size);
     782        if (retval != EOK) {
     783                async_forget(msg);
     784                return retval;
     785        }
     786       
     787        sysarg_t rc;
     788        async_wait_for(msg, &rc);
     789       
     790        chunk->size = IPC_GET_ARG1(*answer);
     791
     792        return (int) rc;
     793}
     794
     795static int vfs_rdwr(int fd, bool read, rdwr_ipc_cb_t ipc_cb, void *ipc_cb_data)
    737796{
    738797        /*
     
    746805         */
    747806       
    748         int fd = IPC_GET_ARG1(*request);
    749        
    750807        /* Lookup the file structure corresponding to the file descriptor. */
    751808        vfs_file_t *file = vfs_file_get(fd);
    752         if (!file) {
    753                 async_answer_0(rid, ENOENT);
    754                 return;
    755         }
     809        if (!file)
     810                return ENOENT;
    756811       
    757812        /*
     
    786841        async_exch_t *fs_exch = vfs_exchange_grab(file->node->fs_handle);
    787842       
    788         /*
    789          * Make a VFS_READ/VFS_WRITE request at the destination FS server
    790          * and forward the IPC_M_DATA_READ/IPC_M_DATA_WRITE request to the
    791          * destination FS server. The call will be routed as if sent by
    792          * ourselves. Note that call arguments are immutable in this case so we
    793          * don't have to bother.
    794          */
    795         sysarg_t rc;
     843        if (!read && file->append)
     844                file->pos = file->node->size;
     845       
     846        /*
     847         * Handle communication with the endpoint FS.
     848         */
    796849        ipc_call_t answer;
    797         if (read) {
    798                 rc = async_data_read_forward_4_1(fs_exch, VFS_OUT_READ,
    799                     file->node->service_id, file->node->index,
    800                     LOWER32(file->pos), UPPER32(file->pos), &answer);
    801         } else {
    802                 if (file->append)
    803                         file->pos = file->node->size;
    804                
    805                 rc = async_data_write_forward_4_1(fs_exch, VFS_OUT_WRITE,
    806                     file->node->service_id, file->node->index,
    807                     LOWER32(file->pos), UPPER32(file->pos), &answer);
    808         }
     850        int rc = ipc_cb(fs_exch, file, &answer, read, ipc_cb_data);
    809851       
    810852        vfs_exchange_release(fs_exch);
     
    833875        vfs_file_put(file);     
    834876
    835         /*
    836          * FS server's reply is the final result of the whole operation we
    837          * return to the client.
    838          */
     877        return rc;
     878}
     879       
     880static void vfs_rdwr_client(ipc_callid_t rid, ipc_call_t *request, bool read)
     881{
     882        size_t bytes = 0;       
     883        int rc = vfs_rdwr(IPC_GET_ARG1(*request), read, rdwr_ipc_client,
     884            &bytes);
    839885        async_answer_1(rid, rc, bytes);
    840886}
    841887
     888int vfs_rdwr_internal(int fd, bool read, rdwr_io_chunk_t *chunk)
     889{
     890        return vfs_rdwr(fd, read, rdwr_ipc_internal, chunk);
     891}
     892
    842893void vfs_read(ipc_callid_t rid, ipc_call_t *request)
    843894{
    844         vfs_rdwr(rid, request, true);
     895        vfs_rdwr_client(rid, request, true);
    845896}
    846897
    847898void vfs_write(ipc_callid_t rid, ipc_call_t *request)
    848899{
    849         vfs_rdwr(rid, request, false);
     900        vfs_rdwr_client(rid, request, false);
    850901}
    851902
     
    893944               
    894945                file->pos += off;
    895                 newoff = (file->pos > OFF64_MAX) ?  OFF64_MAX : file->pos;
     946                newoff = (file->pos > OFF64_MAX) ? OFF64_MAX : file->pos;
    896947               
    897948                fibril_mutex_unlock(&file->lock);
Note: See TracChangeset for help on using the changeset viewer.