Changes in uspace/srv/bd/rd/rd.c [f302586:15f3c3f] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/bd/rd/rd.c
rf302586 r15f3c3f 55 55 #include <ipc/bd.h> 56 56 #include <macros.h> 57 #include <inttypes.h> 58 59 #define NAME "rd" 57 58 #define NAME "rd" 60 59 61 60 /** Pointer to the ramdisk's image */ … … 105 104 unsigned int flags; 106 105 if (async_share_out_receive(&callid, &comm_size, &flags)) { 107 (void) async_share_out_finalize(callid, &fs_va); 108 if (fs_va == (void *) -1) { 106 fs_va = as_get_mappable_page(comm_size); 107 if (fs_va) { 108 (void) async_share_out_finalize(callid, fs_va); 109 } else { 109 110 async_answer_0(callid, EHANGUP); 110 111 return; … … 207 208 static bool rd_init(void) 208 209 { 209 sysarg_t size; 210 int ret = sysinfo_get_value("rd.size", &size); 211 if ((ret != EOK) || (size == 0)) { 210 int ret = sysinfo_get_value("rd.size", &rd_size); 211 if ((ret != EOK) || (rd_size == 0)) { 212 212 printf("%s: No RAM disk found\n", NAME); 213 213 return false; 214 214 } 215 215 216 sysarg_t addr_phys;217 ret = sysinfo_get_value("rd.address.physical", & addr_phys);218 if ((ret != EOK) || ( addr_phys== 0)) {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)) { 219 219 printf("%s: Invalid RAM disk physical address\n", NAME); 220 220 return false; 221 221 } 222 222 223 rd_ size = ALIGN_UP(size, block_size);224 unsigned int flags =225 226 227 ret = physmem_map((void *) addr_phys,228 ALIGN_UP(rd_size, PAGE_SIZE) >> PAGE_WIDTH, flags, &rd_addr);229 if (ret != EOK) {223 rd_addr = as_get_mappable_page(rd_size); 224 225 int flags = AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE; 226 int retval = physmem_map((void *) rd_ph_addr, rd_addr, 227 ALIGN_UP(rd_size, PAGE_SIZE) >> PAGE_WIDTH, flags); 228 229 if (retval < 0) { 230 230 printf("%s: Error mapping RAM disk\n", NAME); 231 231 return false; 232 232 } 233 233 234 printf("%s: Found RAM disk at %p, %" PRIun " bytes\n", NAME, 235 (void *) addr_phys, size); 236 237 async_set_client_connection(rd_connection); 238 ret = loc_server_register(NAME); 239 if (ret < 0) { 240 printf("%s: Unable to register driver (%d)\n", NAME, ret); 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); 241 240 return false; 242 241 } 243 242 244 243 service_id_t service_id; 245 ret = loc_service_register("bd/initrd", &service_id); 246 if (ret != EOK) { 244 if (loc_service_register("bd/initrd", &service_id) != EOK) { 247 245 printf("%s: Unable to register device service\n", NAME); 248 246 return false;
Note:
See TracChangeset
for help on using the changeset viewer.