Changeset dffabf0 in mainline


Ignore:
Timestamp:
2011-01-05T19:08:03Z (13 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f03d3786
Parents:
e84d65a (diff), 196ef08 (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 mainline changes

Conflicts: no problem solving.
Added new apps to ignore list.

Files:
8 added
3 deleted
47 edited
1 moved

Legend:

Unmodified
Added
Removed
  • .bzrignore

    re84d65a rdffabf0  
    4444./uspace/app/getterm/getterm
    4545./uspace/app/init/init
     46./uspace/app/kill/kill
     47./uspace/app/killall/killall
    4648./uspace/app/klog/klog
    4749./uspace/app/mkfat/mkfat
     
    6567./uspace/app/usbinfo/usbinfo
    6668./uspace/app/virtusbkbd/vuk
     69./uspace/app/websrv/websrv
    6770./uspace/dist/app/*
    6871./uspace/dist/cfg/net/general
  • boot/Makefile.common

    re84d65a rdffabf0  
    101101        $(USPACE_PATH)/srv/hw/bus/usb/hcd/virtual/vhcd \
    102102        $(USPACE_PATH)/srv/net/netif/lo/lo \
     103        $(USPACE_PATH)/srv/net/nil/eth/eth \
     104        $(USPACE_PATH)/srv/net/nil/nildummy/nildummy \
    103105        $(USPACE_PATH)/srv/net/il/arp/arp \
    104106        $(USPACE_PATH)/srv/net/il/ip/ip \
     
    117119RD_DRV_CFG =
    118120
    119 ifneq ($(CONFIG_NETIF_NIL_BUNDLE),y)
    120         RD_SRVS_NON_ESSENTIAL += \
    121                 $(USPACE_PATH)/srv/net/nil/eth/eth \
    122                 $(USPACE_PATH)/srv/net/nil/nildummy/nildummy
    123 endif
    124 
    125121RD_APPS_ESSENTIAL = \
    126122        $(USPACE_PATH)/app/bdsh/bdsh \
     
    130126RD_APPS_NON_ESSENTIAL = \
    131127        $(USPACE_PATH)/app/edit/edit \
     128        $(USPACE_PATH)/app/kill/kill \
     129        $(USPACE_PATH)/app/killall/killall \
    132130        $(USPACE_PATH)/app/mkfat/mkfat \
    133131        $(USPACE_PATH)/app/sbi/sbi \
     
    148146        $(USPACE_PATH)/app/top/top \
    149147        $(USPACE_PATH)/app/usbinfo/usbinfo \
    150         $(USPACE_PATH)/app/virtusbkbd/vuk
     148        $(USPACE_PATH)/app/virtusbkbd/vuk \
     149        $(USPACE_PATH)/app/websrv/websrv
    151150
    152151ifneq ($(CONFIG_BAREBONE),y)
  • boot/arch/ia64/Makefile.inc

    re84d65a rdffabf0  
    3434ENDIANESS = LE
    3535PAGE_SIZE = 16384
    36 EXTRA_CFLAGS = -fno-unwind-tables -mfixed-range=f32-f127 -mno-pic
     36EXTRA_CFLAGS = -fno-unwind-tables -mfixed-range=f32-f127 -mno-pic -mno-sdata
    3737
    3838RD_SRVS_NON_ESSENTIAL +=
  • contrib/conf/net-qe.sh

    re84d65a rdffabf0  
    11#!/bin/sh
    22
    3 arguments="-vga std -M isapc -net nic,model=ne2k_isa -net user -boot d -redir udp:8080::8080 -redir udp:8081::8081 -redir tcp:8080::8080 -redir tcp:8081::8081 -cdrom image.iso"
     3# Obsolete versions of QEMU
     4#
     5#   QEMU 0.10.2 and later 0.10.*
     6#    qemu $@ -no-kqemu -vga std -M isapc -net nic,model=ne2k_isa -net user -boot d -redir udp:8080::8080 -redir udp:8081::8081 -redir tcp:8080::8080 -redir tcp:8081::8081 -cdrom image.iso
     7#
     8#   QEMU 0.11.* and 0.12.*
     9#    qemu $@ -vga std -M isapc -net nic,model=ne2k_isa -net user -boot d -redir udp:8080::8080 -redir udp:8081::8081 -redir tcp:8080::8080 -redir tcp:8081::8081 -cdrom image.iso
    410
    5 #qemu 0.10.2 and later 0.10.*:
    6 #qemu $@ -no-kqemu $arguments
    7 
    8 #qemu 0.11:
    9 qemu $@ $arguments
     11# QEMU 0.13 and later
     12qemu $@ -device ne2k_isa,irq=5,vlan=0 -net user -boot d -redir udp:8080::8080 -redir udp:8081::8081 -redir tcp:8080::8080 -redir tcp:8081::8081 -cdrom image.iso
  • defaults/amd64/Makefile.config

    re84d65a rdffabf0  
    6565CONFIG_MOUNT_DATA = n
    6666
    67 # Bundle netif/nil network layer
    68 CONFIG_NETIF_NIL_BUNDLE = n
  • defaults/arm32/Makefile.config

    re84d65a rdffabf0  
    4141CONFIG_MOUNT_DATA = n
    4242
    43 # Bundle netif/nil network layer
    44 CONFIG_NETIF_NIL_BUNDLE = n
  • defaults/ia32/Makefile.config

    re84d65a rdffabf0  
    7171CONFIG_MOUNT_DATA = n
    7272
    73 # Bundle netif/nil network layer
    74 CONFIG_NETIF_NIL_BUNDLE = n
  • defaults/ia64/Makefile.config

    re84d65a rdffabf0  
    5353CONFIG_MOUNT_DATA = n
    5454
    55 # Bundle netif/nil network layer
    56 CONFIG_NETIF_NIL_BUNDLE = n
  • defaults/mips32/Makefile.config

    re84d65a rdffabf0  
    4747CONFIG_MOUNT_DATA = n
    4848
    49 # Bundle netif/nil network layer
    50 CONFIG_NETIF_NIL_BUNDLE = n
  • defaults/ppc32/Makefile.config

    re84d65a rdffabf0  
    4747CONFIG_MOUNT_DATA = n
    4848
    49 # Bundle netif/nil network layer
    50 CONFIG_NETIF_NIL_BUNDLE = n
  • defaults/sparc64/Makefile.config

    re84d65a rdffabf0  
    6262CONFIG_MOUNT_DATA = n
    6363
    64 # Bundle netif/nil network layer
    65 CONFIG_NETIF_NIL_BUNDLE = n
  • defaults/special/Makefile.config

    re84d65a rdffabf0  
    3232CONFIG_START_BD = n
    3333
    34 # Bundle netif/nil network layer
    35 CONFIG_NETIF_NIL_BUNDLE = n
  • kernel/arch/ia32/include/interrupt.h

    re84d65a rdffabf0  
    5555#define IRQ_PIC_SPUR  7
    5656#define IRQ_MOUSE     12
    57 #define IRQ_DP8390    9
     57#define IRQ_DP8390    5
    5858
    5959/* This one must have four least significant bits set to ones */
  • kernel/generic/include/interrupt.h

    re84d65a rdffabf0  
    6060extern void fault_if_from_uspace(istate_t *, const char *, ...)
    6161    PRINTF_ATTRIBUTE(2, 3);
     62extern istate_t *istate_get(thread_t *);
    6263extern iroutine_t exc_register(unsigned int, const char *, bool, iroutine_t);
    6364extern void exc_dispatch(unsigned int, istate_t *);
  • kernel/generic/include/proc/task.h

    re84d65a rdffabf0  
    154154
    155155extern sysarg_t sys_task_set_name(const char *, size_t);
     156extern sysarg_t sys_task_kill(task_id_t *);
    156157
    157158#endif
  • kernel/generic/include/syscall/syscall.h

    re84d65a rdffabf0  
    4747        SYS_TASK_GET_ID,
    4848        SYS_TASK_SET_NAME,
     49        SYS_TASK_KILL,
    4950        SYS_PROGRAM_SPAWN_LOADER,
    5051       
  • kernel/generic/src/interrupt/interrupt.c

    re84d65a rdffabf0  
    209209}
    210210
     211/** Get istate structure of a thread.
     212 *
     213 * Get pointer to the istate structure at the bottom of the kernel stack.
     214 *
     215 * This function can be called in interrupt or user context. In interrupt
     216 * context the istate structure is created by the low-level exception
     217 * handler. In user context the istate structure is created by the
     218 * low-level syscall handler.
     219 */
     220istate_t *istate_get(thread_t *thread)
     221{
     222        /*
     223         * The istate structure should be right at the bottom of the kernel
     224         * stack.
     225         */
     226        return (istate_t *) ((uint8_t *) thread->kstack + THREAD_STACK_SIZE -
     227            sizeof(istate_t));
     228}
     229
    211230#ifdef CONFIG_KCONSOLE
    212231
  • kernel/generic/src/main/main.c

    re84d65a rdffabf0  
    185185        LOG("\nconfig.base=%p config.kernel_size=%zu"
    186186            "\nconfig.stack_base=%p config.stack_size=%zu",
    187             config.base, config.kernel_size, config.stack_base,
    188             config.stack_size);
     187            (void *) config.base, config.kernel_size,
     188            (void *) config.stack_base, config.stack_size);
    189189       
    190190#ifdef CONFIG_KCONSOLE
     
    242242                for (i = 0; i < init.cnt; i++)
    243243                        LOG("init[%zu].addr=%p, init[%zu].size=%zu",
    244                             i, init.tasks[i].addr, i, init.tasks[i].size);
     244                            i, (void *) init.tasks[i].addr, i, init.tasks[i].size);
    245245        } else
    246246                printf("No init binaries found.\n");
  • kernel/generic/src/proc/task.c

    re84d65a rdffabf0  
    360360}
    361361
     362/** Syscall to forcefully terminate a task
     363 *
     364 * @param uspace_taskid Pointer to task ID in user space.
     365 *
     366 * @return 0 on success or an error code from @ref errno.h.
     367 *
     368 */
     369sysarg_t sys_task_kill(task_id_t *uspace_taskid)
     370{
     371        task_id_t taskid;
     372        int rc;
     373
     374        rc = copy_from_uspace(&taskid, uspace_taskid, sizeof(taskid));
     375        if (rc != 0)
     376                return (sysarg_t) rc;
     377
     378        return (sysarg_t) task_kill(taskid);
     379}
     380
    362381/** Find task structure corresponding to task ID.
    363382 *
  • kernel/generic/src/syscall/syscall.c

    re84d65a rdffabf0  
    4545#include <debug.h>
    4646#include <ddi/device.h>
     47#include <interrupt.h>
    4748#include <ipc/sysipc.h>
    4849#include <synch/futex.h>
     
    6667#ifdef CONFIG_UDEBUG
    6768        /*
     69         * An istate_t-compatible record was created on the stack by the
     70         * low-level syscall handler. This is the userspace space state
     71         * structure.
     72         */
     73        THREAD->udebug.uspace_state = istate_get(THREAD);
     74
     75        /*
    6876         * Early check for undebugged tasks. We do not lock anything as this
    6977         * test need not be precise in either direction.
    70          *
    7178         */
    7279        if (THREAD->udebug.active)
     
    98105                udebug_stoppable_end();
    99106        }
     107
     108        /* Clear userspace state pointer */
     109        THREAD->udebug.uspace_state = NULL;
    100110#endif
    101111       
     
    120130        (syshandler_t) sys_task_get_id,
    121131        (syshandler_t) sys_task_set_name,
     132        (syshandler_t) sys_task_kill,
    122133        (syshandler_t) sys_program_spawn_loader,
    123134       
  • uspace/Makefile

    re84d65a rdffabf0  
    3838        app/getterm \
    3939        app/init \
     40        app/kill \
     41        app/killall \
    4042        app/klog \
    4143        app/mkfat \
     
    5557        app/nettest2 \
    5658        app/ping \
     59        app/websrv \
    5760        app/sysinfo \
    5861        srv/clip \
     
    9699#
    97100
    98 ifeq ($(CONFIG_NETIF_NIL_BUNDLE),y)
    99         LIBN = \
    100                 srv/net/nil/eth \
    101                 srv/net/nil/nildummy
    102 else
    103         DIRS += \
    104                 srv/net/nil/eth \
    105                 srv/net/nil/nildummy
    106 endif
     101DIRS += \
     102        srv/net/nil/eth \
     103        srv/net/nil/nildummy
    107104
    108105## Platform-specific hardware support
  • uspace/app/init/init.c

    re84d65a rdffabf0  
    6161
    6262#define DATA_FS_TYPE      "fat"
    63 #define DATA_DEVICE       "bd/disk0"
     63#define DATA_DEVICE       "bd/ata1disk0"
    6464#define DATA_MOUNT_POINT  "/data"
    6565
  • uspace/app/netecho/netecho.c

    re84d65a rdffabf0  
    3232
    3333/** @file
    34  * Network echo application.
    35  * Answers received packets.
     34 * Network echo server.
     35 *
     36 * Sockets-based server that echoes incomming messages. If stream mode
     37 * is selected, accepts incoming connections.
    3638 */
    3739
    38 #include <malloc.h>
     40#include <assert.h>
    3941#include <stdio.h>
     42#include <stdlib.h>
    4043#include <str.h>
    4144#include <task.h>
     
    5053#include "print_error.h"
    5154
    52 /** Network echo module name. */
    53 #define NAME    "Network Echo"
     55#define NAME "netecho"
     56
     57static int count = -1;
     58static int family = PF_INET;
     59static sock_type_t type = SOCK_DGRAM;
     60static uint16_t port = 7;
     61static int backlog = 3;
     62static size_t size = 1024;
     63static int verbose = 0;
     64
     65static char *reply = NULL;
     66static size_t reply_length;
     67
     68static char *data;
    5469
    5570static void echo_print_help(void)
    5671{
    5772        printf(
    58                 "Network Echo aplication\n" \
    59                 "Usage: echo [options]\n" \
    60                 "Where options are:\n" \
    61                 "-b backlog | --backlog=size\n" \
    62                 "\tThe size of the accepted sockets queue. Only for SOCK_STREAM. The default is 3.\n" \
    63                 "\n" \
    64                 "-c count | --count=count\n" \
    65                 "\tThe number of received messages to handle. A negative number means infinity. The default is infinity.\n" \
    66                 "\n" \
    67                 "-f protocol_family | --family=protocol_family\n" \
    68                 "\tThe listenning socket protocol family. Only the PF_INET and PF_INET6 are supported.\n"
    69                 "\n" \
    70                 "-h | --help\n" \
    71                 "\tShow this application help.\n"
    72                 "\n" \
    73                 "-p port_number | --port=port_number\n" \
    74                 "\tThe port number the application should listen at. The default is 7.\n" \
    75                 "\n" \
    76                 "-r reply_string | --reply=reply_string\n" \
    77                 "\tThe constant reply string. The default is the original data received.\n" \
    78                 "\n" \
    79                 "-s receive_size | --size=receive_size\n" \
    80                 "\tThe maximum receive data size the application should accept. The default is 1024 bytes.\n" \
    81                 "\n" \
    82                 "-t socket_type | --type=socket_type\n" \
    83                 "\tThe listenning socket type. Only the SOCK_DGRAM and the SOCK_STREAM are supported.\n" \
    84                 "\n" \
    85                 "-v | --verbose\n" \
    86                 "\tShow all output messages.\n"
     73            "Network echo server\n"
     74            "Usage: " NAME " [options]\n"
     75            "Where options are:\n"
     76            "-b backlog | --backlog=size\n"
     77            "\tThe size of the accepted sockets queue. Only for SOCK_STREAM. "
     78            "The default is 3.\n"
     79            "\n"
     80            "-c count | --count=count\n"
     81            "\tThe number of received messages to handle. A negative number "
     82            "means infinity. The default is infinity.\n"
     83            "\n"
     84            "-f protocol_family | --family=protocol_family\n"
     85            "\tThe listenning socket protocol family. Only the PF_INET and "
     86            "PF_INET6 are supported.\n"
     87            "\n"
     88            "-h | --help\n"
     89            "\tShow this application help.\n"
     90            "\n"
     91            "-p port_number | --port=port_number\n"
     92            "\tThe port number the application should listen at. The default "
     93            "is 7.\n"
     94            "\n"
     95            "-r reply_string | --reply=reply_string\n"
     96            "\tThe constant reply string. The default is the original data "
     97            "received.\n"
     98            "\n"
     99            "-s receive_size | --size=receive_size\n"
     100            "\tThe maximum receive data size the application should accept. "
     101            "The default is 1024 bytes.\n"
     102            "\n"
     103            "-t socket_type | --type=socket_type\n"
     104            "\tThe listenning socket type. Only the SOCK_DGRAM and the "
     105            "SOCK_STREAM are supported.\n"
     106            "\n"
     107            "-v | --verbose\n"
     108            "\tShow all output messages.\n"
    87109        );
    88110}
    89111
    90 int main(int argc, char *argv[])
     112static int netecho_parse_option(int argc, char *argv[], int *index)
    91113{
    92         size_t size = 1024;
    93         int verbose = 0;
    94         char *reply = NULL;
    95         sock_type_t type = SOCK_DGRAM;
    96         int count = -1;
    97         int family = PF_INET;
    98         uint16_t port = 7;
    99         int backlog = 3;
    100 
    101         socklen_t max_length = sizeof(struct sockaddr_in6);
    102         uint8_t address_data[max_length];
    103         struct sockaddr *address = (struct sockaddr *) address_data;
    104         struct sockaddr_in *address_in = (struct sockaddr_in *) address;
    105         struct sockaddr_in6 *address_in6 = (struct sockaddr_in6 *) address;
    106         socklen_t addrlen;
    107         char address_string[INET6_ADDRSTRLEN];
    108         uint8_t *address_start;
    109         int socket_id;
    110         int listening_id;
    111         char *data;
    112         size_t length;
    113         int index;
    114         size_t reply_length;
    115114        int value;
    116115        int rc;
    117116
    118         // parse the command line arguments
    119         for (index = 1; index < argc; ++ index) {
    120                 if (argv[index][0] == '-') {
    121                         switch (argv[index][1]) {
    122                         case 'b':
    123                                 rc = arg_parse_int(argc, argv, &index, &backlog, 0);
    124                                 if (rc != EOK)
    125                                         return rc;
    126                                 break;
    127                         case 'c':
    128                                 rc = arg_parse_int(argc, argv, &index, &count, 0);
    129                                 if (rc != EOK)
    130                                         return rc;
    131                                 break;
    132                         case 'f':
    133                                 rc = arg_parse_name_int(argc, argv, &index, &family, 0, socket_parse_protocol_family);
    134                                 if (rc != EOK)
    135                                         return rc;
    136                                 break;
    137                         case 'h':
    138                                 echo_print_help();
    139                                 return EOK;
    140                                 break;
    141                         case 'p':
    142                                 rc = arg_parse_int(argc, argv, &index, &value, 0);
    143                                 if (rc != EOK)
    144                                         return rc;
    145                                 port = (uint16_t) value;
    146                                 break;
    147                         case 'r':
    148                                 rc = arg_parse_string(argc, argv, &index, &reply, 0);
    149                                 if (rc != EOK)
    150                                         return rc;
    151                                 break;
    152                         case 's':
    153                                 rc = arg_parse_int(argc, argv, &index, &value, 0);
    154                                 if (rc != EOK)
    155                                         return rc;
    156                                 size = (value >= 0) ? (size_t) value : 0;
    157                                 break;
    158                         case 't':
    159                                 rc = arg_parse_name_int(argc, argv, &index, &value, 0, socket_parse_socket_type);
    160                                 if (rc != EOK)
    161                                         return rc;
    162                                 type = (sock_type_t) value;
    163                                 break;
    164                         case 'v':
    165                                 verbose = 1;
    166                                 break;
    167                         // long options with the double minus sign ('-')
    168                         case '-':
    169                                 if (str_lcmp(argv[index] + 2, "backlog=", 6) == 0) {
    170                                         rc = arg_parse_int(argc, argv, &index, &backlog, 8);
    171                                         if (rc != EOK)
    172                                                 return rc;
    173                                 } else if (str_lcmp(argv[index] + 2, "count=", 6) == 0) {
    174                                         rc = arg_parse_int(argc, argv, &index, &count, 8);
    175                                         if (rc != EOK)
    176                                                 return rc;
    177                                 } else if (str_lcmp(argv[index] + 2, "family=", 7) == 0) {
    178                                         rc = arg_parse_name_int(argc, argv, &index, &family, 9, socket_parse_protocol_family);
    179                                         if (rc != EOK)
    180                                                 return rc;
    181                                 } else if (str_lcmp(argv[index] + 2, "help", 5) == 0) {
    182                                         echo_print_help();
    183                                         return EOK;
    184                                 } else if (str_lcmp(argv[index] + 2, "port=", 5) == 0) {
    185                                         rc = arg_parse_int(argc, argv, &index, &value, 7);
    186                                         if (rc != EOK)
    187                                                 return rc;
    188                                         port = (uint16_t) value;
    189                                 } else if (str_lcmp(argv[index] + 2, "reply=", 6) == 0) {
    190                                         rc = arg_parse_string(argc, argv, &index, &reply, 8);
    191                                         if (rc != EOK)
    192                                                 return rc;
    193                                 } else if (str_lcmp(argv[index] + 2, "size=", 5) == 0) {
    194                                         rc = arg_parse_int(argc, argv, &index, &value, 7);
    195                                         if (rc != EOK)
    196                                                 return rc;
    197                                         size = (value >= 0) ? (size_t) value : 0;
    198                                 } else if (str_lcmp(argv[index] + 2, "type=", 5) == 0) {
    199                                         rc = arg_parse_name_int(argc, argv, &index, &value, 7, socket_parse_socket_type);
    200                                         if (rc != EOK)
    201                                                 return rc;
    202                                         type = (sock_type_t) value;
    203                                 } else if (str_lcmp(argv[index] + 2, "verbose", 8) == 0) {
    204                                         verbose = 1;
    205                                 } else {
    206                                         echo_print_help();
    207                                         return EINVAL;
    208                                 }
    209                                 break;
    210                         default:
    211                                 echo_print_help();
    212                                 return EINVAL;
    213                         }
     117        switch (argv[*index][1]) {
     118        case 'b':
     119                rc = arg_parse_int(argc, argv, index, &backlog, 0);
     120                if (rc != EOK)
     121                        return rc;
     122                break;
     123        case 'c':
     124                rc = arg_parse_int(argc, argv, index, &count, 0);
     125                if (rc != EOK)
     126                        return rc;
     127                break;
     128        case 'f':
     129                rc = arg_parse_name_int(argc, argv, index, &family, 0,
     130                    socket_parse_protocol_family);
     131                if (rc != EOK)
     132                        return rc;
     133                break;
     134        case 'h':
     135                echo_print_help();
     136                exit(0);
     137                break;
     138        case 'p':
     139                rc = arg_parse_int(argc, argv, index, &value, 0);
     140                if (rc != EOK)
     141                        return rc;
     142                port = (uint16_t) value;
     143                break;
     144        case 'r':
     145                rc = arg_parse_string(argc, argv, index, &reply, 0);
     146                if (rc != EOK)
     147                        return rc;
     148                break;
     149        case 's':
     150                rc = arg_parse_int(argc, argv, index, &value, 0);
     151                if (rc != EOK)
     152                        return rc;
     153                size = (value >= 0) ? (size_t) value : 0;
     154                break;
     155        case 't':
     156                rc = arg_parse_name_int(argc, argv, index, &value, 0,
     157                    socket_parse_socket_type);
     158                if (rc != EOK)
     159                        return rc;
     160                type = (sock_type_t) value;
     161                break;
     162        case 'v':
     163                verbose = 1;
     164                break;
     165        /* Long options with double dash */
     166        case '-':
     167                if (str_lcmp(argv[*index] + 2, "backlog=", 6) == 0) {
     168                        rc = arg_parse_int(argc, argv, index, &backlog, 8);
     169                        if (rc != EOK)
     170                                return rc;
     171                } else if (str_lcmp(argv[*index] + 2, "count=", 6) == 0) {
     172                        rc = arg_parse_int(argc, argv, index, &count, 8);
     173                        if (rc != EOK)
     174                                return rc;
     175                } else if (str_lcmp(argv[*index] + 2, "family=", 7) == 0) {
     176                        rc = arg_parse_name_int(argc, argv, index, &family, 9,
     177                            socket_parse_protocol_family);
     178                        if (rc != EOK)
     179                                return rc;
     180                } else if (str_lcmp(argv[*index] + 2, "help", 5) == 0) {
     181                        echo_print_help();
     182                        exit(0);
     183                } else if (str_lcmp(argv[*index] + 2, "port=", 5) == 0) {
     184                        rc = arg_parse_int(argc, argv, index, &value, 7);
     185                        if (rc != EOK)
     186                                return rc;
     187                        port = (uint16_t) value;
     188                } else if (str_lcmp(argv[*index] + 2, "reply=", 6) == 0) {
     189                        rc = arg_parse_string(argc, argv, index, &reply, 8);
     190                        if (rc != EOK)
     191                                return rc;
     192                } else if (str_lcmp(argv[*index] + 2, "size=", 5) == 0) {
     193                        rc = arg_parse_int(argc, argv, index, &value, 7);
     194                        if (rc != EOK)
     195                                return rc;
     196                        size = (value >= 0) ? (size_t) value : 0;
     197                } else if (str_lcmp(argv[*index] + 2, "type=", 5) == 0) {
     198                        rc = arg_parse_name_int(argc, argv, index, &value, 7,
     199                            socket_parse_socket_type);
     200                        if (rc != EOK)
     201                                return rc;
     202                        type = (sock_type_t) value;
     203                } else if (str_lcmp(argv[*index] + 2, "verbose", 8) == 0) {
     204                        verbose = 1;
    214205                } else {
    215206                        echo_print_help();
    216207                        return EINVAL;
    217208                }
    218         }
    219 
    220         // check the buffer size
     209                break;
     210        default:
     211                echo_print_help();
     212                return EINVAL;
     213        }
     214
     215        return EOK;
     216}
     217
     218/** Echo one message (accept one connection and echo message).
     219 *
     220 * @param listening_id  Listening socket.
     221 * @return              EOK on success or negative error code.
     222 */
     223static int netecho_socket_process_message(int listening_id)
     224{
     225        uint8_t address_buf[sizeof(struct sockaddr_in6)];
     226
     227        socklen_t addrlen;
     228        int socket_id;
     229        ssize_t rcv_size;
     230        size_t length;
     231        uint8_t *address_start;
     232
     233        char address_string[INET6_ADDRSTRLEN];
     234        struct sockaddr_in *address_in = (struct sockaddr_in *) address_buf;
     235        struct sockaddr_in6 *address_in6 = (struct sockaddr_in6 *) address_buf;
     236        struct sockaddr *address = (struct sockaddr *) address_buf;
     237
     238        int rc;
     239
     240        if (type == SOCK_STREAM) {
     241                /* Accept a socket if a stream socket is used */
     242                addrlen = sizeof(address_buf);
     243                socket_id = accept(listening_id, (void *) address_buf, &addrlen);
     244                if (socket_id <= 0) {
     245                        socket_print_error(stderr, socket_id, "Socket accept: ", "\n");
     246                } else {
     247                        if (verbose)
     248                                printf("Socket %d accepted\n", socket_id);
     249                }
     250
     251                assert((size_t) addrlen <= sizeof(address_buf));
     252        } else {
     253                socket_id = listening_id;
     254        }
     255
     256        /* if the datagram socket is used or the stream socked was accepted */
     257        if (socket_id > 0) {
     258
     259                /* Receive a message to echo */
     260                rcv_size = recvfrom(socket_id, data, size, 0, address,
     261                    &addrlen);
     262                if (rcv_size < 0) {
     263                        socket_print_error(stderr, rcv_size, "Socket receive: ", "\n");
     264                } else {
     265                        length = (size_t) rcv_size;
     266                        if (verbose) {
     267                                /* Print the header */
     268
     269                                /* Get the source port and prepare the address buffer */
     270                                address_start = NULL;
     271                                switch (address->sa_family) {
     272                                case AF_INET:
     273                                        port = ntohs(address_in->sin_port);
     274                                        address_start = (uint8_t *) &address_in->sin_addr.s_addr;
     275                                        break;
     276                                case AF_INET6:
     277                                        port = ntohs(address_in6->sin6_port);
     278                                        address_start = (uint8_t *) &address_in6->sin6_addr.s6_addr;
     279                                        break;
     280                                default:
     281                                        fprintf(stderr, "Address family %u (%#x) is not supported.\n",
     282                                            address->sa_family, address->sa_family);
     283                                }
     284
     285                                /* Parse source address */
     286                                if (address_start) {
     287                                        rc = inet_ntop(address->sa_family, address_start, address_string, sizeof(address_string));
     288                                        if (rc != EOK) {
     289                                                fprintf(stderr, "Received address error %d\n", rc);
     290                                        } else {
     291                                                data[length] = '\0';
     292                                                printf("Socket %d received %zu bytes from %s:%d\n%s\n",
     293                                                    socket_id, length, address_string, port, data);
     294                                        }
     295                                }
     296                        }
     297
     298                        /* Answer the request either with the static reply or the original data */
     299                        rc = sendto(socket_id, reply ? reply : data, reply ? reply_length : length, 0, address, addrlen);
     300                        if (rc != EOK)
     301                                socket_print_error(stderr, rc, "Socket send: ", "\n");
     302                }
     303
     304                /* Close accepted stream socket */
     305                if (type == SOCK_STREAM) {
     306                        rc = closesocket(socket_id);
     307                        if (rc != EOK)
     308                                socket_print_error(stderr, rc, "Close socket: ", "\n");
     309                }
     310
     311        }
     312
     313        return EOK;
     314}
     315
     316
     317int main(int argc, char *argv[])
     318{
     319        struct sockaddr *address;;
     320        struct sockaddr_in address_in;
     321        struct sockaddr_in6 address_in6;
     322        socklen_t addrlen;
     323
     324        int listening_id;
     325        int index;
     326        int rc;
     327
     328        /* Parse command line arguments */
     329        for (index = 1; index < argc; ++index) {
     330                if (argv[index][0] == '-') {
     331                        rc = netecho_parse_option(argc, argv, &index);
     332                        if (rc != EOK)
     333                                return rc;
     334                } else {
     335                        echo_print_help();
     336                        return EINVAL;
     337                }
     338        }
     339
     340        /* Check buffer size */
    221341        if (size <= 0) {
    222342                fprintf(stderr, "Receive size too small (%zu). Using 1024 bytes instead.\n", size);
    223343                size = 1024;
    224344        }
    225         // size plus the terminating null (\0)
     345
     346        /* size plus the terminating null character. */
    226347        data = (char *) malloc(size + 1);
    227348        if (!data) {
     
    230351        }
    231352
    232         // set the reply size if set
     353        /* Set the reply size if set */
    233354        reply_length = reply ? str_length(reply) : 0;
    234355
    235         // prepare the address buffer
    236         bzero(address_data, max_length);
     356        /* Prepare the address buffer */
    237357        switch (family) {
    238358        case PF_INET:
    239                 address_in->sin_family = AF_INET;
    240                 address_in->sin_port = htons(port);
    241                 addrlen = sizeof(struct sockaddr_in);
     359                address_in.sin_family = AF_INET;
     360                address_in.sin_port = htons(port);
     361                address = (struct sockaddr *) &address_in;
     362                addrlen = sizeof(address_in);
    242363                break;
    243364        case PF_INET6:
    244                 address_in6->sin6_family = AF_INET6;
    245                 address_in6->sin6_port = htons(port);
    246                 addrlen = sizeof(struct sockaddr_in6);
     365                address_in6.sin6_family = AF_INET6;
     366                address_in6.sin6_port = htons(port);
     367                address = (struct sockaddr *) &address_in6;
     368                addrlen = sizeof(address_in6);
    247369                break;
    248370        default:
     
    251373        }
    252374
    253         // get a listening socket
     375        /* Get a listening socket */
    254376        listening_id = socket(family, type, 0);
    255377        if (listening_id < 0) {
     
    258380        }
    259381
    260         // if the stream socket is used
     382        /* if the stream socket is used */
    261383        if (type == SOCK_STREAM) {
    262                 // check the backlog
     384                /* Check backlog size */
    263385                if (backlog <= 0) {
    264386                        fprintf(stderr, "Accepted sockets queue size too small (%zu). Using 3 instead.\n", size);
    265387                        backlog = 3;
    266388                }
    267                 // set the backlog
     389
     390                /* Set the backlog */
    268391                rc = listen(listening_id, backlog);
    269392                if (rc != EOK) {
     
    273396        }
    274397
    275         // bind the listenning socket
     398        /* Bind the listening socket */
    276399        rc = bind(listening_id, address, addrlen);
    277400        if (rc != EOK) {
     
    283406                printf("Socket %d listenning at %d\n", listening_id, port);
    284407
    285         socket_id = listening_id;
    286 
    287         // do count times
    288         // or indefinitely if set to a negative value
     408        /*
     409         * do count times
     410         * or indefinitely if set to a negative value
     411         */
    289412        while (count) {
    290 
    291                 addrlen = max_length;
    292                 if (type == SOCK_STREAM) {
    293                         // acceept a socket if the stream socket is used
    294                         socket_id = accept(listening_id, address, &addrlen);
    295                         if (socket_id <= 0) {
    296                                 socket_print_error(stderr, socket_id, "Socket accept: ", "\n");
    297                         } else {
    298                                 if (verbose)
    299                                         printf("Socket %d accepted\n", socket_id);
    300                         }
    301                 }
    302 
    303                 // if the datagram socket is used or the stream socked was accepted
    304                 if (socket_id > 0) {
    305 
    306                         // receive an echo request
    307                         value = recvfrom(socket_id, data, size, 0, address, &addrlen);
    308                         if (value < 0) {
    309                                 socket_print_error(stderr, value, "Socket receive: ", "\n");
    310                         } else {
    311                                 length = (size_t) value;
    312                                 if (verbose) {
    313                                         // print the header
    314 
    315                                         // get the source port and prepare the address buffer
    316                                         address_start = NULL;
    317                                         switch (address->sa_family) {
    318                                         case AF_INET:
    319                                                 port = ntohs(address_in->sin_port);
    320                                                 address_start = (uint8_t *) &address_in->sin_addr.s_addr;
    321                                                 break;
    322                                         case AF_INET6:
    323                                                 port = ntohs(address_in6->sin6_port);
    324                                                 address_start = (uint8_t *) &address_in6->sin6_addr.s6_addr;
    325                                                 break;
    326                                         default:
    327                                                 fprintf(stderr, "Address family %u (%#x) is not supported.\n",
    328                                                     address->sa_family, address->sa_family);
    329                                         }
    330                                         // parse the source address
    331                                         if (address_start) {
    332                                                 rc = inet_ntop(address->sa_family, address_start, address_string, sizeof(address_string));
    333                                                 if (rc != EOK) {
    334                                                         fprintf(stderr, "Received address error %d\n", rc);
    335                                                 } else {
    336                                                         data[length] = '\0';
    337                                                         printf("Socket %d received %zu bytes from %s:%d\n%s\n",
    338                                                             socket_id, length, address_string, port, data);
    339                                                 }
    340                                         }
    341                                 }
    342 
    343                                 // answer the request either with the static reply or the original data
    344                                 rc = sendto(socket_id, reply ? reply : data, reply ? reply_length : length, 0, address, addrlen);
    345                                 if (rc != EOK)
    346                                         socket_print_error(stderr, rc, "Socket send: ", "\n");
    347                         }
    348 
    349                         // close the accepted stream socket
    350                         if (type == SOCK_STREAM) {
    351                                 rc = closesocket(socket_id);
    352                                 if (rc != EOK)
    353                                         socket_print_error(stderr, rc, "Close socket: ", "\n");
    354                         }
    355 
    356                 }
    357 
    358                 // decrease the count if positive
     413                rc = netecho_socket_process_message(listening_id);
     414                if (rc != EOK)
     415                        break;
     416
     417                /* Decrease count if positive */
    359418                if (count > 0) {
    360419                        count--;
    361420                        if (verbose)
    362                                 printf("Waiting for next %d packet(s)\n", count);
     421                                printf("Waiting for next %d message(s)\n", count);
    363422                }
    364423        }
     
    367426                printf("Closing the socket\n");
    368427
    369         // close the listenning socket
     428        /* Close listenning socket */
    370429        rc = closesocket(listening_id);
    371430        if (rc != EOK) {
  • uspace/app/taskdump/taskdump.c

    re84d65a rdffabf0  
    326326
    327327        sym_pc = fmt_sym_address(pc);
    328         printf("Thread %p crashed at %s. FP = %p\n", (void *) thash,
     328        printf("Thread %p: PC = %s. FP = %p\n", (void *) thash,
    329329            sym_pc, (void *) fp);
    330330        free(sym_pc);
  • uspace/lib/c/Makefile

    re84d65a rdffabf0  
    8787        generic/ipc.c \
    8888        generic/async.c \
    89         generic/async_rel.c \
     89        generic/async_sess.c \
    9090        generic/loader.c \
    9191        generic/getopt.c \
  • uspace/lib/c/generic/async.c

    re84d65a rdffabf0  
    749749                return ENOMEM;
    750750        }
     751
     752        _async_sess_init();
    751753       
    752754        return 0;
  • uspace/lib/c/generic/libc.c

    re84d65a rdffabf0  
    5050#include <ipc/ipc.h>
    5151#include <async.h>
    52 #include <async_rel.h>
    5352#include <as.h>
    5453#include <loader/pcb.h>
     
    6665        __heap_init();
    6766        __async_init();
    68         (void) async_rel_init();
    6967        fibril_t *fibril = fibril_setup();
    7068        __tcb_set(fibril->tcb);
  • uspace/lib/c/generic/net/icmp_api.c

    re84d65a rdffabf0  
    8989            tos, (sysarg_t) dont_fragment, NULL);
    9090
    91         // send the address
     91        /* Send the address */
    9292        async_data_write_start(icmp_phone, addr, (size_t) addrlen);
    9393
  • uspace/lib/c/generic/net/inet.c

    re84d65a rdffabf0  
    6464        switch (family) {
    6565        case AF_INET:
    66                 // check the output buffer size
     66                /* Check output buffer size */
    6767                if (length < INET_ADDRSTRLEN)
    6868                        return ENOMEM;
    6969                       
    70                 // fill the buffer with the IPv4 address
     70                /* Fill buffer with IPv4 address */
    7171                snprintf(address, length, "%hhu.%hhu.%hhu.%hhu",
    7272                    data[0], data[1], data[2], data[3]);
     
    7575
    7676        case AF_INET6:
    77                 // check the output buffer size
     77                /* Check output buffer size */
    7878                if (length < INET6_ADDRSTRLEN)
    7979                        return ENOMEM;
    8080               
    81                 // fill the buffer with the IPv6 address
     81                /* Fill buffer with IPv6 address */
    8282                snprintf(address, length,
    8383                    "%hhx%hhx:%hhx%hhx:%hhx%hhx:%hhx%hhx:%hhx%hhx:%hhx%hhx:"
     
    124124                return EINVAL;
    125125
    126         // set the processing parameters
     126        /* Set processing parameters */
    127127        switch (family) {
    128128        case AF_INET:
     
    142142        }
    143143
    144         // erase if no address
     144        /* Erase if no address */
    145145        if (!address) {
    146146                bzero(data, count);
     
    148148        }
    149149
    150         // process the string from the beginning
     150        /* Process string from the beginning */
    151151        next = address;
    152152        index = 0;
    153153        do {
    154                 // if the actual character is set
     154                /* If the actual character is set */
    155155                if (next && *next) {
    156156
    157                         // if not on the first character
     157                        /* If not on the first character */
    158158                        if (index) {
    159                                 // move to the next character
     159                                /* Move to the next character */
    160160                                ++next;
    161161                        }
    162162
    163                         // parse the actual integral value
     163                        /* Parse the actual integral value */
    164164                        value = strtoul(next, &last, base);
    165                         // remember the last problematic character
    166                         // should be either '.' or ':' but is ignored to be more
    167                         // generic
     165                        /*
     166                         * Remember the last problematic character
     167                         * should be either '.' or ':' but is ignored to be
     168                         * more generic
     169                         */
    168170                        next = last;
    169171
    170                         // fill the address data byte by byte
     172                        /* Fill the address data byte by byte */
    171173                        shift = bytes - 1;
    172174                        do {
    173                                 // like little endian
     175                                /* like little endian */
    174176                                data[index + shift] = value;
    175177                                value >>= 8;
     
    178180                        index += bytes;
    179181                } else {
    180                         // erase the rest of the address
     182                        /* Erase the rest of the address */
    181183                        bzero(data + index, count - index);
    182184                        return EOK;
  • uspace/lib/c/generic/net/modules.c

    re84d65a rdffabf0  
    6363    int answer_count)
    6464{
    65         // choose the most efficient answer function
     65        /* Choose the most efficient answer function */
    6666        if (answer || (!answer_count)) {
    6767                switch (answer_count) {
     
    178178        int phone;
    179179
    180         // if no timeout is set
     180        /* If no timeout is set */
    181181        if (timeout <= 0)
    182182                return async_connect_me_to_blocking(PHONE_NS, need, 0, 0);
     
    187187                        return phone;
    188188
    189                 // end if no time is left
     189                /* Abort if no time is left */
    190190                if (timeout <= 0)
    191191                        return ETIMEOUT;
    192192
    193                 // wait the minimum of the module wait time and the timeout
     193                /* Wait the minimum of the module wait time and the timeout */
    194194                usleep((timeout <= MODULE_WAIT_TIME) ?
    195195                    timeout : MODULE_WAIT_TIME);
     
    214214        ipc_callid_t callid;
    215215
    216         // fetch the request
     216        /* Fetch the request */
    217217        if (!async_data_read_receive(&callid, &length))
    218218                return EINVAL;
    219219
    220         // check the requested data size
     220        /* Check the requested data size */
    221221        if (length < data_length) {
    222222                async_data_read_finalize(callid, data, length);
     
    224224        }
    225225
    226         // send the data
     226        /* Send the data */
    227227        return async_data_read_finalize(callid, data, data_length);
    228228}
     
    242242        if (answer) {
    243243                IPC_SET_RETVAL(*answer, 0);
    244                 // just to be precize
     244                /* Just to be precise */
    245245                IPC_SET_IMETHOD(*answer, 0);
    246246                IPC_SET_ARG1(*answer, 0);
  • uspace/lib/c/generic/net/packet.c

    re84d65a rdffabf0  
    191191        }
    192192        gpm_destroy(&pm_globals.packet_map);
    193         // leave locked
     193        /* leave locked */
    194194}
    195195
  • uspace/lib/c/generic/net/socket_client.c

    re84d65a rdffabf0  
    220220                fibril_rwlock_read_lock(&socket_globals.lock);
    221221
    222                 // find the socket
     222                /* Find the socket */
    223223                socket = sockets_find(socket_get_sockets(),
    224224                    SOCKET_GET_SOCKET_ID(call));
     
    232232                case NET_SOCKET_RECEIVED:
    233233                        fibril_mutex_lock(&socket->receive_lock);
    234                         // push the number of received packet fragments
     234                        /* Push the number of received packet fragments */
    235235                        rc = dyn_fifo_push(&socket->received,
    236236                            SOCKET_GET_DATA_FRAGMENTS(call),
    237237                            SOCKET_MAX_RECEIVED_SIZE);
    238238                        if (rc == EOK) {
    239                                 // signal the received packet
     239                                /* Signal the received packet */
    240240                                fibril_condvar_signal(&socket->receive_signal);
    241241                        }
     
    244244
    245245                case NET_SOCKET_ACCEPTED:
    246                         // push the new socket identifier
     246                        /* Push the new socket identifier */
    247247                        fibril_mutex_lock(&socket->accept_lock);
    248248                        rc = dyn_fifo_push(&socket->accepted, 1,
    249249                            SOCKET_MAX_ACCEPTED_SIZE);
    250250                        if (rc == EOK) {
    251                                 // signal the accepted socket
     251                                /* Signal the accepted socket */
    252252                                fibril_condvar_signal(&socket->accept_signal);
    253253                        }
     
    264264                        fibril_rwlock_write_lock(&socket->sending_lock);
    265265
    266                         // set the data fragment size
     266                        /* Set the data fragment size */
    267267                        socket->data_fragment_size =
    268268                            SOCKET_GET_DATA_FRAGMENT_SIZE(call);
     
    342342                        socket_id = 1;
    343343                        ++count;
    344                 // only this branch for last_id
     344                /* Only this branch for last_id */
    345345                } else {
    346346                        if (socket_id < INT_MAX) {
     
    408408        int rc;
    409409
    410         // find the appropriate service
     410        /* Find the appropriate service */
    411411        switch (domain) {
    412412        case PF_INET:
     
    457457                return phone;
    458458
    459         // create a new socket structure
     459        /* Create a new socket structure */
    460460        socket = (socket_t *) malloc(sizeof(socket_t));
    461461        if (!socket)
     
    465465        fibril_rwlock_write_lock(&socket_globals.lock);
    466466
    467         // request a new socket
     467        /* Request a new socket */
    468468        socket_id = socket_generate_new_id();
    469469        if (socket_id <= 0) {
     
    484484        socket->header_size = (size_t) header_size;
    485485
    486         // finish the new socket initialization
     486        /* Finish the new socket initialization */
    487487        socket_initialize(socket, socket_id, phone, service);
    488         // store the new socket
     488        /* Store the new socket */
    489489        rc = sockets_add(socket_get_sockets(), socket_id, socket);
    490490
     
    531531        fibril_rwlock_read_lock(&socket_globals.lock);
    532532
    533         // find the socket
     533        /* Find the socket */
    534534        socket = sockets_find(socket_get_sockets(), socket_id);
    535535        if (!socket) {
     
    538538        }
    539539
    540         // request the message
     540        /* Request the message */
    541541        message_id = async_send_3(socket->phone, message,
    542542            (sysarg_t) socket->socket_id, arg2, socket->service, NULL);
    543         // send the address
     543        /* Send the address */
    544544        async_data_write_start(socket->phone, data, datalength);
    545545
     
    566566                return EINVAL;
    567567
    568         // send the address
     568        /* Send the address */
    569569        return socket_send_data(socket_id, NET_SOCKET_BIND, 0, my_addr,
    570570            (size_t) addrlen);
     
    591591        fibril_rwlock_read_lock(&socket_globals.lock);
    592592
    593         // find the socket
     593        /* Find the socket */
    594594        socket = sockets_find(socket_get_sockets(), socket_id);
    595595        if (!socket) {
     
    598598        }
    599599
    600         // request listen backlog change
     600        /* Request listen backlog change */
    601601        result = (int) async_req_3_0(socket->phone, NET_SOCKET_LISTEN,
    602602            (sysarg_t) socket->socket_id, (sysarg_t) backlog, socket->service);
     
    634634        fibril_rwlock_write_lock(&socket_globals.lock);
    635635
    636         // find the socket
     636        /* Find the socket */
    637637        socket = sockets_find(socket_get_sockets(), socket_id);
    638638        if (!socket) {
     
    643643        fibril_mutex_lock(&socket->accept_lock);
    644644
    645         // wait for an accepted socket
     645        /* Wait for an accepted socket */
    646646        ++ socket->blocked;
    647647        while (dyn_fifo_value(&socket->accepted) <= 0) {
    648648                fibril_rwlock_write_unlock(&socket_globals.lock);
    649649                fibril_condvar_wait(&socket->accept_signal, &socket->accept_lock);
    650                 // drop the accept lock to avoid deadlock
     650                /* Drop the accept lock to avoid deadlock */
    651651                fibril_mutex_unlock(&socket->accept_lock);
    652652                fibril_rwlock_write_lock(&socket_globals.lock);
     
    655655        -- socket->blocked;
    656656
    657         // create a new scoket
     657        /* Create a new socket */
    658658        new_socket = (socket_t *) malloc(sizeof(socket_t));
    659659        if (!new_socket) {
     
    681681        }
    682682
    683         // request accept
     683        /* Request accept */
    684684        message_id = async_send_5(socket->phone, NET_SOCKET_ACCEPT,
    685685            (sysarg_t) socket->socket_id, 0, socket->service, 0,
    686686            new_socket->socket_id, &answer);
    687687
    688         // read address
     688        /* Read address */
    689689        ipc_data_read_start(socket->phone, cliaddr, *addrlen);
    690690        fibril_rwlock_write_unlock(&socket_globals.lock);
     
    695695                        result = EINVAL;
    696696
    697                 // dequeue the accepted socket if successful
     697                /* Dequeue the accepted socket if successful */
    698698                dyn_fifo_pop(&socket->accepted);
    699                 // set address length
     699                /* Set address length */
    700700                *addrlen = SOCKET_GET_ADDRESS_LENGTH(answer);
    701701                new_socket->data_fragment_size =
    702702                    SOCKET_GET_DATA_FRAGMENT_SIZE(answer);
    703703        } else if (result == ENOTSOCK) {
    704                 // empty the queue if no accepted sockets
     704                /* Empty the queue if no accepted sockets */
    705705                while (dyn_fifo_pop(&socket->accepted) > 0)
    706706                        ;
     
    731731                return EDESTADDRREQ;
    732732
    733         // send the address
     733        /* Send the address */
    734734        return socket_send_data(socket_id, NET_SOCKET_CONNECT, 0, serv_addr,
    735735            addrlen);
     
    744744        int accepted_id;
    745745
    746         // destroy all accepted sockets
     746        /* Destroy all accepted sockets */
    747747        while ((accepted_id = dyn_fifo_pop(&socket->accepted)) >= 0)
    748748                socket_destroy(sockets_find(socket_get_sockets(), accepted_id));
     
    780780        }
    781781
    782         // request close
     782        /* Request close */
    783783        rc = (int) async_req_3_0(socket->phone, NET_SOCKET_CLOSE,
    784784            (sysarg_t) socket->socket_id, 0, socket->service);
     
    787787                return rc;
    788788        }
    789         // free the socket structure
     789        /* Free the socket structure */
    790790        socket_destroy(socket);
    791791
     
    833833        fibril_rwlock_read_lock(&socket_globals.lock);
    834834
    835         // find socket
     835        /* Find socket */
    836836        socket = sockets_find(socket_get_sockets(), socket_id);
    837837        if (!socket) {
     
    842842        fibril_rwlock_read_lock(&socket->sending_lock);
    843843
    844         // compute data fragment count
     844        /* Compute data fragment count */
    845845        if (socket->data_fragment_size > 0) {
    846846                fragments = (datalength + socket->header_size) /
     
    853853        }
    854854
    855         // request send
     855        /* Request send */
    856856        message_id = async_send_5(socket->phone, message,
    857857            (sysarg_t) socket->socket_id,
     
    859859            socket->service, (sysarg_t) flags, fragments, &answer);
    860860
    861         // send the address if given
     861        /* Send the address if given */
    862862        if (!toaddr ||
    863863            (async_data_write_start(socket->phone, toaddr, addrlen) == EOK)) {
    864864                if (fragments == 1) {
    865                         // send all if only one fragment
     865                        /* Send all if only one fragment */
    866866                        async_data_write_start(socket->phone, data, datalength);
    867867                } else {
    868                         // send the first fragment
     868                        /* Send the first fragment */
    869869                        async_data_write_start(socket->phone, data,
    870870                            socket->data_fragment_size - socket->header_size);
     
    872872                            socket->data_fragment_size - socket->header_size;
    873873       
    874                         // send the middle fragments
     874                        /* Send the middle fragments */
    875875                        while (--fragments > 1) {
    876876                                async_data_write_start(socket->phone, data,
     
    880880                        }
    881881
    882                         // send the last fragment
     882                        /* Send the last fragment */
    883883                        async_data_write_start(socket->phone, data,
    884884                            (datalength + socket->header_size) %
     
    892892            (SOCKET_GET_DATA_FRAGMENT_SIZE(answer) !=
    893893            socket->data_fragment_size)) {
    894                 // set the data fragment size
     894                /* Set the data fragment size */
    895895                socket->data_fragment_size =
    896896                    SOCKET_GET_DATA_FRAGMENT_SIZE(answer);
     
    917917int send(int socket_id, void *data, size_t datalength, int flags)
    918918{
    919         // without the address
     919        /* Without the address */
    920920        return sendto_core(NET_SOCKET_SEND, socket_id, data, datalength, flags,
    921921            NULL, 0);
     
    950950                return EDESTADDRREQ;
    951951
    952         // with the address
     952        /* With the address */
    953953        return sendto_core(NET_SOCKET_SENDTO, socket_id, data, datalength,
    954954            flags, toaddr, addrlen);
     
    966966 *                      read. The actual address length is set. Used only if
    967967 *                      fromaddr is not NULL.
    968  * @return              EOK on success.
     968 * @return              Positive received message size in bytes on success.
     969 * @return              Zero if no more data (other side closed the connection).
    969970 * @return              ENOTSOCK if the socket is not found.
    970971 * @return              EBADMEM if the data parameter is NULL.
     
    972973 * @return              Other error codes as defined for the spcific message.
    973974 */
    974 static int
     975static ssize_t
    975976recvfrom_core(sysarg_t message, int socket_id, void *data, size_t datalength,
    976977    int flags, struct sockaddr *fromaddr, socklen_t *addrlen)
     
    984985        size_t index;
    985986        ipc_call_t answer;
     987        ssize_t retval;
    986988
    987989        if (!data)
     
    996998        fibril_rwlock_read_lock(&socket_globals.lock);
    997999
    998         // find the socket
     1000        /* Find the socket */
    9991001        socket = sockets_find(socket_get_sockets(), socket_id);
    10001002        if (!socket) {
     
    10041006
    10051007        fibril_mutex_lock(&socket->receive_lock);
    1006         // wait for a received packet
     1008        /* Wait for a received packet */
    10071009        ++socket->blocked;
    1008         while ((result = dyn_fifo_value(&socket->received)) <= 0) {
     1010        while ((result = dyn_fifo_value(&socket->received)) < 0) {
    10091011                fibril_rwlock_read_unlock(&socket_globals.lock);
    10101012                fibril_condvar_wait(&socket->receive_signal,
    10111013                    &socket->receive_lock);
    10121014
    1013                 // drop the receive lock to avoid deadlock
     1015                /* Drop the receive lock to avoid deadlock */
    10141016                fibril_mutex_unlock(&socket->receive_lock);
    10151017                fibril_rwlock_read_lock(&socket_globals.lock);
     
    10191021        fragments = (size_t) result;
    10201022
    1021         // prepare lengths if more fragments
     1023        if (fragments == 0) {
     1024                /* No more data, other side has closed the connection. */
     1025                fibril_mutex_unlock(&socket->receive_lock);
     1026                fibril_rwlock_read_unlock(&socket_globals.lock);
     1027                return 0;
     1028        }
     1029
     1030        /* Prepare lengths if more fragments */
    10221031        if (fragments > 1) {
    10231032                lengths = (size_t *) malloc(sizeof(size_t) * fragments +
     
    10291038                }
    10301039
    1031                 // request packet data
     1040                /* Request packet data */
    10321041                message_id = async_send_4(socket->phone, message,
    10331042                    (sysarg_t) socket->socket_id, 0, socket->service,
    10341043                    (sysarg_t) flags, &answer);
    10351044
    1036                 // read the address if desired
     1045                /* Read the address if desired */
    10371046                if(!fromaddr ||
    10381047                    (async_data_read_start(socket->phone, fromaddr,
    10391048                    *addrlen) == EOK)) {
    1040                         // read the fragment lengths
     1049                        /* Read the fragment lengths */
    10411050                        if (async_data_read_start(socket->phone, lengths,
    10421051                            sizeof(int) * (fragments + 1)) == EOK) {
    10431052                                if (lengths[fragments] <= datalength) {
    10441053
    1045                                         // read all fragments if long enough
     1054                                        /* Read all fragments if long enough */
    10461055                                        for (index = 0; index < fragments;
    10471056                                            ++index) {
     
    10571066
    10581067                free(lengths);
    1059         } else {
    1060                 // request packet data
     1068        } else { /* fragments == 1 */
     1069                /* Request packet data */
    10611070                message_id = async_send_4(socket->phone, message,
    10621071                    (sysarg_t) socket->socket_id, 0, socket->service,
    10631072                    (sysarg_t) flags, &answer);
    10641073
    1065                 // read the address if desired
     1074                /* Read the address if desired */
    10661075                if (!fromaddr ||
    10671076                    (async_data_read_start(socket->phone, fromaddr,
    10681077                        *addrlen) == EOK)) {
    1069                         // read all if only one fragment
     1078                        /* Read all if only one fragment */
    10701079                        async_data_read_start(socket->phone, data, datalength);
    10711080                }
     
    10751084        result = (int) ipc_result;
    10761085        if (result == EOK) {
    1077                 // dequeue the received packet
     1086                /* Dequeue the received packet */
    10781087                dyn_fifo_pop(&socket->received);
    1079                 // return read data length
    1080                 result = SOCKET_GET_READ_DATA_LENGTH(answer);
    1081                 // set address length
     1088                /* Return read data length */
     1089                retval = SOCKET_GET_READ_DATA_LENGTH(answer);
     1090                /* Set address length */
    10821091                if (fromaddr && addrlen)
    10831092                        *addrlen = SOCKET_GET_ADDRESS_LENGTH(answer);
     1093        } else {
     1094                retval = (ssize_t) result;
    10841095        }
    10851096
    10861097        fibril_mutex_unlock(&socket->receive_lock);
    10871098        fibril_rwlock_read_unlock(&socket_globals.lock);
    1088         return result;
     1099        return retval;
    10891100}
    10901101
     
    10951106 * @param[in] datalength The data length.
    10961107 * @param[in] flags     Various receive flags.
    1097  * @return              EOK on success.
     1108 * @return              Positive received message size in bytes on success.
     1109 * @return              Zero if no more data (other side closed the connection).
    10981110 * @return              ENOTSOCK if the socket is not found.
    10991111 * @return              EBADMEM if the data parameter is NULL.
     
    11021114 *                      message.
    11031115 */
    1104 int recv(int socket_id, void *data, size_t datalength, int flags)
    1105 {
    1106         // without the address
     1116ssize_t recv(int socket_id, void *data, size_t datalength, int flags)
     1117{
     1118        /* Without the address */
    11071119        return recvfrom_core(NET_SOCKET_RECV, socket_id, data, datalength,
    11081120            flags, NULL, NULL);
     
    11181130 * @param[in,out] addrlen The address length. The maximum address length is
    11191131 *                      read. The actual address length is set.
    1120  * @return              EOK on success.
     1132 * @return              Positive received message size in bytes on success.
     1133 * @return              Zero if no more data (other side closed the connection).
    11211134 * @return              ENOTSOCK if the socket is not found.
    11221135 * @return              EBADMEM if the data or fromaddr parameter is NULL.
     
    11251138 *                      message.
    11261139 */
    1127 int
     1140ssize_t
    11281141recvfrom(int socket_id, void *data, size_t datalength, int flags,
    11291142    struct sockaddr *fromaddr, socklen_t *addrlen)
     
    11351148                return NO_DATA;
    11361149
    1137         // with the address
     1150        /* With the address */
    11381151        return recvfrom_core(NET_SOCKET_RECVFROM, socket_id, data, datalength,
    11391152            flags, fromaddr, addrlen);
     
    11701183        fibril_rwlock_read_lock(&socket_globals.lock);
    11711184
    1172         // find the socket
     1185        /* Find the socket */
    11731186        socket = sockets_find(socket_get_sockets(), socket_id);
    11741187        if (!socket) {
     
    11771190        }
    11781191
    1179         // request option value
     1192        /* Request option value */
    11801193        message_id = async_send_3(socket->phone, NET_SOCKET_GETSOCKOPT,
    11811194            (sysarg_t) socket->socket_id, (sysarg_t) optname, socket->service,
    11821195            NULL);
    11831196
    1184         // read the length
     1197        /* Read the length */
    11851198        if (async_data_read_start(socket->phone, optlen,
    11861199            sizeof(*optlen)) == EOK) {
    1187                 // read the value
     1200                /* Read the value */
    11881201                async_data_read_start(socket->phone, value, *optlen);
    11891202        }
     
    12121225    size_t optlen)
    12131226{
    1214         // send the value
     1227        /* Send the value */
    12151228        return socket_send_data(socket_id, NET_SOCKET_SETSOCKOPT,
    12161229            (sysarg_t) optname, value, optlen);
  • uspace/lib/c/generic/task.c

    re84d65a rdffabf0  
    6565 *
    6666 * @return Zero on success or negative error code.
    67  *
    6867 */
    6968int task_set_name(const char *name)
    7069{
    7170        return __SYSCALL2(SYS_TASK_SET_NAME, (sysarg_t) name, str_size(name));
     71}
     72
     73/** Kill a task.
     74 *
     75 * @param task_id ID of task to kill.
     76 *
     77 * @return Zero on success or negative error code.
     78 */
     79
     80int task_kill(task_id_t task_id)
     81{
     82        return (int) __SYSCALL1(SYS_TASK_KILL, (sysarg_t) &task_id);
    7283}
    7384
  • uspace/lib/c/include/async.h

    re84d65a rdffabf0  
    3737
    3838#include <ipc/ipc.h>
     39#include <async_sess.h>
    3940#include <fibril.h>
    4041#include <sys/time.h>
  • uspace/lib/c/include/async_sess.h

    re84d65a rdffabf0  
    3333 */
    3434
    35 #ifndef LIBC_ASYNC_REL_H_
    36 #define LIBC_ASYNC_REL_H_
     35#ifndef LIBC_ASYNC_SESS_H_
     36#define LIBC_ASYNC_SESS_H_
    3737
    38 extern int async_rel_init(void);
    39 extern int async_relation_create(int);
    40 extern void async_relation_destroy(int, int);
     38#include <adt/list.h>
     39
     40typedef struct {
     41        int sess_phone;         /**< Phone for cloning off the connections. */
     42        link_t conn_head;       /**< List of open data connections. */
     43        link_t sess_link;       /**< Link in global list of open sessions. */
     44} async_sess_t;
     45
     46extern void _async_sess_init(void);
     47extern void async_session_create(async_sess_t *, int);
     48extern void async_session_destroy(async_sess_t *);
     49extern int async_exchange_begin(async_sess_t *);
     50extern void async_exchange_end(async_sess_t *, int);
    4151
    4252#endif
  • uspace/lib/c/include/net/socket.h

    re84d65a rdffabf0  
    6060extern int sendto(int, const void *, size_t, int, const struct sockaddr *,
    6161    socklen_t);
    62 extern int recv(int, void *, size_t, int);
    63 extern int recvfrom(int, void *, size_t, int, struct sockaddr *, socklen_t *);
     62extern ssize_t recv(int, void *, size_t, int);
     63extern ssize_t recvfrom(int, void *, size_t, int, struct sockaddr *, socklen_t *);
    6464extern int getsockopt(int, int, int, void *, size_t *);
    6565extern int setsockopt(int, int, int, const void *, size_t);
  • uspace/lib/c/include/task.h

    re84d65a rdffabf0  
    4747extern task_id_t task_get_id(void);
    4848extern int task_set_name(const char *);
     49extern int task_kill(task_id_t);
     50
    4951extern task_id_t task_spawn(const char *, const char *const[], int *);
    5052extern int task_spawnv(task_id_t *, const char *path, const char *const []);
  • uspace/srv/bd/ata_bd/ata_bd.c

    re84d65a rdffabf0  
    6565#include <macros.h>
    6666
     67#include "ata_hw.h"
    6768#include "ata_bd.h"
    6869
     
    7071#define NAMESPACE  "bd"
    7172
     73/** Number of defined legacy controller base addresses. */
     74#define LEGACY_CTLS 4
     75
    7276/** Physical block size. Should be always 512. */
    7377static const size_t block_size = 512;
     
    7781
    7882/** I/O base address of the command registers. */
    79 static uintptr_t cmd_physical = 0x1f0;
     83static uintptr_t cmd_physical;
    8084/** I/O base address of the control registers. */
    81 static uintptr_t ctl_physical = 0x170;
     85static uintptr_t ctl_physical;
     86
     87/** I/O base addresses for legacy (ISA-compatible) controllers. */
     88static ata_base_t legacy_base[LEGACY_CTLS] = {
     89        { 0x1f0, 0x3f0 },
     90        { 0x170, 0x370 },
     91        { 0x1e8, 0x3e8 },
     92        { 0x168, 0x368 }
     93};
    8294
    8395static ata_cmd_t *cmd;
     
    8799static disk_t disk[MAX_DISKS];
    88100
     101static void print_syntax(void);
    89102static int ata_bd_init(void);
    90103static void ata_bd_connection(ipc_callid_t iid, ipc_call_t *icall);
     
    110123        int i, rc;
    111124        int n_disks;
     125        unsigned ctl_num;
     126        char *eptr;
    112127
    113128        printf(NAME ": ATA disk driver\n");
    114129
    115         printf("I/O address %p/%p\n", (void *) ctl_physical,
    116             (void *) cmd_physical);
     130        if (argc > 1) {
     131                ctl_num = strtoul(argv[1], &eptr, 0);
     132                if (*eptr != '\0' || ctl_num == 0 || ctl_num > 4) {
     133                        printf("Invalid argument.\n");
     134                        print_syntax();
     135                        return -1;
     136                }
     137        } else {
     138                ctl_num = 1;
     139        }
     140
     141        cmd_physical = legacy_base[ctl_num - 1].cmd;
     142        ctl_physical = legacy_base[ctl_num - 1].ctl;
     143
     144        printf("I/O address %p/%p\n", (void *) cmd_physical,
     145            (void *) ctl_physical);
    117146
    118147        if (ata_bd_init() != EOK)
     
    139168                        continue;
    140169               
    141                 snprintf(name, 16, "%s/disk%d", NAMESPACE, i);
     170                snprintf(name, 16, "%s/ata%udisk%d", NAMESPACE, ctl_num, i);
    142171                rc = devmap_device_register(name, &disk[i].devmap_handle);
    143172                if (rc != EOK) {
     
    160189        /* Not reached */
    161190        return 0;
     191}
     192
     193
     194static void print_syntax(void)
     195{
     196        printf("Syntax: " NAME " <controller_number>\n");
     197        printf("Controller number = 1..4\n");
    162198}
    163199
  • uspace/srv/bd/ata_bd/ata_bd.h

    re84d65a rdffabf0  
    3030 * @{
    3131 */
    32 /** @file
     32/** @file ATA driver definitions.
    3333 */
    3434
     
    4040#include <str.h>
    4141
    42 enum {
    43         CTL_READ_START  = 0,
    44         CTL_WRITE_START = 1,
    45 };
    46 
    47 enum {
    48         STATUS_FAILURE = 0
    49 };
    50 
    51 enum {
    52         MAX_DISKS       = 2
    53 };
    54 
    55 /** ATA Command Register Block. */
    56 typedef union {
    57         /* Read/Write */
    58         struct {
    59                 uint16_t data_port;
    60                 uint8_t sector_count;
    61                 uint8_t sector_number;
    62                 uint8_t cylinder_low;
    63                 uint8_t cylinder_high;
    64                 uint8_t drive_head;
    65                 uint8_t pad_rw0;               
    66         };
    67 
    68         /* Read Only */
    69         struct {
    70                 uint8_t pad_ro0;
    71                 uint8_t error;
    72                 uint8_t pad_ro1[5];
    73                 uint8_t status;
    74         };
    75 
    76         /* Write Only */
    77         struct {
    78                 uint8_t pad_wo0;
    79                 uint8_t features;
    80                 uint8_t pad_wo1[5];
    81                 uint8_t command;
    82         };
    83 } ata_cmd_t;
    84 
    85 typedef union {
    86         /* Read */
    87         struct {
    88                 uint8_t pad0[6];
    89                 uint8_t alt_status;
    90                 uint8_t drive_address;
    91         };
    92 
    93         /* Write */
    94         struct {
    95                 uint8_t pad1[6];
    96                 uint8_t device_control;
    97                 uint8_t pad2;
    98         };
    99 } ata_ctl_t;
    100 
    101 enum devctl_bits {
    102         DCR_SRST        = 0x04, /**< Software Reset */
    103         DCR_nIEN        = 0x02  /**< Interrupt Enable (negated) */
    104 };
    105 
    106 enum status_bits {
    107         SR_BSY          = 0x80, /**< Busy */
    108         SR_DRDY         = 0x40, /**< Drive Ready */
    109         SR_DWF          = 0x20, /**< Drive Write Fault */
    110         SR_DSC          = 0x10, /**< Drive Seek Complete */
    111         SR_DRQ          = 0x08, /**< Data Request */
    112         SR_CORR         = 0x04, /**< Corrected Data */
    113         SR_IDX          = 0x02, /**< Index */
    114         SR_ERR          = 0x01  /**< Error */
    115 };
    116 
    117 enum drive_head_bits {
    118         DHR_LBA         = 0x40, /**< Use LBA addressing mode */
    119         DHR_DRV         = 0x10  /**< Select device 1 */
    120 };
    121 
    122 enum error_bits {
    123         ER_BBK          = 0x80, /**< Bad Block Detected */
    124         ER_UNC          = 0x40, /**< Uncorrectable Data Error */
    125         ER_MC           = 0x20, /**< Media Changed */
    126         ER_IDNF         = 0x10, /**< ID Not Found */
    127         ER_MCR          = 0x08, /**< Media Change Request */
    128         ER_ABRT         = 0x04, /**< Aborted Command */
    129         ER_TK0NF        = 0x02, /**< Track 0 Not Found */
    130         ER_AMNF         = 0x01  /**< Address Mark Not Found */
    131 };
    132 
    133 enum ata_command {
    134         CMD_READ_SECTORS        = 0x20,
    135         CMD_READ_SECTORS_EXT    = 0x24,
    136         CMD_WRITE_SECTORS       = 0x30,
    137         CMD_WRITE_SECTORS_EXT   = 0x34,
    138         CMD_IDENTIFY_DRIVE      = 0xEC
    139 };
     42/** Base addresses for ATA I/O blocks. */
     43typedef struct {
     44        uintptr_t cmd;  /**< Command block base address. */
     45        uintptr_t ctl;  /**< Control block base address. */
     46} ata_base_t;
    14047
    14148/** Timeout definitions. Unit is 10 ms. */
     
    14451        TIMEOUT_BSY     =  100, /*  1 s */
    14552        TIMEOUT_DRDY    = 1000  /* 10 s */
    146 };
    147 
    148 /** Data returned from @c identify command. */
    149 typedef struct {
    150         uint16_t gen_conf;
    151         uint16_t cylinders;
    152         uint16_t _res2;
    153         uint16_t heads;
    154         uint16_t _vs4;
    155         uint16_t _vs5;
    156         uint16_t sectors;
    157         uint16_t _vs7;
    158         uint16_t _vs8;
    159         uint16_t _vs9;
    160 
    161         uint16_t serial_number[10];
    162         uint16_t _vs20;
    163         uint16_t _vs21;
    164         uint16_t vs_bytes;
    165         uint16_t firmware_rev[4];
    166         uint16_t model_name[20];
    167 
    168         uint16_t max_rw_multiple;
    169         uint16_t _res48;
    170         uint16_t caps;
    171         uint16_t _res50;
    172         uint16_t pio_timing;
    173         uint16_t dma_timing;
    174 
    175         uint16_t validity;
    176         uint16_t cur_cyl;
    177         uint16_t cur_heads;
    178         uint16_t cur_sectors;
    179         uint16_t cur_capacity0;
    180         uint16_t cur_capacity1;
    181         uint16_t mss;
    182         uint16_t total_lba28_0;
    183         uint16_t total_lba28_1;
    184         uint16_t sw_dma;
    185         uint16_t mw_dma;
    186         uint16_t pio_modes;
    187         uint16_t min_mw_dma_cycle;
    188         uint16_t rec_mw_dma_cycle;
    189         uint16_t min_raw_pio_cycle;
    190         uint16_t min_iordy_pio_cycle;
    191 
    192         uint16_t _res69;
    193         uint16_t _res70;
    194         uint16_t _res71;
    195         uint16_t _res72;
    196         uint16_t _res73;
    197         uint16_t _res74;
    198 
    199         uint16_t queue_depth;
    200         uint16_t _res76[1 + 79 - 76];
    201         uint16_t version_maj;
    202         uint16_t version_min;
    203         uint16_t cmd_set0;
    204         uint16_t cmd_set1;
    205         uint16_t csf_sup_ext;
    206         uint16_t csf_enabled0;
    207         uint16_t csf_enabled1;
    208         uint16_t csf_default;
    209         uint16_t udma;
    210 
    211         uint16_t _res89[1 + 99 - 89];
    212 
    213         /* Total number of blocks in LBA-48 addressing */
    214         uint16_t total_lba48_0;
    215         uint16_t total_lba48_1;
    216         uint16_t total_lba48_2;
    217         uint16_t total_lba48_3;
    218 
    219         /* Note: more fields are defined in ATA/ATAPI-7 */
    220         uint16_t _res104[1 + 127 - 104];
    221         uint16_t _vs128[1 + 159 - 128];
    222         uint16_t _res160[1 + 255 - 160];
    223 } identify_data_t;
    224 
    225 enum ata_caps {
    226         cap_iordy       = 0x0800,
    227         cap_iordy_cbd   = 0x0400,
    228         cap_lba         = 0x0200,
    229         cap_dma         = 0x0100
    230 };
    231 
    232 /** Bits of @c identify_data_t.cmd_set1 */
    233 enum ata_cs1 {
    234         cs1_addr48      = 0x0400        /**< 48-bit address feature set */
    23553};
    23654
     
    26987} block_coord_t;
    27088
     89/** ATA device state structure. */
    27190typedef struct {
    27291        bool present;
  • uspace/srv/hw/netif/dp8390/Makefile

    re84d65a rdffabf0  
    3939-include $(CONFIG_MAKEFILE)
    4040
    41 ifeq ($(CONFIG_NETIF_NIL_BUNDLE),y)
    42         LIBS += $(USPACE_PREFIX)/srv/net/nil/eth/libeth.a
    43 endif
    44 
    4541BINARY = dp8390
    4642
  • uspace/srv/net/cfg/Makefile

    re84d65a rdffabf0  
    3636-include $(CONFIG_MAKEFILE)
    3737
    38 ifeq ($(CONFIG_NETIF_NIL_BUNDLE),y)
    39         LO_SOURCE = lo.netif_nil_bundle
    40         NE2K_SOURCE = ne2k.netif_nil_bundle
    41 else
    42         LO_SOURCE = lo.netif_standalone
    43         NE2K_SOURCE = ne2k.netif_standalone
    44 endif
     38LO_SOURCE = lo.netif_standalone
     39NE2K_SOURCE = ne2k.netif_standalone
    4540
    4641LO_TARGET = lo
  • uspace/srv/net/cfg/ne2k.netif_standalone

    re84d65a rdffabf0  
    77IL=ip
    88
    9 IRQ=9
     9IRQ=5
    1010IO=300
    1111
  • uspace/srv/net/netif/lo/Makefile

    re84d65a rdffabf0  
    3939-include $(CONFIG_MAKEFILE)
    4040
    41 ifeq ($(CONFIG_NETIF_NIL_BUNDLE),y)
    42         LIBS += $(USPACE_PREFIX)/srv/net/nil/nildummy/libnildummy.a
    43 endif
    44 
    4541BINARY = lo
    4642
  • uspace/srv/net/nil/eth/Makefile

    re84d65a rdffabf0  
    3939-include $(CONFIG_MAKEFILE)
    4040
    41 ifeq ($(CONFIG_NETIF_NIL_BUNDLE),y)
    42         LIBRARY = libeth
    43 else
    44         BINARY = eth
    45 endif
     41BINARY = eth
    4642
    4743SOURCES = \
  • uspace/srv/net/nil/nildummy/Makefile

    re84d65a rdffabf0  
    3939-include $(CONFIG_MAKEFILE)
    4040
    41 ifeq ($(CONFIG_NETIF_NIL_BUNDLE),y)
    42         LIBRARY = libnildummy
    43 else
    44         BINARY = nildummy
    45 endif
     41BINARY = nildummy
    4642
    4743SOURCES = \
  • uspace/srv/net/tl/tcp/tcp.c

    re84d65a rdffabf0  
    205205static int tcp_queue_received_packet(socket_core_t *, tcp_socket_data_t *,
    206206    packet_t *, int, size_t);
     207static void tcp_queue_received_end_of_data(socket_core_t *socket);
    207208
    208209static int tcp_received_msg(device_id_t, packet_t *, services_t, services_t);
     
    453454
    454455has_error_service:
    455         fibril_rwlock_read_unlock(&tcp_globals.lock);
     456        fibril_rwlock_write_unlock(&tcp_globals.lock);
    456457
    457458        /* TODO error reporting/handling */
     
    504505        size_t offset;
    505506        uint32_t new_sequence_number;
     507        bool forced_ack;
    506508        int rc;
    507509
     
    512514        assert(packet);
    513515
     516        forced_ack = false;
     517
    514518        new_sequence_number = ntohl(header->sequence_number);
    515519        old_incoming = socket_data->next_incoming;
    516520
    517         if (header->finalize)
    518                 socket_data->fin_incoming = new_sequence_number;
     521        if (header->finalize) {
     522                socket_data->fin_incoming = new_sequence_number +
     523                    total_length - TCP_HEADER_LENGTH(header);
     524        }
    519525
    520526        /* Trim begining if containing expected data */
     
    760766                /* Release duplicite or restricted */
    761767                pq_release_remote(tcp_globals.net_phone, packet_get_id(packet));
    762         }
    763 
    764         /* Change state according to the acknowledging incoming fin */
    765         if (IS_IN_INTERVAL_OVERFLOW(old_incoming, socket_data->fin_incoming,
    766             socket_data->next_incoming)) {
     768                forced_ack = true;
     769        }
     770
     771        /* If next in sequence is an incoming FIN */
     772        if (socket_data->next_incoming == socket_data->fin_incoming) {
     773                /* Advance sequence number */
     774                socket_data->next_incoming += 1;
     775
     776                /* Handle FIN */
    767777                switch (socket_data->state) {
    768778                case TCP_SOCKET_FIN_WAIT_1:
     
    771781                        socket_data->state = TCP_SOCKET_CLOSING;
    772782                        break;
    773                 /*case TCP_ESTABLISHED:*/
     783                case TCP_SOCKET_ESTABLISHED:
     784                        /* Queue end-of-data marker on the socket. */
     785                        tcp_queue_received_end_of_data(socket);
     786                        socket_data->state = TCP_SOCKET_CLOSE_WAIT;
     787                        break;
    774788                default:
    775789                        socket_data->state = TCP_SOCKET_CLOSE_WAIT;
     
    779793
    780794        packet = tcp_get_packets_to_send(socket, socket_data);
    781         if (!packet) {
     795        if (!packet && (socket_data->next_incoming != old_incoming || forced_ack)) {
    782796                /* Create the notification packet */
    783797                rc = tcp_create_notification_packet(&packet, socket,
     
    835849
    836850        return EOK;
     851}
     852
     853/** Queue end-of-data marker on the socket.
     854 *
     855 * Next element in the sequence space is FIN. Queue end-of-data marker
     856 * on the socket.
     857 *
     858 * @param socket        Socket
     859 */
     860static void tcp_queue_received_end_of_data(socket_core_t *socket)
     861{
     862        assert(socket != NULL);
     863
     864        /* Notify the destination socket */
     865        async_msg_5(socket->phone, NET_SOCKET_RECEIVED,
     866            (sysarg_t) socket->socket_id,
     867            0, 0, 0,
     868            (sysarg_t) 0 /* 0 fragments == no more data */);
    837869}
    838870
     
    18031835                        fibril_rwlock_write_unlock(socket_data->local_lock);
    18041836
     1837                        socket_data->state = TCP_SOCKET_SYN_SENT;
     1838
    18051839                        /* Send the packet */
    18061840                        printf("connecting %d\n", packet_get_id(packet));
     
    22102244
    22112245                tcp_prepare_operation_header(socket, socket_data, header, 0, 0);
    2212                 rc = tcp_queue_packet(socket, socket_data, packet, 0);
     2246                rc = tcp_queue_packet(socket, socket_data, packet, total_length);
    22132247                if (rc != EOK)
    22142248                        return rc;
  • uspace/srv/vfs/vfs.h

    re84d65a rdffabf0  
    3434#define VFS_VFS_H_
    3535
     36#include <async.h>
    3637#include <ipc/ipc.h>
    3738#include <adt/list.h>
     
    5354        vfs_info_t vfs_info;
    5455        fs_handle_t fs_handle;
    55         fibril_mutex_t phone_lock;
    56         sysarg_t phone;
     56        async_sess_t session;
    5757} fs_info_t;
    5858
  • uspace/srv/vfs/vfs_register.c

    re84d65a rdffabf0  
    3939#include <ipc/services.h>
    4040#include <async.h>
    41 #include <async_rel.h>
    4241#include <fibril.h>
    4342#include <fibril_synch.h>
     
    111110void vfs_register(ipc_callid_t rid, ipc_call_t *request)
    112111{
     112        int phone;
     113       
    113114        dprintf("Processing VFS_REGISTER request received from %p.\n",
    114115            request->in_phone_hash);
     
    136137       
    137138        link_initialize(&fs_info->fs_link);
    138         fibril_mutex_initialize(&fs_info->phone_lock);
    139139        fs_info->vfs_info = *vfs_info;
    140140        free(vfs_info);
     
    186186                return;
    187187        }
    188         fs_info->phone = IPC_GET_ARG5(call);
     188       
     189        phone = IPC_GET_ARG5(call);
     190        async_session_create(&fs_info->session, phone);
    189191        ipc_answer_0(callid, EOK);
    190192       
     
    200202                list_remove(&fs_info->fs_link);
    201203                fibril_mutex_unlock(&fs_head_lock);
    202                 ipc_hangup(fs_info->phone);
     204                async_session_destroy(&fs_info->session);
     205                ipc_hangup(phone);
    203206                free(fs_info);
    204207                ipc_answer_0(callid, EINVAL);
     
    214217                list_remove(&fs_info->fs_link);
    215218                fibril_mutex_unlock(&fs_head_lock);
    216                 ipc_hangup(fs_info->phone);
     219                async_session_destroy(&fs_info->session);
     220                ipc_hangup(phone);
    217221                free(fs_info);
    218222                ipc_answer_0(callid, EINVAL);
     
    269273                if (fs->fs_handle == handle) {
    270274                        fibril_mutex_unlock(&fs_head_lock);
    271                         fibril_mutex_lock(&fs->phone_lock);
    272                         phone = async_relation_create(fs->phone);
    273                         fibril_mutex_unlock(&fs->phone_lock);
     275                        phone = async_exchange_begin(&fs->session);
    274276
    275277                        assert(phone > 0);
     
    295297                if (fs->fs_handle == handle) {
    296298                        fibril_mutex_unlock(&fs_head_lock);
    297                         fibril_mutex_lock(&fs->phone_lock);
    298                         async_relation_destroy(fs->phone, phone);
    299                         fibril_mutex_unlock(&fs->phone_lock);
     299                        async_exchange_end(&fs->session, phone);
    300300                        return;
    301301                }
Note: See TracChangeset for help on using the changeset viewer.