Changeset df3c6f02 in mainline for uspace/srv


Ignore:
Timestamp:
2011-05-31T22:58:56Z (14 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d362410
Parents:
82582e4 (diff), 4ce90544 (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.

Location:
uspace/srv
Files:
17 deleted
28 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/bd/rd/Makefile

    r82582e4 rdf3c6f02  
    3030USPACE_PREFIX = ../../..
    3131BINARY = rd
     32STATIC_NEEDED = y
    3233
    3334SOURCES = \
  • uspace/srv/devman/Makefile

    r82582e4 rdf3c6f02  
    3030USPACE_PREFIX = ../..
    3131BINARY = devman
     32STATIC_NEEDED = y
    3233
    3334SOURCES = \
  • uspace/srv/devman/devman.c

    r82582e4 rdf3c6f02  
    3939#include <devmap.h>
    4040#include <str_error.h>
     41#include <stdio.h>
    4142
    4243#include "devman.h"
     
    555556}
    556557
    557 /** Remember the driver's phone.
    558  *
    559  * @param driver        The driver.
    560  * @param phone         The phone to the driver.
    561  */
    562 void set_driver_phone(driver_t *driver, sysarg_t phone)
    563 {
    564         fibril_mutex_lock(&driver->driver_mutex);
    565         assert(driver->state == DRIVER_STARTING);
    566         driver->phone = phone;
    567         fibril_mutex_unlock(&driver->driver_mutex);
    568 }
    569 
    570558/** Notify driver about the devices to which it was assigned.
    571559 *
     
    685673        list_initialize(&drv->devices);
    686674        fibril_mutex_initialize(&drv->driver_mutex);
     675        drv->phone = -1;
    687676}
    688677
  • uspace/srv/devman/devman.h

    r82582e4 rdf3c6f02  
    8888       
    8989        /** Phone asociated with this driver. */
    90         sysarg_t phone;
     90        int phone;
    9191        /** Name of the device driver. */
    9292        char *name;
     
    316316
    317317extern driver_t *find_driver(driver_list_t *, const char *);
    318 extern void set_driver_phone(driver_t *, sysarg_t);
    319318extern void initialize_running_driver(driver_t *, dev_tree_t *);
    320319
  • uspace/srv/devman/main.c

    r82582e4 rdf3c6f02  
    9595        /* Find driver structure. */
    9696        driver = find_driver(&drivers_list, drv_name);
    97        
    9897        if (driver == NULL) {
    9998                log_msg(LVL_ERROR, "No driver named `%s' was found.", drv_name);
     
    107106        drv_name = NULL;
    108107       
     108        fibril_mutex_lock(&driver->driver_mutex);
     109       
     110        if (driver->phone >= 0) {
     111                /* We already have a connection to the driver. */
     112                log_msg(LVL_ERROR, "Driver '%s' already started.\n",
     113                    driver->name);
     114                fibril_mutex_unlock(&driver->driver_mutex);
     115                async_answer_0(iid, EEXISTS);
     116                return NULL;
     117        }
     118       
     119        switch (driver->state) {
     120        case DRIVER_NOT_STARTED:
     121                /* Somebody started the driver manually. */
     122                log_msg(LVL_NOTE, "Driver '%s' started manually.\n",
     123                    driver->name);
     124                driver->state = DRIVER_STARTING;
     125                break;
     126        case DRIVER_STARTING:
     127                /* The expected case */
     128                break;
     129        case DRIVER_RUNNING:
     130                /* Should not happen since we do not have a connected phone */
     131                assert(false);
     132        }
     133       
    109134        /* Create connection to the driver. */
    110135        log_msg(LVL_DEBUG, "Creating connection to the `%s' driver.",
     
    113138        ipc_callid_t callid = async_get_call(&call);
    114139        if (IPC_GET_IMETHOD(call) != IPC_M_CONNECT_TO_ME) {
     140                fibril_mutex_unlock(&driver->driver_mutex);
    115141                async_answer_0(callid, ENOTSUP);
    116142                async_answer_0(iid, ENOTSUP);
     
    119145       
    120146        /* Remember driver's phone. */
    121         set_driver_phone(driver, IPC_GET_ARG5(call));
     147        driver->phone = IPC_GET_ARG5(call);
     148       
     149        fibril_mutex_unlock(&driver->driver_mutex);
    122150       
    123151        log_msg(LVL_NOTE,
     
    578606                method = DRIVER_CLIENT;
    579607       
    580         if (driver->phone <= 0) {
     608        if (driver->phone < 0) {
    581609                log_msg(LVL_ERROR,
    582610                    "Could not forward to driver `%s' (phone is %d).",
     
    618646        dev = fun->dev;
    619647       
    620         if (dev->state != DEVICE_USABLE || dev->drv->phone <= 0) {
     648        if (dev->state != DEVICE_USABLE || dev->drv->phone < 0) {
    621649                async_answer_0(iid, EINVAL);
    622650                return;
  • uspace/srv/devmap/Makefile

    r82582e4 rdf3c6f02  
    3030USPACE_PREFIX = ../..
    3131BINARY = devmap
     32STATIC_NEEDED = y
    3233
    3334SOURCES = \
  • uspace/srv/fs/devfs/Makefile

    r82582e4 rdf3c6f02  
    3232EXTRA_CFLAGS += -I$(LIBFS_PREFIX)
    3333BINARY = devfs
     34STATIC_NEEDED = y
    3435
    3536SOURCES = \
  • uspace/srv/fs/fat/Makefile

    r82582e4 rdf3c6f02  
    3232EXTRA_CFLAGS += -I$(LIBBLOCK_PREFIX) -I$(LIBFS_PREFIX)
    3333BINARY = fat
     34STATIC_NEEDED = y
    3435
    3536SOURCES = \
  • uspace/srv/fs/fat/fat_fat.c

    r82582e4 rdf3c6f02  
    4747#include <assert.h>
    4848#include <fibril_synch.h>
     49#include <malloc.h>
    4950#include <mem.h>
    5051
  • uspace/srv/fs/fat/fat_idx.c

    r82582e4 rdf3c6f02  
    4444#include <assert.h>
    4545#include <fibril_synch.h>
     46#include <malloc.h>
    4647
    4748/** Each instance of this type describes one interval of freed VFS indices. */
  • uspace/srv/fs/fat/fat_ops.c

    r82582e4 rdf3c6f02  
    5555#include <sys/mman.h>
    5656#include <align.h>
     57#include <malloc.h>
    5758
    5859#define FAT_NODE(node)  ((node) ? (fat_node_t *) (node)->data : NULL)
  • uspace/srv/fs/tmpfs/Makefile

    r82582e4 rdf3c6f02  
    3232EXTRA_CFLAGS += -I$(LIBBLOCK_PREFIX) -I$(LIBFS_PREFIX)
    3333BINARY = tmpfs
     34STATIC_NEEDED = y
    3435
    3536SOURCES = \
  • uspace/srv/hw/irc/apic/apic.c

    r82582e4 rdf3c6f02  
    5656static int apic_enable_irq(sysarg_t irq)
    5757{
    58         /* FIXME: TODO */
     58        // FIXME: TODO
    5959        return ENOTSUP;
    6060}
  • uspace/srv/hw/netif/ne2000/dp8390.c

    r82582e4 rdf3c6f02  
    5353#include <byteorder.h>
    5454#include <errno.h>
     55#include <stdio.h>
    5556#include <libarch/ddi.h>
    5657#include <net/packet.h>
  • uspace/srv/loader/Makefile

    r82582e4 rdf3c6f02  
    3636-include $(COMMON_MAKEFILE)
    3737-include $(CONFIG_MAKEFILE)
    38 -include arch/$(UARCH)/Makefile.inc
    3938
    40 LINKER_SCRIPT = arch/$(UARCH)/_link.ld
    41 EXTRA_CLEAN = $(LINKER_SCRIPT)
     39LINKER_SCRIPT = $(LIBC_PREFIX)/arch/$(UARCH)/_link-loader.ld
    4240
    4341EXTRA_CFLAGS = -Iinclude
    4442
    4543BINARY = loader
     44STATIC_ONLY = y
    4645
    4746GENERIC_SOURCES = \
     
    5554
    5655include $(USPACE_PREFIX)/Makefile.common
    57 
    58 $(LINKER_SCRIPT): $(LINKER_SCRIPT).in
    59         $(GCC) $(DEFS) $(CFLAGS) -DLIBC_PREFIX=$(LIBC_PREFIX) -E -x c $< | grep -v "^\#" > $@
  • uspace/srv/loader/elf_load.c

    r82582e4 rdf3c6f02  
    22 * Copyright (c) 2006 Sergey Bondari
    33 * Copyright (c) 2006 Jakub Jermar
    4  * Copyright (c) 2008 Jiri Svoboda
     4 * Copyright (c) 2011 Jiri Svoboda
    55 * All rights reserved.
    66 *
     
    5353#include <smc.h>
    5454#include <loader/pcb.h>
     55#include <entry_point.h>
    5556
    5657#include "elf.h"
    5758#include "elf_load.h"
    58 #include "arch.h"
    5959
    6060#define DPRINTF(...)
     
    103103 *
    104104 */
    105 int elf_load_file(const char *file_name, size_t so_bias, elf_info_t *info)
     105int elf_load_file(const char *file_name, size_t so_bias, eld_flags_t flags,
     106    elf_info_t *info)
    106107{
    107108        elf_ld_t elf;
     
    118119        elf.fd = fd;
    119120        elf.info = info;
     121        elf.flags = flags;
    120122
    121123        rc = elf_load(&elf, so_bias);
     
    124126
    125127        return rc;
    126 }
    127 
    128 /** Run an ELF executable.
    129  *
    130  * Transfers control to the entry point of an ELF executable loaded
    131  * earlier with elf_load_file(). This function does not return.
    132  *
    133  * @param info Info structure filled earlier by elf_load_file()
    134  *
    135  */
    136 void elf_run(elf_info_t *info, pcb_t *pcb)
    137 {
    138         program_run(info->entry, pcb);
    139 
    140         /* not reached */
    141128}
    142129
     
    153140        pcb->entry = info->entry;
    154141        pcb->dynamic = info->dynamic;
     142        pcb->rtld_runtime = NULL;
    155143}
    156144
     
    306294                break;
    307295        case PT_INTERP:
    308                 /* Assume silently interp == "/rtld.so" */
    309                 elf->info->interp = "/rtld.so";
     296                /* Assume silently interp == "/app/dload" */
     297                elf->info->interp = "/app/dload";
    310298                break;
    311299        case PT_DYNAMIC:
     300                /* Record pointer to dynamic section into info structure */
     301                elf->info->dynamic =
     302                    (void *)((uint8_t *)entry->p_vaddr + elf->bias);
     303                DPRINTF("dynamic section found at 0x%x\n",
     304                        (uintptr_t)elf->info->dynamic);
     305                break;
     306        case 0x70000000:
     307                /* FIXME: MIPS reginfo */
     308                break;
    312309        case PT_SHLIB:
    313         case PT_LOPROC:
    314         case PT_HIPROC:
     310//      case PT_LOPROC:
     311//      case PT_HIPROC:
    315312        default:
    316313                DPRINTF("Segment p_type %d unknown.\n", entry->p_type);
     
    383380            AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE);
    384381        if (a == (void *)(-1)) {
    385                 DPRINTF("Memory mapping failed.\n");
     382                DPRINTF("memory mapping failed (0x%x, %d)\n",
     383                        base+bias, mem_sz);
    386384                return EE_MEMORY;
    387385        }
     
    425423        }
    426424
     425        /*
     426         * The caller wants to modify the segments first. He will then
     427         * need to set the right access mode and ensure SMC coherence.
     428         */
     429        if ((elf->flags & ELDF_RW) != 0) return EE_OK;
     430
     431//      printf("set area flags to %d\n", flags);
    427432        rc = as_area_change_flags(seg_ptr, flags);
    428433        if (rc != 0) {
  • uspace/srv/loader/include/elf_load.h

    r82582e4 rdf3c6f02  
    4343#include "elf.h"
    4444
     45typedef enum {
     46        /** Leave all segments in RW access mode. */
     47        ELDF_RW = 1
     48} eld_flags_t;
     49
    4550/**
    4651 * Some data extracted from the headers are stored here
     
    6772        uintptr_t bias;
    6873
     74        /** Flags passed to the ELF loader. */
     75        eld_flags_t flags;
     76
    6977        /** A copy of the ELF file header */
    7078        elf_header_t *header;
     
    7482} elf_ld_t;
    7583
    76 int elf_load_file(const char *file_name, size_t so_bias, elf_info_t *info);
    77 void elf_run(elf_info_t *info, pcb_t *pcb);
     84int elf_load_file(const char *file_name, size_t so_bias, eld_flags_t flags,
     85    elf_info_t *info);
    7886void elf_create_pcb(elf_info_t *info, pcb_t *pcb);
    7987
  • uspace/srv/loader/main.c

    r82582e4 rdf3c6f02  
    5555#include <macros.h>
    5656#include <loader/pcb.h>
     57#include <entry_point.h>
    5758#include <errno.h>
    5859#include <async.h>
     
    6263#include <elf.h>
    6364#include <elf_load.h>
     65
     66#ifdef CONFIG_RTLD
     67#include <rtld/rtld.h>
     68#include <rtld/dynamic.h>
     69#include <rtld/module.h>
     70
     71static int ldr_load_dyn_linked(elf_info_t *p_info);
     72#endif
    6473
    6574#define DPRINTF(...)
     
    8998
    9099static elf_info_t prog_info;
    91 static elf_info_t interp_info;
    92 
    93 static bool is_dyn_linked;
    94100
    95101/** Used to limit number of connections to one. */
    96102static bool connected = false;
     103
     104#ifdef CONFIG_RTLD
     105/** State structure of the dynamic linker. */
     106runtime_env_t dload_re;
     107static module_t prog_mod;
     108#endif
    97109
    98110static void ldr_get_taskid(ipc_callid_t rid, ipc_call_t *request)
     
    283295        int rc;
    284296       
    285         rc = elf_load_file(pathname, 0, &prog_info);
     297        rc = elf_load_file(pathname, 0, 0, &prog_info);
    286298        if (rc != EE_OK) {
    287299                DPRINTF("Failed to load executable '%s'.\n", pathname);
     
    302314        if (prog_info.interp == NULL) {
    303315                /* Statically linked program */
    304                 is_dyn_linked = false;
    305316                async_answer_0(rid, EOK);
    306317                return 0;
    307318        }
    308319       
    309         rc = elf_load_file(prog_info.interp, 0, &interp_info);
    310         if (rc != EE_OK) {
    311                 DPRINTF("Failed to load interpreter '%s.'\n",
    312                     prog_info.interp);
    313                 async_answer_0(rid, EINVAL);
    314                 return 1;
    315         }
    316        
    317         is_dyn_linked = true;
    318         async_answer_0(rid, EOK);
    319        
     320        DPRINTF("Binary is dynamically linked.\n");
     321#ifdef CONFIG_RTLD
     322        DPRINTF(" - pcb address: %p\n", &pcb);
     323        DPRINTF( "- prog dynamic: %p\n", prog_info.dynamic);
     324
     325        rc = ldr_load_dyn_linked(&prog_info);
     326#else
     327        rc = ENOTSUP;
     328#endif
     329        async_answer_0(rid, rc);
    320330        return 0;
    321331}
    322332
     333#ifdef CONFIG_RTLD
     334
     335static int ldr_load_dyn_linked(elf_info_t *p_info)
     336{
     337        runtime_env = &dload_re;
     338
     339        DPRINTF("Load dynamically linked program.\n");
     340
     341        /*
     342         * First we need to process dynamic sections of the executable
     343         * program and insert it into the module graph.
     344         */
     345
     346        DPRINTF("Parse program .dynamic section at %p\n", p_info->dynamic);
     347        dynamic_parse(p_info->dynamic, 0, &prog_mod.dyn);
     348        prog_mod.bias = 0;
     349        prog_mod.dyn.soname = "[program]";
     350
     351        /* Initialize list of loaded modules */
     352        list_initialize(&runtime_env->modules_head);
     353        list_append(&prog_mod.modules_link, &runtime_env->modules_head);
     354
     355        /* Pointer to program module. Used as root of the module graph. */
     356        runtime_env->program = &prog_mod;
     357
     358        /* Work around non-existent memory space allocation. */
     359        runtime_env->next_bias = 0x1000000;
     360
     361        /*
     362         * Now we can continue with loading all other modules.
     363         */
     364
     365        DPRINTF("Load all program dependencies\n");
     366        module_load_deps(&prog_mod);
     367
     368        /*
     369         * Now relocate/link all modules together.
     370         */
     371
     372        /* Process relocations in all modules */
     373        DPRINTF("Relocate all modules\n");
     374        modules_process_relocs(&prog_mod);
     375
     376        /* Pass runtime evironment pointer through PCB. */
     377        pcb.rtld_runtime = (void *) runtime_env;
     378
     379        return 0;
     380}
     381#endif
    323382
    324383/** Run the previously loaded program.
     
    332391        const char *cp;
    333392       
     393        DPRINTF("Set task name\n");
     394
    334395        /* Set the task name. */
    335396        cp = str_rchr(pathname, '/');
     
    337398        task_set_name(cp);
    338399       
    339         if (is_dyn_linked == true) {
    340                 /* Dynamically linked program */
    341                 DPRINTF("Run ELF interpreter.\n");
    342                 DPRINTF("Entry point: %p\n", interp_info.entry);
    343                
    344                 async_answer_0(rid, EOK);
    345                 elf_run(&interp_info, &pcb);
    346         } else {
    347                 /* Statically linked program */
    348                 async_answer_0(rid, EOK);
    349                 elf_run(&prog_info, &pcb);
    350         }
     400        /* Run program */
     401        DPRINTF("Reply OK\n");
     402        async_answer_0(rid, EOK);
     403        DPRINTF("Jump to entry point at %p\n", pcb.entry);
     404        entry_point_jmp(prog_info.entry, &pcb);
    351405       
    352406        /* Not reached */
  • uspace/srv/net/il/ip/ip.c

    r82582e4 rdf3c6f02  
    201201
    202202        /* Set the destination address */
    203         switch (header->version) {
     203        switch (GET_IP_HEADER_VERSION(header)) {
    204204        case IPVERSION:
    205205                addrlen = sizeof(dest_in);
     
    365365               
    366366                if (ip_netif->dhcp) {
    367                         /* TODO dhcp */
     367                        // TODO dhcp
    368368                        net_free_settings(configuration, data);
    369369                        return ENOTSUP;
     
    398398                        }
    399399                } else {
    400                         /* TODO ipv6 in separate module */
     400                        // TODO ipv6 in separate module
    401401                        net_free_settings(configuration, data);
    402402                        return ENOTSUP;
     
    517517            ip_netif->dhcp ? "dhcp" : "static");
    518518       
    519         /* TODO ipv6 addresses */
     519        // TODO ipv6 addresses
    520520       
    521521        char address[INET_ADDRSTRLEN];
     
    635635
    636636        /* Process all IP options */
    637         while (next < first->header_length) {
     637        while (next < GET_IP_HEADER_LENGTH(first)) {
    638638                option = (ip_option_t *) (((uint8_t *) first) + next);
    639639                /* Skip end or noop */
     
    656656        if (length % 4) {
    657657                bzero(((uint8_t *) last) + length, 4 - (length % 4));
    658                 last->header_length = length / 4 + 1;
     658                SET_IP_HEADER_LENGTH(last, (length / 4 + 1));
    659659        } else {
    660                 last->header_length = length / 4;
     660                SET_IP_HEADER_LENGTH(last, (length / 4));
    661661        }
    662662
     
    706706                return rc;
    707707       
    708         header->version = IPV4;
    709         header->fragment_offset_high = 0;
     708        SET_IP_HEADER_VERSION(header, IPV4);
     709        SET_IP_HEADER_FRAGMENT_OFFSET_HIGH(header, 0);
    710710        header->fragment_offset_low = 0;
    711711        header->header_checksum = 0;
     
    735735                        memcpy(middle_header, last_header,
    736736                            IP_HEADER_LENGTH(last_header));
    737                         header->flags |= IPFLAG_MORE_FRAGMENTS;
     737                        SET_IP_HEADER_FLAGS(header,
     738                            (GET_IP_HEADER_FLAGS(header) | IPFLAG_MORE_FRAGMENTS));
    738739                        middle_header->total_length =
    739740                            htons(packet_get_data_length(next));
    740                         middle_header->fragment_offset_high =
    741                             IP_COMPUTE_FRAGMENT_OFFSET_HIGH(length);
     741                        SET_IP_HEADER_FRAGMENT_OFFSET_HIGH(middle_header,
     742                            IP_COMPUTE_FRAGMENT_OFFSET_HIGH(length));
    742743                        middle_header->fragment_offset_low =
    743744                            IP_COMPUTE_FRAGMENT_OFFSET_LOW(length);
     
    768769                middle_header->total_length =
    769770                    htons(packet_get_data_length(next));
    770                 middle_header->fragment_offset_high =
    771                     IP_COMPUTE_FRAGMENT_OFFSET_HIGH(length);
     771                SET_IP_HEADER_FRAGMENT_OFFSET_HIGH(middle_header,
     772                    IP_COMPUTE_FRAGMENT_OFFSET_HIGH(length));
    772773                middle_header->fragment_offset_low =
    773774                    IP_COMPUTE_FRAGMENT_OFFSET_LOW(length);
     
    785786                length += packet_get_data_length(next);
    786787                free(last_header);
    787                 header->flags |= IPFLAG_MORE_FRAGMENTS;
     788                SET_IP_HEADER_FLAGS(header,
     789                    (GET_IP_HEADER_FLAGS(header) | IPFLAG_MORE_FRAGMENTS));
    788790        }
    789791
     
    834836        new_header->total_length = htons(IP_HEADER_LENGTH(new_header) + length);
    835837        offset = IP_FRAGMENT_OFFSET(header) + IP_HEADER_DATA_LENGTH(header);
    836         new_header->fragment_offset_high =
    837             IP_COMPUTE_FRAGMENT_OFFSET_HIGH(offset);
     838        SET_IP_HEADER_FRAGMENT_OFFSET_HIGH(new_header,
     839            IP_COMPUTE_FRAGMENT_OFFSET_HIGH(offset));
    838840        new_header->fragment_offset_low =
    839841            IP_COMPUTE_FRAGMENT_OFFSET_LOW(offset);
     
    865867                return NULL;
    866868        memcpy(middle, last, IP_HEADER_LENGTH(last));
    867         middle->flags |= IPFLAG_MORE_FRAGMENTS;
     869        SET_IP_HEADER_FLAGS(middle,
     870            (GET_IP_HEADER_FLAGS(middle) | IPFLAG_MORE_FRAGMENTS));
    868871        return middle;
    869872}
     
    922925
    923926        /* Fragmentation forbidden? */
    924         if(header->flags & IPFLAG_DONT_FRAGMENT)
     927        if(GET_IP_HEADER_FLAGS(header) & IPFLAG_DONT_FRAGMENT)
    925928                return EPERM;
    926929
     
    946949
    947950        /* Greatest multiple of 8 lower than content */
    948         /* TODO even fragmentation? */
     951        // TODO even fragmentation?
    949952        length = length & ~0x7;
    950953       
     
    958961
    959962        /* Mark the first as fragmented */
    960         header->flags |= IPFLAG_MORE_FRAGMENTS;
     963        SET_IP_HEADER_FLAGS(header,
     964            (GET_IP_HEADER_FLAGS(header) | IPFLAG_MORE_FRAGMENTS));
    961965
    962966        /* Create middle fragments */
     
    12121216        }
    12131217       
    1214         /* Ff the local host is the destination */
     1218        /* If the local host is the destination */
    12151219        if ((route->address.s_addr == dest->s_addr) &&
    12161220            (dest->s_addr != IPV4_LOCALHOST_ADDRESS)) {
     
    12791283        in_addr_t destination;
    12801284
    1281         /* TODO search set ipopt route? */
     1285        // TODO search set ipopt route?
    12821286        destination.s_addr = header->destination_address;
    12831287        return destination;
     
    13191323        int rc;
    13201324
    1321         if ((header->flags & IPFLAG_MORE_FRAGMENTS) ||
     1325        if ((GET_IP_HEADER_FLAGS(header) & IPFLAG_MORE_FRAGMENTS) ||
    13221326            IP_FRAGMENT_OFFSET(header)) {
    1323                 /* TODO fragmented */
     1327                // TODO fragmented
    13241328                return ENOTSUP;
    13251329        }
    13261330       
    1327         switch (header->version) {
     1331        switch (GET_IP_HEADER_VERSION(header)) {
    13281332        case IPVERSION:
    13291333                addrlen = sizeof(src_in);
     
    14371441                phone = ip_prepare_icmp_and_get_phone(0, packet, header);
    14381442                if (phone >= 0) {
    1439                         /* ttl exceeded ICMP */
     1443                        /* TTL exceeded ICMP */
    14401444                        icmp_time_exceeded_msg(phone, ICMP_EXC_TTL, packet);
    14411445                }
     
    14471451
    14481452        /* Set the destination address */
    1449         switch (header->version) {
     1453        switch (GET_IP_HEADER_VERSION(header)) {
    14501454        case IPVERSION:
    14511455                addrlen = sizeof(addr_in);
     
    17771781                if ((type != ICMP_DEST_UNREACH) ||
    17781782                    (code != ICMP_HOST_UNREACH)) {
    1779                         /* No, something else */
     1783                        /* No, something else */
    17801784                        break;
    17811785                }
  • uspace/srv/net/tl/icmp/Makefile

    r82582e4 rdf3c6f02  
    3232EXTRA_CFLAGS = -I$(LIBNET_PREFIX)/include
    3333BINARY = icmp
     34STATIC_ONLY = y
    3435
    3536SOURCES = \
  • uspace/srv/net/tl/tcp/tcp.c

    r82582e4 rdf3c6f02  
    476476        old_incoming = socket_data->next_incoming;
    477477
    478         if (header->finalize) {
     478        if (GET_TCP_HEADER_FINALIZE(header)) {
    479479                socket_data->fin_incoming = new_sequence_number +
    480480                    total_length - TCP_HEADER_LENGTH(header);
     
    838838        assert(packet);
    839839
    840         if (!header->synchronize)
     840        if (!GET_TCP_HEADER_SYNCHRONIZE(header))
    841841                return tcp_release_and_return(packet, EINVAL);
    842842       
     
    903903        assert(packet);
    904904
    905         if (!header->synchronize)
     905        if (!GET_TCP_HEADER_SYNCHRONIZE(header))
    906906                return tcp_release_and_return(packet, EINVAL);
    907907
     
    10571057        assert(packet);
    10581058
    1059         if (!header->acknowledge)
     1059        if (!GET_TCP_HEADER_ACKNOWLEDGE(header))
    10601060                return tcp_release_and_return(packet, EINVAL);
    10611061
     
    11261126        assert(header);
    11271127
    1128         if (!header->acknowledge)
     1128        if (!GET_TCP_HEADER_ACKNOWLEDGE(header))
    11291129                return;
    11301130
     
    18331833
    18341834        /* Remember the outgoing FIN */
    1835         if (header->finalize)
     1835        if (GET_TCP_HEADER_FINALIZE(header))
    18361836                socket_data->fin_outgoing = socket_data->next_outgoing;
    18371837       
     
    19521952                header->acknowledgement_number =
    19531953                    htonl(socket_data->next_incoming);
    1954                 header->acknowledge = 1;
     1954                SET_TCP_HEADER_ACKNOWLEDGE(header, 1);
    19551955        }
    19561956        header->window = htons(socket_data->window);
     
    20242024        header->source_port = htons(socket->port);
    20252025        header->source_port = htons(socket_data->dest_port);
    2026         header->header_length = TCP_COMPUTE_HEADER_LENGTH(sizeof(*header));
    2027         header->synchronize = synchronize;
    2028         header->finalize = finalize;
     2026        SET_TCP_HEADER_LENGTH(header,
     2027            TCP_COMPUTE_HEADER_LENGTH(sizeof(*header)));
     2028        SET_TCP_HEADER_SYNCHRONIZE(header, synchronize);
     2029        SET_TCP_HEADER_FINALIZE(header, finalize);
    20292030}
    20302031
  • uspace/srv/net/tl/tcp/tcp_header.h

    r82582e4 rdf3c6f02  
    4747 * @param[in] header The TCP packet header.
    4848 */
    49 #define TCP_HEADER_LENGTH(header)               ((header)->header_length * 4U)
     49#define TCP_HEADER_LENGTH(header)               (GET_TCP_HEADER_LENGTH(header) * 4U)
    5050
    5151/** Returns the TCP header length.
     
    7373        uint32_t sequence_number;
    7474        uint32_t acknowledgement_number;
    75        
    76 #ifdef ARCH_IS_BIG_ENDIAN
    77         uint8_t header_length:4;
    78         uint8_t reserved1:4;
    79 #else
    80         uint8_t reserved1:4;
    81         uint8_t header_length:4;
    82 #endif
    8375
    84 #ifdef ARCH_IS_BIG_ENDIAN
    85         uint8_t reserved2:2;
    86         uint8_t urgent:1;
    87         uint8_t acknowledge:1;
    88         uint8_t push:1;
    89         uint8_t reset:1;
    90         uint8_t synchronize:1;
    91         uint8_t finalize:1;
    92 #else
    93         uint8_t finalize:1;
    94         uint8_t synchronize:1;
    95         uint8_t reset:1;
    96         uint8_t push:1;
    97         uint8_t acknowledge:1;
    98         uint8_t urgent:1;
    99         uint8_t reserved2:2;
    100 #endif
     76        uint8_t hlr; /* header length, reserved1 */
     77
     78#define GET_TCP_HEADER_LENGTH(header) \
     79        (((header)->hlr & 0xf0) >> 4)
     80#define SET_TCP_HEADER_LENGTH(header, length) \
     81        ((header)->hlr = \
     82         ((length & 0x0f) << 4) | ((header)->hlr & 0x0f))
     83
     84#define GET_TCP_HEADER_RESERVED1(header) \
     85        ((header)->hlr & 0x0f)
     86#define SET_TCP_HEADER_RESERVED1(header, reserved1) \
     87        ((header)->hlr = \
     88         (reserved1 & 0x0f) | ((header)->hlr & 0xf0))
     89
     90        /* reserved2, urgent, acknowledge, push, reset, synchronize, finalize */
     91        uint8_t ruaprsf; 
     92
     93#define GET_TCP_HEADER_RESERVED2(header) \
     94        (((header)->ruaprsf & 0xc0) >> 6)
     95#define SET_TCP_HEADER_RESERVED2(header, reserved2) \
     96        ((header)->ruaprsf = \
     97         ((reserved2 & 0x03) << 6) | ((header)->ruaprsf & 0x3f))
     98
     99#define GET_TCP_HEADER_URGENT(header) \
     100        (((header)->ruaprsf & 0x20) >> 5)
     101#define SET_TCP_HEADER_URGENT(header, urgent) \
     102        ((header)->ruaprsf = \
     103         ((urgent & 0x01) << 5) | ((header)->ruaprsf & 0xdf))
     104
     105#define GET_TCP_HEADER_ACKNOWLEDGE(header) \
     106        (((header)->ruaprsf & 0x10) >> 4)
     107#define SET_TCP_HEADER_ACKNOWLEDGE(header, acknowledge) \
     108        ((header)->ruaprsf = \
     109         ((acknowledge & 0x01) << 4) | ((header)->ruaprsf & 0xef))
     110
     111#define GET_TCP_HEADER_PUSH(header) \
     112        (((header)->ruaprsf & 0x08) >> 3)
     113#define SET_TCP_HEADER_PUSH(header, push) \
     114        ((header)->ruaprsf = \
     115         ((push & 0x01) << 3) | ((header)->ruaprsf & 0xf7))
     116
     117#define GET_TCP_HEADER_RESET(header) \
     118        (((header)->ruaprsf & 0x04) >> 2)
     119#define SET_TCP_HEADER_RESET(header, reset) \
     120        ((header)->ruaprsf = \
     121         ((reset & 0x01) << 2) | ((header)->ruaprsf & 0xfb))
     122
     123#define GET_TCP_HEADER_SYNCHRONIZE(header) \
     124        (((header)->ruaprsf & 0x02) >> 1)
     125#define SET_TCP_HEADER_SYNCHRONIZE(header, synchronize) \
     126        ((header)->ruaprsf = \
     127         ((synchronize & 0x01) << 1) | ((header)->ruaprsf & 0xfd))
     128
     129#define GET_TCP_HEADER_FINALIZE(header) \
     130        ((header)->ruaprsf & 0x01)
     131#define SET_TCP_HEADER_FINALIZE(header, finalize) \
     132        ((header)->ruaprsf = \
     133         (finalize & 0x01) | ((header)->ruaprsf & 0xfe))
    101134
    102135        uint16_t window;
  • uspace/srv/ns/Makefile

    r82582e4 rdf3c6f02  
    3030USPACE_PREFIX = ../..
    3131BINARY = ns
     32STATIC_NEEDED = y
    3233
    3334SOURCES = \
  • uspace/srv/ns/clonable.c

    r82582e4 rdf3c6f02  
    7878        if (list_empty(&cs_req)) {
    7979                /* There was no pending connection request. */
    80                 printf(NAME ": Unexpected clonable server.\n");
     80                printf("%s: Unexpected clonable server.\n", NAME);
    8181                ipc_answer_0(callid, EBUSY);
    8282                return;
  • uspace/srv/ns/service.c

    r82582e4 rdf3c6f02  
    3535#include <assert.h>
    3636#include <errno.h>
     37#include <stdio.h>
     38#include <malloc.h>
    3739#include "service.h"
    3840#include "ns.h"
  • uspace/srv/ns/task.c

    r82582e4 rdf3c6f02  
    3939#include <stdio.h>
    4040#include <macros.h>
     41#include <malloc.h>
    4142#include "task.h"
    4243#include "ns.h"
  • uspace/srv/vfs/Makefile

    r82582e4 rdf3c6f02  
    3030USPACE_PREFIX = ../..
    3131BINARY = vfs
     32STATIC_NEEDED = y
    3233
    3334SOURCES = \
  • uspace/srv/vfs/vfs_ops.c

    r82582e4 rdf3c6f02  
    611611void vfs_open_node(ipc_callid_t rid, ipc_call_t *request)
    612612{
    613         /* FIXME: check for sanity of the supplied fs, dev and index */
     613        // FIXME: check for sanity of the supplied fs, dev and index
    614614       
    615615        /*
Note: See TracChangeset for help on using the changeset viewer.