Subversion Repositories HelenOS

Rev

Rev 2131 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2006 decky 1
/*
2071 jermar 2
 * Copyright (c) 2006 Martin Decky
2006 decky 3
 * All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 *
9
 * - Redistributions of source code must retain the above copyright
10
 *   notice, this list of conditions and the following disclaimer.
11
 * - Redistributions in binary form must reproduce the above copyright
12
 *   notice, this list of conditions and the following disclaimer in the
13
 *   documentation and/or other materials provided with the distribution.
14
 * - The name of the author may not be used to endorse or promote products
15
 *   derived from this software without specific prior written permission.
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
 */
28
 
29
/** @addtogroup fs
30
 * @{
31
 */
32
 
33
/**
34
 * @file    fs.c
35
 * @brief   File system driver for HelenOS.
36
 */
37
 
2248 jelen 38
#include <ipc/ipc.h>
39
#include <ipc/services.h>
40
#include <ipc/ns.h>
41
#include <sysinfo.h>
42
#include <stdio.h>
43
#include <stdlib.h>
44
#include <as.h>
45
#include <ddi.h>
46
#include <align.h>
47
#include <bool.h>
48
#include <errno.h>
49
#include <async.h>
50
#include "fs.h"
2006 decky 51
 
2248 jelen 52
 
53
static void fs_connection(ipc_callid_t iid, ipc_call_t *icall)
54
{
55
    ipc_callid_t callid;
56
    ipc_call_t call;
57
    int retval;
58
 
59
    ipc_answer_fast(iid, 0, 0, 0);
60
 
61
    while (1) {
62
        callid = async_get_call(&call);
63
        switch (IPC_GET_METHOD(call)) {
64
        case IPC_M_PHONE_HUNGUP:
65
            ipc_answer_fast(callid, 0,0,0);
66
            return;
67
        case FS_OPEN:
68
            //Why doesn't printf do anything in this task?
69
            printf("FS_OPEN called");  
70
            char * f_name = (char *) IPC_GET_ARG1(call);
71
            printf("I should open file: %s \n",f_name);
72
            retval = 73;
73
            break;
74
        case FS_READ:
75
            printf("FS_READ called");
76
            unsigned int file_handle = IPC_GET_ARG1(call);
77
            void * buffer = (void *) IPC_GET_ARG2(call);
78
            unsigned int count = IPC_GET_ARG3(call);
79
            //I still don't know how to copy memory to another task :(
80
            //Or can i only map memory?
81
            retval = 0;
82
            break;
83
        default:
84
            retval = EINVAL;
85
        }
86
        ipc_answer_fast(callid, retval, 0, 0);
87
    }  
88
}
89
 
90
 
91
static bool fs_init(void)
92
{
93
 
94
    return true;
95
}
96
 
2006 decky 97
int main(int argc, char **argv)
98
{
2248 jelen 99
    if (fs_init()) {
100
        ipcarg_t phonead;
101
 
102
        async_set_client_connection(fs_connection);
103
 
104
        /* Register service at nameserver */
105
        if (ipc_connect_to_me(PHONE_NS, SERVICE_FS, 0, &phonead) != 0)
106
            return -1;
107
 
108
        async_manager();
109
 
110
        /* Never reached */
111
        return 0;
112
    }
113
 
114
    return -1;
2006 decky 115
}
116
 
117
/**
118
 * @}
119
 */