Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset b5daa89 in mainline


Ignore:
Timestamp:
2011-12-08T20:16:41Z (10 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master
Children:
c5ebb59
Parents:
28f8f170
Message:

align RAM disk size to block size
cstyle

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/bd/rd/rd.c

    r28f8f170 rb5daa89  
    5555#include <ipc/bd.h>
    5656#include <macros.h>
    57 
    58 #define NAME "rd"
     57#include <inttypes.h>
     58
     59#define NAME  "rd"
    5960
    6061/** Pointer to the ramdisk's image */
     
    208209static bool rd_init(void)
    209210{
    210         int ret = sysinfo_get_value("rd.size", &rd_size);
    211         if ((ret != EOK) || (rd_size == 0)) {
     211        sysarg_t size;
     212        int ret = sysinfo_get_value("rd.size", &size);
     213        if ((ret != EOK) || (size == 0)) {
    212214                printf("%s: No RAM disk found\n", NAME);
    213215                return false;
    214216        }
    215217       
    216         sysarg_t rd_ph_addr;
    217         ret = sysinfo_get_value("rd.address.physical", &rd_ph_addr);
    218         if ((ret != EOK) || (rd_ph_addr == 0)) {
     218        sysarg_t addr_phys;
     219        ret = sysinfo_get_value("rd.address.physical", &addr_phys);
     220        if ((ret != EOK) || (addr_phys == 0)) {
    219221                printf("%s: Invalid RAM disk physical address\n", NAME);
    220222                return false;
    221223        }
    222224       
     225        rd_size = ALIGN_UP(size, block_size);
    223226        rd_addr = as_get_mappable_page(rd_size);
    224227       
    225         int flags = AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE;
    226         int retval = physmem_map((void *) rd_ph_addr, rd_addr,
     228        unsigned int flags =
     229            AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE;
     230        ret = physmem_map((void *) addr_phys, rd_addr,
    227231            ALIGN_UP(rd_size, PAGE_SIZE) >> PAGE_WIDTH, flags);
    228        
    229         if (retval < 0) {
     232        if (ret < 0) {
    230233                printf("%s: Error mapping RAM disk\n", NAME);
    231234                return false;
    232235        }
    233236       
    234         printf("%s: Found RAM disk at %p, %zu bytes\n", NAME,
    235             (void *) rd_ph_addr, rd_size);
    236        
    237         int rc = loc_server_register(NAME, rd_connection);
    238         if (rc < 0) {
    239                 printf("%s: Unable to register driver (%d)\n", NAME, rc);
     237        printf("%s: Found RAM disk at %p, %" PRIun " bytes\n", NAME,
     238            (void *) addr_phys, size);
     239       
     240        ret = loc_server_register(NAME, rd_connection);
     241        if (ret < 0) {
     242                printf("%s: Unable to register driver (%d)\n", NAME, ret);
    240243                return false;
    241244        }
    242245       
    243246        service_id_t service_id;
    244         if (loc_service_register("bd/initrd", &service_id) != EOK) {
     247        ret = loc_service_register("bd/initrd", &service_id);
     248        if (ret != EOK) {
    245249                printf("%s: Unable to register device service\n", NAME);
    246250                return false;
Note: See TracChangeset for help on using the changeset viewer.