Changeset 0b99e40 in mainline


Ignore:
Timestamp:
2006-05-28T18:22:10Z (19 years ago)
Author:
Ondrej Palkovsky <ondrap@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2d1fde3b
Parents:
7f5b37a
Message:

Rough implementation of gettimeofday.
IPC_M_RECV_AS doesn't allow us to specify additional user parametrs. That
doesn't seem to be very configurable :-/

Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • init/init.c

    r7f5b37a r0b99e40  
    4545#include <ipc/fb.h>
    4646#include <async.h>
     47#include <time.h>
    4748
    4849int a;
     
    402403}
    403404
     405static void test_time(void)
     406{
     407        int rc;
     408        struct timeval tv;
     409        struct timezone tz;
     410
     411        while (1) {
     412                rc = gettimeofday(&tv, &tz);
     413                printf("Rc: %d, Secs: %d, Usecs: %d\n", rc, tv.tv_sec,
     414                       tv.tv_usec);
     415        }
     416}
    404417
    405418int main(int argc, char *argv[])
     
    421434//      test_pci();
    422435//      test_kbd();
    423         test_async_kbd();
     436        test_time();
     437//      test_async_kbd();
    424438//      test_fb();
    425439
  • libc/Makefile

    r7f5b37a r0b99e40  
    6666        generic/async.c \
    6767        generic/libadt/list.o \
    68         generic/libadt/hash_table.o
     68        generic/libadt/hash_table.o \
     69        generic/time.c
    6970
    7071ARCH_SOURCES += \
  • libc/generic/async.c

    r7f5b37a r0b99e40  
    332332        ipc_call_t call;
    333333        ipc_callid_t callid;
     334        int timeout;
    334335
    335336        while (1) {
     
    340341                        continue;
    341342                }
    342                 callid = ipc_wait_cycle(&call,SYNCH_NO_TIMEOUT,SYNCH_BLOCKING);
     343/*
     344                if (expires)
     345                        timeout = .... ;
     346                else
     347*/
     348                        timeout = SYNCH_NO_TIMEOUT;
     349                callid = ipc_wait_cycle(&call, timeout, SYNCH_BLOCKING);
     350
     351                if (!callid) {
     352//                      handle_expired_timeouts.......;
     353                        continue;
     354                }
    343355
    344356                if (callid & IPC_CALLID_ANSWERED)
     
    405417        if (msg->dataptr)
    406418                *msg->dataptr = *data;
    407        
     419
     420        /* TODO: memory barrier?? */
    408421        msg->done = 1;
    409422        if (! msg->active) {
     
    461474        free(msg);
    462475}
     476
     477
     478/* int async_wait_timeout(aid_t amsgid, ipcarg_t *retval, int timeout) */
     479/* { */
     480/*      amsg_t *msg = (amsg_t *) amsgid; */
     481/*      connection_t *conn; */
     482
     483/*      futex_down(&async_futex); */
     484/*      if (msg->done) { */
     485/*              futex_up(&async_futex); */
     486/*              goto done; */
     487/*      } */
     488
     489/*      msg->ptid = psthread_get_id(); */
     490/*      msg->active = 0; */
     491/*      msg->expires = gettime() + timeout; */
     492/*      setup_timeouts_etc...(); */
     493
     494/*      /\* Leave locked async_futex when entering this function *\/ */
     495/*      psthread_schedule_next_adv(PS_TO_MANAGER); */
     496/*      /\* futex is up automatically after psthread_schedule_next...*\/ */
     497
     498/*      if (!msg->done) */
     499/*              return casy-casy; */
     500
     501/*      /\* TODO: When memory barrier in reply_received, we can skip this *\/ */
     502/*      futex_down(&async_futex); */
     503/*      futex_up(&async_futex); */
     504/* done: */
     505       
     506/*      if (retval) */
     507/*              *retval = msg->retval; */
     508/*      free(msg); */
     509/* } */
     510
  • libc/include/ipc/services.h

    r7f5b37a r0b99e40  
    3838#define SERVICE_FRAME_BUFFER    2
    3939#define SERVICE_KEYBOARD        3
    40 #define SERVICE_VIDEO   4
     40#define SERVICE_VIDEO           4
     41
     42/* Memory area to be received from NS */
     43#define SERVICE_MEM_REALTIME    1
    4144
    4245#endif
  • ns/ns.c

    r7f5b37a r0b99e40  
    4141#include <libadt/list.h>
    4242#include <libadt/hash_table.h>
     43#include <sysinfo.h>
     44#include <ddi.h>
     45#include <as.h>
    4346
    4447#define NAME    "NS"
     
    7376
    7477int static ping_phone;
     78
     79static void get_realtime_as(ipc_callid_t callid, ipc_call_t *call)
     80{
     81        static void *addr = NULL;
     82        void *ph_addr;
     83
     84        if (IPC_GET_ARG3(*call) != (AS_AREA_READ | AS_AREA_CACHEABLE)) {
     85                ipc_answer_fast(callid, EPERM, 0, 0);
     86                return;
     87        }
     88        if (!addr) {
     89                ph_addr = (void *)sysinfo_value("clock.faddr");
     90                if (!ph_addr) {
     91                        ipc_answer_fast(callid, ENOENT, 0, 0);
     92                        return;
     93                }
     94                addr = (void *)(200*1024*1024); /* TODO: intelligent freemem space */
     95                map_physmem(task_get_id(), ph_addr, addr, 1,
     96                            AS_AREA_READ | AS_AREA_CACHEABLE);
     97        }
     98        ipc_answer_fast(callid, 0, (ipcarg_t)addr, 0);
     99}
    75100
    76101int main(int argc, char **argv)
     
    103128//                              printf("Failed answer: %d\n", retval);
    104129                        continue;
    105                         break;
     130                case IPC_M_AS_AREA_RECV:
     131                        get_realtime_as(callid, &call);
     132                        continue;
    106133                case IPC_M_INTERRUPT:
    107 //                      printf("GOT INTERRUPT: %c\n", IPC_GET_ARG2(call));
    108134                        break;
    109135                case IPC_M_PHONE_HUNGUP:
    110 //                      printf("Phone hung up.\n");
    111136                        retval = 0;
    112137                        break;
Note: See TracChangeset for help on using the changeset viewer.