Changeset 250717cc in mainline


Ignore:
Timestamp:
2006-05-16T09:30:42Z (19 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ec153a0
Parents:
51d6f80
Message:

Add services.h to codify service numbers.
Assign codes for PCI, keyboard and frame buffer services.

Rename ipc_answer() to ipc_answer_fast() and add the basic
slower variant and call it ipc_answer(). Add some doxygen comments.

Remove unused bits from the libpci library.

Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • init/init.c

    r51d6f80 r250717cc  
    2929#include "version.h"
    3030#include <ipc.h>
     31#include <services.h>
    3132#include <stdio.h>
    3233#include <unistd.h>
     
    4041#include <ddi.h>
    4142#include <string.h>
     43#include <errno.h>
    4244#include <kbd.h>
    4345
     
    203205                callid = ipc_wait_for_call(&data, NULL);
    204206                printf("Received ping\n");
    205                 ipc_answer(callid, 0, 0, 0);
     207                ipc_answer_fast(callid, 0, 0, 0);
    206208        }
    207209//      callid = ipc_wait_for_call(&data, NULL);
     
    301303
    302304        printf("Test: Starting connect...\n");
    303         while ((phoneid = ipc_connect_me_to(PHONE_NS, 30, 60)) < 0) {
     305        while ((phoneid = ipc_connect_me_to(PHONE_NS, SERVICE_KEYBOARD, 0)) < 0) {
    304306        };
    305307       
     
    314316        printf("Test: Hangin up\n");
    315317        ipc_hangup(phoneid);
     318}
     319
     320static void test_pci()
     321{
     322        int phone;
     323        while ((phone = ipc_connect_me_to(PHONE_NS, SERVICE_PCI, 0)) < 0)
     324                ;
     325        printf("Connected to PCI service through phone %d.\n", phone);
    316326}
    317327
     
    355365//      test_slam();
    356366//      test_as_send();
     367        test_pci();
    357368        test_kbd();
    358369
     
    378389
    379390        int i;
    380        
     391
    381392        for (i = 0; i < 50000000; i++)
    382393                ;
     
    401412        printf("Main thread exiting.\n");
    402413*/
     414
    403415        return 0;
    404416}
  • kbd/generic/kbd.c

    r51d6f80 r250717cc  
    2828
    2929#include <ipc.h>
     30#include <services.h>
    3031#include <stdio.h>
    3132#include <unistd.h>
     
    7172        printf("%s: Registering at naming service.\n", NAME);
    7273
    73         if ((res = ipc_connect_to_me(PHONE_NS, 30, 60, &phonead)) != 0) {
     74        if ((res = ipc_connect_to_me(PHONE_NS, SERVICE_KEYBOARD, 0, &phonead)) != 0) {
    7475                printf("%s: Error: Registering at naming service failed.\n", NAME);
    7576                return -1;
     
    139140                if (! (callid & IPC_CALLID_NOTIFICATION)) {
    140141                //      printf("%s: Answering\n", NAME);
    141                         ipc_answer(callid, retval, arg1, arg2);
     142                        ipc_answer_fast(callid, retval, arg1, arg2);
    142143                }
    143144        }
  • libipc/generic/ipc.c

    r51d6f80 r250717cc  
    148148
    149149
    150 /** Send answer to a received call */
    151 ipcarg_t ipc_answer(ipc_callid_t callid, ipcarg_t retval, ipcarg_t arg1,
     150/** Send a fast answer to a received call.
     151 *
     152 * The fast answer makes use of passing retval and first two arguments in registers.
     153 * If you need to return more, use the ipc_answer() instead.
     154 *
     155 * @param callid ID of the call being answered.
     156 * @param retval Return value.
     157 * @param arg1 First return argument.
     158 * @param arg2 Second return argument.
     159 *
     160 * @return Zero on success or a value from @ref errno.h on failure.
     161 */
     162ipcarg_t ipc_answer_fast(ipc_callid_t callid, ipcarg_t retval, ipcarg_t arg1,
    152163                ipcarg_t arg2)
    153164{
    154165        return __SYSCALL4(SYS_IPC_ANSWER_FAST, callid, retval, arg1, arg2);
    155166}
     167
     168/** Send a full answer to a received call.
     169 *
     170 * @param callid ID of the call being answered.
     171 * @param call Call data. Must be already initialized by the responder.
     172 *
     173 * @return Zero on success or a value from @ref errno.h on failure.
     174 */
     175ipcarg_t ipc_answer(ipc_callid_t callid, ipc_call_t *call)
     176{
     177        return __SYSCALL2(SYS_IPC_ANSWER, callid, (sysarg_t) call);
     178}
     179
    156180
    157181/** Try to dispatch queed calls from async queue */
  • libipc/include/ipc.h

    r51d6f80 r250717cc  
    5555                         ipcarg_t *result);
    5656extern ipc_callid_t ipc_wait_for_call(ipc_call_t *data, int flags);
    57 extern ipcarg_t ipc_answer(ipc_callid_t callid, ipcarg_t retval, ipcarg_t arg1,
     57extern ipcarg_t ipc_answer_fast(ipc_callid_t callid, ipcarg_t retval, ipcarg_t arg1,
    5858                           ipcarg_t arg2);
     59extern ipcarg_t ipc_answer(ipc_callid_t callid, ipc_call_t *call);
    5960
    6061#define ipc_call_async(phoneid,method,arg1,private, callback) (ipc_call_async_2(phoneid, method, arg1, 0, private, callback))
  • ns/ns.c

    r51d6f80 r250717cc  
    7272} hashed_service_t;
    7373
    74 /*
    75 irq_cmd_t msim_cmds[1] = {
    76         { CMD_MEM_READ_1, (void *)0xB0000000, 0 }
    77 };
    78 
    79 irq_code_t msim_kbd = {
    80         1,
    81         msim_cmds
    82 };
    83 */
    84 /*
    85 irq_cmd_t i8042_cmds[1] = {
    86         { CMD_PORT_READ_1, (void *)0x60, 0 }
    87 };
    88 
    89 irq_code_t i8042_kbd = {
    90         1,
    91         i8042_cmds
    92 };
    93 */
    94 
    95 
    9674int static ping_phone;
    9775
     
    11088                return ENOMEM;
    11189        }
    112        
    113        
    114 //      ipc_register_irq(2, &msim_kbd);
    115 //      ipc_register_irq(1, &i8042_kbd);
     90               
    11691        while (1) {
    11792                callid = ipc_wait_for_call(&call, 0);
    118                 printf("NS: Call in_phone_hash=%lX...", call.in_phone_hash);
     93//              printf("NS: Call in_phone_hash=%lX...", call.in_phone_hash);
    11994                switch (IPC_GET_METHOD(call)) {
    12095                case IPC_M_AS_SEND:
    12196                        as = (char *)IPC_GET_ARG2(call);
    12297                        printf("Received as: %P, size:%d\n", as, IPC_GET_ARG3(call));
    123                         retval = ipc_answer(callid, 0,(sysarg_t)(1024*1024), 0);
     98                        retval = ipc_answer_fast(callid, 0,(sysarg_t)(1024*1024), 0);
    12499                        if (!retval) {
    125100                                printf("Reading shared memory...");
     
    171146                }
    172147                if (! (callid & IPC_CALLID_NOTIFICATION)) {
    173                         printf("Answering.\n");
    174                         ipc_answer(callid, retval, arg1, arg2);
     148//                      printf("Answering.\n");
     149                        ipc_answer_fast(callid, retval, arg1, arg2);
    175150                }
    176151        }
     
    228203        hlp = hash_table_find(&ns_hash_table, keys);
    229204        if (!hlp) {
    230                 printf("Service %d not registered.\n", service);
     205//              printf("Service %d not registered.\n", service);
    231206                return ENOENT;
    232207        }
  • pci/libpci/pci.h

    r51d6f80 r250717cc  
    5050        struct id_entry **id_hash;      /* names.c */
    5151        struct id_bucket *current_id_bucket;
    52         int fd;                 /* proc: fd */
    53         int fd_rw;              /* proc: fd opened read-write */
    54         struct pci_dev *cached_dev;     /* proc: device the fd is for */
    55         int fd_pos;             /* proc: current position */
    5652};
    5753
     
    117113
    118114/*
    119  *      Filters
    120  */
    121 
    122 struct pci_filter {
    123         int domain, bus, slot, func;    /* -1 = ANY */
    124         int vendor, device;
    125 };
    126 
    127 void pci_filter_init(struct pci_access *, struct pci_filter *);
    128 char *pci_filter_parse_slot(struct pci_filter *, char *);
    129 char *pci_filter_parse_id(struct pci_filter *, char *);
    130 int pci_filter_match(struct pci_filter *, struct pci_dev *);
    131 
    132 /*
    133115 *      Conversion of PCI ID's to names (according to the pci.ids file)
    134116 *
  • pci/pci.c

    r51d6f80 r250717cc  
    1515#include <stdlib.h>
    1616#include <ipc.h>
     17#include <services.h>
    1718#include <errno.h>
    1819
     
    2425#define NAME            "PCI"
    2526
     27static struct pci_access *pacc;
     28
    2629int main(int argc, char *argv[])
    2730{
    28         struct pci_access *pacc;
    2931        struct pci_dev *dev;
    3032        unsigned int c;
    3133        char buf[80];
    32 
    33         int ipc_res;
    3434        ipcarg_t ns_in_phone_hash;
    3535
     
    5353                        dev->vendor_id, dev->device_id));
    5454        }
    55         pci_cleanup(pacc);            /* Close everything */
    5655
    5756        printf("%s: registering at naming service.\n", NAME);
    58         if (ipc_connect_to_me(PHONE_NS, 40, 70, &ns_in_phone_hash) != 0) {
     57        if (ipc_connect_to_me(PHONE_NS, SERVICE_PCI, 0, &ns_in_phone_hash) != 0) {
    5958                printf("Failed to register %s at naming service.\n", NAME);
    6059                return -1;
    6160        }
    62        
     61
    6362        printf("%s: accepting connections\n", NAME);
    64         while (1) {
     63        while (1) {             
    6564                ipc_call_t call;
    6665                ipc_callid_t callid;
    67                
     66                int retval;
     67
    6868                callid = ipc_wait_for_call(&call, 0);
    69                 ipc_answer(callid, EHANGUP, 0, 0);
     69                switch(IPC_GET_METHOD(call)) {
     70                case IPC_M_CONNECT_ME_TO:
     71                        IPC_SET_RETVAL(call, 0);
     72                        break;
     73                }
     74                if (! (callid & IPC_CALLID_NOTIFICATION)) {
     75                        ipc_answer(callid, &call);
     76                }
     77                printf("%s: received call from %lX\n", NAME, call.in_phone_hash);
    7078        }
     79
     80        pci_cleanup(pacc);
    7181        return 0;
    7282}
Note: See TracChangeset for help on using the changeset viewer.