Changeset c47e1a8 in mainline for uspace/srv/bd


Ignore:
Timestamp:
2010-05-21T07:50:04Z (16 years ago)
Author:
Lenka Trochtova <trochtova.lenka@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d51ee2b
Parents:
cf8cc36 (diff), 15b592b (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 (rev. 451)

Location:
uspace/srv/bd
Files:
12 edited

Legend:

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

    rcf8cc36 rc47e1a8  
    2929
    3030USPACE_PREFIX = ../../..
    31 LIBS = $(LIBC_PREFIX)/libc.a
    32 
    33 OUTPUT = ata_bd
     31BINARY = ata_bd
    3432
    3533SOURCES = \
    3634        ata_bd.c
    3735
    38 include ../../Makefile.common
     36include $(USPACE_PREFIX)/Makefile.common
  • uspace/srv/bd/ata_bd/ata_bd.c

    rcf8cc36 rc47e1a8  
    5656#include <as.h>
    5757#include <fibril_synch.h>
    58 #include <string.h>
     58#include <str.h>
    5959#include <devmap.h>
    6060#include <sys/types.h>
     
    500500
    501501        d = &disk[disk_id];
    502         bc.h = 0;       /* Silence warning. */
     502       
     503        /* Silence warning. */
     504        memset(&bc, 0, sizeof(bc));
    503505
    504506        /* Compute block coordinates. */
     
    574576
    575577        d = &disk[disk_id];
    576         bc.h = 0;       /* Silence warning. */
     578       
     579        /* Silence warning. */
     580        memset(&bc, 0, sizeof(bc));
    577581
    578582        /* Compute block coordinates. */
  • uspace/srv/bd/ata_bd/ata_bd.h

    rcf8cc36 rc47e1a8  
    3838#include <sys/types.h>
    3939#include <fibril_synch.h>
    40 #include <string.h>
     40#include <str.h>
    4141
    4242enum {
  • uspace/srv/bd/file_bd/Makefile

    rcf8cc36 rc47e1a8  
    2929
    3030USPACE_PREFIX = ../../..
    31 LIBS = $(LIBC_PREFIX)/libc.a
    32 
    33 OUTPUT = file_bd
     31BINARY = file_bd
    3432
    3533SOURCES = \
    3634        file_bd.c
    3735
    38 include ../../Makefile.common
     36include $(USPACE_PREFIX)/Makefile.common
  • uspace/srv/bd/file_bd/file_bd.c

    rcf8cc36 rc47e1a8  
    4848#include <devmap.h>
    4949#include <sys/types.h>
     50#include <sys/typefmt.h>
    5051#include <errno.h>
    5152#include <bool.h>
     
    5657
    5758static const size_t block_size = 512;
    58 static bn_t num_blocks;
     59static aoff64_t num_blocks;
    5960static FILE *img;
    6061
     
    207208        int rc;
    208209
     210        /* Check whether access is within device address bounds. */
     211        if (ba + cnt > num_blocks) {
     212                printf(NAME ": Accessed blocks %" PRIuOFF64 "-%" PRIuOFF64 ", while "
     213                    "max block number is %" PRIuOFF64 ".\n", ba, ba + cnt - 1,
     214                    num_blocks - 1);
     215                return ELIMIT;
     216        }
     217
    209218        fibril_mutex_lock(&dev_lock);
    210219
     
    237246        int rc;
    238247
     248        /* Check whether access is within device address bounds. */
     249        if (ba + cnt > num_blocks) {
     250                printf(NAME ": Accessed blocks %" PRIuOFF64 "-%" PRIuOFF64 ", while "
     251                    "max block number is %" PRIuOFF64 ".\n", ba, ba + cnt - 1,
     252                    num_blocks - 1);
     253                return ELIMIT;
     254        }
     255
    239256        fibril_mutex_lock(&dev_lock);
    240257
  • uspace/srv/bd/gxe_bd/Makefile

    rcf8cc36 rc47e1a8  
    2929
    3030USPACE_PREFIX = ../../..
    31 LIBS = $(LIBC_PREFIX)/libc.a
    32 
    33 OUTPUT = gxe_bd
     31BINARY = gxe_bd
    3432
    3533SOURCES = \
    3634        gxe_bd.c
    3735
    38 include ../../Makefile.common
     36include $(USPACE_PREFIX)/Makefile.common
  • uspace/srv/bd/part/guid_part/Makefile

    rcf8cc36 rc47e1a8  
    2828
    2929USPACE_PREFIX = ../../../..
    30 LIBS = $(LIBBLOCK_PREFIX)/libblock.a $(LIBC_PREFIX)/libc.a
     30LIBS = $(LIBBLOCK_PREFIX)/libblock.a
    3131EXTRA_CFLAGS = -I$(LIBBLOCK_PREFIX)
    3232
    3333# Correct name is 'guid_part' but must use this because of FAT 8.3 names.
    34 OUTPUT = g_part
     34BINARY = g_part
    3535
    3636SOURCES = \
    3737        guid_part.c
    3838
    39 include ../../../Makefile.common
     39include $(USPACE_PREFIX)/Makefile.common
  • uspace/srv/bd/part/guid_part/guid_part.c

    rcf8cc36 rc47e1a8  
    7979        bool present;
    8080        /** Address of first block */
    81         bn_t start_addr;
     81        aoff64_t start_addr;
    8282        /** Number of blocks */
    83         bn_t length;
     83        aoff64_t length;
    8484        /** Device representing the partition (outbound device) */
    8585        dev_handle_t dev;
     
    101101static void gpt_pte_to_part(const gpt_entry_t *pte, part_t *part);
    102102static void gpt_connection(ipc_callid_t iid, ipc_call_t *icall);
    103 static int gpt_bd_read(part_t *p, bn_t ba, size_t cnt, void *buf);
    104 static int gpt_bd_write(part_t *p, bn_t ba, size_t cnt, const void *buf);
    105 static int gpt_bsa_translate(part_t *p, bn_t ba, size_t cnt, bn_t *gba);
     103static int gpt_bd_read(part_t *p, aoff64_t ba, size_t cnt, void *buf);
     104static int gpt_bd_write(part_t *p, aoff64_t ba, size_t cnt, const void *buf);
     105static int gpt_bsa_translate(part_t *p, aoff64_t ba, size_t cnt, aoff64_t *gba);
    106106
    107107int main(int argc, char **argv)
     
    199199                    / (1024 * 1024);
    200200                printf(NAME ": Registered device %s: %" PRIu64 " blocks "
    201                     "%" PRIuBN " MB.\n", name, part->length, size_mb);
     201                    "%" PRIuOFF64 " MB.\n", name, part->length, size_mb);
    202202
    203203                part->dev = dev;
     
    319319        int flags;
    320320        int retval;
    321         bn_t ba;
     321        aoff64_t ba;
    322322        size_t cnt;
    323323        part_t *part;
     
    402402
    403403/** Read blocks from partition. */
    404 static int gpt_bd_read(part_t *p, bn_t ba, size_t cnt, void *buf)
    405 {
    406         bn_t gba;
     404static int gpt_bd_read(part_t *p, aoff64_t ba, size_t cnt, void *buf)
     405{
     406        aoff64_t gba;
    407407
    408408        if (gpt_bsa_translate(p, ba, cnt, &gba) != EOK)
     
    413413
    414414/** Write blocks to partition. */
    415 static int gpt_bd_write(part_t *p, bn_t ba, size_t cnt, const void *buf)
    416 {
    417         bn_t gba;
     415static int gpt_bd_write(part_t *p, aoff64_t ba, size_t cnt, const void *buf)
     416{
     417        aoff64_t gba;
    418418
    419419        if (gpt_bsa_translate(p, ba, cnt, &gba) != EOK)
     
    424424
    425425/** Translate block segment address with range checking. */
    426 static int gpt_bsa_translate(part_t *p, bn_t ba, size_t cnt, bn_t *gba)
     426static int gpt_bsa_translate(part_t *p, aoff64_t ba, size_t cnt, aoff64_t *gba)
    427427{
    428428        if (ba + cnt > p->length)
  • uspace/srv/bd/part/mbr_part/Makefile

    rcf8cc36 rc47e1a8  
    2929
    3030USPACE_PREFIX = ../../../..
    31 LIBS = $(LIBBLOCK_PREFIX)/libblock.a $(LIBC_PREFIX)/libc.a
     31LIBS = $(LIBBLOCK_PREFIX)/libblock.a
    3232EXTRA_CFLAGS = -I$(LIBBLOCK_PREFIX)
    33 
    34 OUTPUT = mbr_part
     33BINARY = mbr_part
    3534
    3635SOURCES = \
    3736        mbr_part.c
    3837
    39 include ../../../Makefile.common
     38include $(USPACE_PREFIX)/Makefile.common
  • uspace/srv/bd/part/mbr_part/mbr_part.c

    rcf8cc36 rc47e1a8  
    9797        bool present;
    9898        /** Address of first block */
    99         bn_t start_addr;
     99        aoff64_t start_addr;
    100100        /** Number of blocks */
    101         bn_t length;
     101        aoff64_t length;
    102102        /** Device representing the partition (outbound device) */
    103103        dev_handle_t dev;
     
    249249                size_mb = (part->length * block_size + 1024 * 1024 - 1)
    250250                    / (1024 * 1024);
    251                 printf(NAME ": Registered device %s: %" PRIuBN " blocks "
     251                printf(NAME ": Registered device %s: %" PRIuOFF64 " blocks "
    252252                    "%" PRIu64 " MB.\n", name, part->length, size_mb);
    253253
  • uspace/srv/bd/rd/Makefile

    rcf8cc36 rc47e1a8  
    2929
    3030USPACE_PREFIX = ../../..
    31 LIBS = $(LIBC_PREFIX)/libc.a
    32 
    33 OUTPUT = rd
     31BINARY = rd
    3432
    3533SOURCES = \
    3634        rd.c
    3735
    38 include ../../Makefile.common
     36include $(USPACE_PREFIX)/Makefile.common
  • uspace/srv/bd/rd/rd.c

    rcf8cc36 rc47e1a8  
    3232/** @addtogroup rd
    3333 * @{
    34  */ 
     34 */
    3535
    3636/**
    37  * @file        rd.c
    38  * @brief       Initial RAM disk for HelenOS.
     37 * @file rd.c
     38 * @brief Initial RAM disk for HelenOS.
    3939 */
    4040
     
    6161/** Pointer to the ramdisk's image */
    6262static void *rd_addr;
     63
    6364/** Size of the ramdisk */
    6465static size_t rd_size;
     
    7071static int rd_write_blocks(uint64_t ba, size_t cnt, const void *buf);
    7172
    72 /**
    73  * This rwlock protects the ramdisk's data.
     73/** This rwlock protects the ramdisk's data.
     74 *
    7475 * If we were to serve multiple requests (read + write or several writes)
    75  * concurrently (i.e. from two or more threads), each read and write needs to be
    76  * protected by this rwlock.
    77  */
     76 * concurrently (i.e. from two or more threads), each read and write needs to
     77 * be protected by this rwlock.
     78 *
     79 */
    7880fibril_rwlock_t rd_lock;
    7981
    8082/** Handle one connection to ramdisk.
    8183 *
    82  * @param iid           Hash of the request that opened the connection.
    83  * @param icall         Call data of the request that opened the connection.
     84 * @param iid   Hash of the request that opened the connection.
     85 * @param icall Call data of the request that opened the connection.
    8486 */
    8587static void rd_connection(ipc_callid_t iid, ipc_call_t *icall)
     
    9294        size_t cnt;
    9395        size_t comm_size;
    94 
     96       
    9597        /*
    9698         * Answer the first IPC_M_CONNECT_ME_TO call.
    9799         */
    98100        ipc_answer_0(iid, EOK);
    99 
     101       
    100102        /*
    101103         * Now we wait for the client to send us its communication as_area.
     
    108110                } else {
    109111                        ipc_answer_0(callid, EHANGUP);
    110                         return;         
     112                        return;
    111113                }
    112114        } else {
     
    178180                return ELIMIT;
    179181        }
    180 
     182       
    181183        fibril_rwlock_read_lock(&rd_lock);
    182184        memcpy(buf, rd_addr + ba * block_size, block_size * cnt);
    183185        fibril_rwlock_read_unlock(&rd_lock);
    184 
     186       
    185187        return EOK;
    186188}
     
    193195                return ELIMIT;
    194196        }
    195 
     197       
    196198        fibril_rwlock_write_lock(&rd_lock);
    197199        memcpy(rd_addr + ba * block_size, buf, block_size * cnt);
    198200        fibril_rwlock_write_unlock(&rd_lock);
    199 
     201       
    200202        return EOK;
    201203}
     
    204206static bool rd_init(void)
    205207{
    206         rd_size = sysinfo_value("rd.size");
    207         void *rd_ph_addr = (void *) sysinfo_value("rd.address.physical");
    208        
    209         if (rd_size == 0) {
    210                 printf(NAME ": No RAM disk found\n");
     208        int ret = sysinfo_get_value("rd.size", &rd_size);
     209        if ((ret != EOK) || (rd_size == 0)) {
     210                printf("%s: No RAM disk found\n", NAME);
     211                return false;
     212        }
     213       
     214        sysarg_t rd_ph_addr;
     215        ret = sysinfo_get_value("rd.address.physical", &rd_ph_addr);
     216        if ((ret != EOK) || (rd_ph_addr == 0)) {
     217                printf("%s: Invalid RAM disk physical address\n", NAME);
    211218                return false;
    212219        }
     
    215222       
    216223        int flags = AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE;
    217         int retval = physmem_map(rd_ph_addr, rd_addr,
     224        int retval = physmem_map((void *) rd_ph_addr, rd_addr,
    218225            ALIGN_UP(rd_size, PAGE_SIZE) >> PAGE_WIDTH, flags);
    219226       
    220227        if (retval < 0) {
    221                 printf(NAME ": Error mapping RAM disk\n");
    222                 return false;
    223         }
    224        
    225         printf(NAME ": Found RAM disk at %p, %d bytes\n", rd_ph_addr, rd_size);
     228                printf("%s: Error mapping RAM disk\n", NAME);
     229                return false;
     230        }
     231       
     232        printf("%s: Found RAM disk at %p, %d bytes\n", NAME, rd_ph_addr, rd_size);
    226233       
    227234        int rc = devmap_driver_register(NAME, rd_connection);
    228235        if (rc < 0) {
    229                 printf(NAME ": Unable to register driver (%d)\n", rc);
     236                printf("%s: Unable to register driver (%d)\n", NAME, rc);
    230237                return false;
    231238        }
     
    234241        if (devmap_device_register("bd/initrd", &dev_handle) != EOK) {
    235242                devmap_hangup_phone(DEVMAP_DRIVER);
    236                 printf(NAME ": Unable to register device\n");
     243                printf("%s: Unable to register device\n", NAME);
    237244                return false;
    238245        }
     
    245252int main(int argc, char **argv)
    246253{
    247         printf(NAME ": HelenOS RAM disk server\n");
     254        printf("%s: HelenOS RAM disk server\n", NAME);
    248255       
    249256        if (!rd_init())
    250257                return -1;
    251258       
    252         printf(NAME ": Accepting connections\n");
     259        printf("%s: Accepting connections\n", NAME);
    253260        async_manager();
    254261
Note: See TracChangeset for help on using the changeset viewer.