Changeset c47e1a8 in mainline for uspace/srv/bd
- Timestamp:
- 2010-05-21T07:50:04Z (16 years ago)
- 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. - Location:
- uspace/srv/bd
- Files:
-
- 12 edited
-
ata_bd/Makefile (modified) (1 diff)
-
ata_bd/ata_bd.c (modified) (3 diffs)
-
ata_bd/ata_bd.h (modified) (1 diff)
-
file_bd/Makefile (modified) (1 diff)
-
file_bd/file_bd.c (modified) (4 diffs)
-
gxe_bd/Makefile (modified) (1 diff)
-
part/guid_part/Makefile (modified) (1 diff)
-
part/guid_part/guid_part.c (modified) (7 diffs)
-
part/mbr_part/Makefile (modified) (1 diff)
-
part/mbr_part/mbr_part.c (modified) (2 diffs)
-
rd/Makefile (modified) (1 diff)
-
rd/rd.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/bd/ata_bd/Makefile
rcf8cc36 rc47e1a8 29 29 30 30 USPACE_PREFIX = ../../.. 31 LIBS = $(LIBC_PREFIX)/libc.a 32 33 OUTPUT = ata_bd 31 BINARY = ata_bd 34 32 35 33 SOURCES = \ 36 34 ata_bd.c 37 35 38 include ../../Makefile.common36 include $(USPACE_PREFIX)/Makefile.common -
uspace/srv/bd/ata_bd/ata_bd.c
rcf8cc36 rc47e1a8 56 56 #include <as.h> 57 57 #include <fibril_synch.h> 58 #include <str ing.h>58 #include <str.h> 59 59 #include <devmap.h> 60 60 #include <sys/types.h> … … 500 500 501 501 d = &disk[disk_id]; 502 bc.h = 0; /* Silence warning. */ 502 503 /* Silence warning. */ 504 memset(&bc, 0, sizeof(bc)); 503 505 504 506 /* Compute block coordinates. */ … … 574 576 575 577 d = &disk[disk_id]; 576 bc.h = 0; /* Silence warning. */ 578 579 /* Silence warning. */ 580 memset(&bc, 0, sizeof(bc)); 577 581 578 582 /* Compute block coordinates. */ -
uspace/srv/bd/ata_bd/ata_bd.h
rcf8cc36 rc47e1a8 38 38 #include <sys/types.h> 39 39 #include <fibril_synch.h> 40 #include <str ing.h>40 #include <str.h> 41 41 42 42 enum { -
uspace/srv/bd/file_bd/Makefile
rcf8cc36 rc47e1a8 29 29 30 30 USPACE_PREFIX = ../../.. 31 LIBS = $(LIBC_PREFIX)/libc.a 32 33 OUTPUT = file_bd 31 BINARY = file_bd 34 32 35 33 SOURCES = \ 36 34 file_bd.c 37 35 38 include ../../Makefile.common36 include $(USPACE_PREFIX)/Makefile.common -
uspace/srv/bd/file_bd/file_bd.c
rcf8cc36 rc47e1a8 48 48 #include <devmap.h> 49 49 #include <sys/types.h> 50 #include <sys/typefmt.h> 50 51 #include <errno.h> 51 52 #include <bool.h> … … 56 57 57 58 static const size_t block_size = 512; 58 static bn_t num_blocks;59 static aoff64_t num_blocks; 59 60 static FILE *img; 60 61 … … 207 208 int rc; 208 209 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 209 218 fibril_mutex_lock(&dev_lock); 210 219 … … 237 246 int rc; 238 247 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 239 256 fibril_mutex_lock(&dev_lock); 240 257 -
uspace/srv/bd/gxe_bd/Makefile
rcf8cc36 rc47e1a8 29 29 30 30 USPACE_PREFIX = ../../.. 31 LIBS = $(LIBC_PREFIX)/libc.a 32 33 OUTPUT = gxe_bd 31 BINARY = gxe_bd 34 32 35 33 SOURCES = \ 36 34 gxe_bd.c 37 35 38 include ../../Makefile.common36 include $(USPACE_PREFIX)/Makefile.common -
uspace/srv/bd/part/guid_part/Makefile
rcf8cc36 rc47e1a8 28 28 29 29 USPACE_PREFIX = ../../../.. 30 LIBS = $(LIBBLOCK_PREFIX)/libblock.a $(LIBC_PREFIX)/libc.a30 LIBS = $(LIBBLOCK_PREFIX)/libblock.a 31 31 EXTRA_CFLAGS = -I$(LIBBLOCK_PREFIX) 32 32 33 33 # Correct name is 'guid_part' but must use this because of FAT 8.3 names. 34 OUTPUT= g_part34 BINARY = g_part 35 35 36 36 SOURCES = \ 37 37 guid_part.c 38 38 39 include ../../../Makefile.common39 include $(USPACE_PREFIX)/Makefile.common -
uspace/srv/bd/part/guid_part/guid_part.c
rcf8cc36 rc47e1a8 79 79 bool present; 80 80 /** Address of first block */ 81 bn_t start_addr;81 aoff64_t start_addr; 82 82 /** Number of blocks */ 83 bn_t length;83 aoff64_t length; 84 84 /** Device representing the partition (outbound device) */ 85 85 dev_handle_t dev; … … 101 101 static void gpt_pte_to_part(const gpt_entry_t *pte, part_t *part); 102 102 static 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);103 static int gpt_bd_read(part_t *p, aoff64_t ba, size_t cnt, void *buf); 104 static int gpt_bd_write(part_t *p, aoff64_t ba, size_t cnt, const void *buf); 105 static int gpt_bsa_translate(part_t *p, aoff64_t ba, size_t cnt, aoff64_t *gba); 106 106 107 107 int main(int argc, char **argv) … … 199 199 / (1024 * 1024); 200 200 printf(NAME ": Registered device %s: %" PRIu64 " blocks " 201 "%" PRIu BN" MB.\n", name, part->length, size_mb);201 "%" PRIuOFF64 " MB.\n", name, part->length, size_mb); 202 202 203 203 part->dev = dev; … … 319 319 int flags; 320 320 int retval; 321 bn_t ba;321 aoff64_t ba; 322 322 size_t cnt; 323 323 part_t *part; … … 402 402 403 403 /** 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;404 static int gpt_bd_read(part_t *p, aoff64_t ba, size_t cnt, void *buf) 405 { 406 aoff64_t gba; 407 407 408 408 if (gpt_bsa_translate(p, ba, cnt, &gba) != EOK) … … 413 413 414 414 /** 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;415 static int gpt_bd_write(part_t *p, aoff64_t ba, size_t cnt, const void *buf) 416 { 417 aoff64_t gba; 418 418 419 419 if (gpt_bsa_translate(p, ba, cnt, &gba) != EOK) … … 424 424 425 425 /** 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)426 static int gpt_bsa_translate(part_t *p, aoff64_t ba, size_t cnt, aoff64_t *gba) 427 427 { 428 428 if (ba + cnt > p->length) -
uspace/srv/bd/part/mbr_part/Makefile
rcf8cc36 rc47e1a8 29 29 30 30 USPACE_PREFIX = ../../../.. 31 LIBS = $(LIBBLOCK_PREFIX)/libblock.a $(LIBC_PREFIX)/libc.a31 LIBS = $(LIBBLOCK_PREFIX)/libblock.a 32 32 EXTRA_CFLAGS = -I$(LIBBLOCK_PREFIX) 33 34 OUTPUT = mbr_part 33 BINARY = mbr_part 35 34 36 35 SOURCES = \ 37 36 mbr_part.c 38 37 39 include ../../../Makefile.common38 include $(USPACE_PREFIX)/Makefile.common -
uspace/srv/bd/part/mbr_part/mbr_part.c
rcf8cc36 rc47e1a8 97 97 bool present; 98 98 /** Address of first block */ 99 bn_t start_addr;99 aoff64_t start_addr; 100 100 /** Number of blocks */ 101 bn_t length;101 aoff64_t length; 102 102 /** Device representing the partition (outbound device) */ 103 103 dev_handle_t dev; … … 249 249 size_mb = (part->length * block_size + 1024 * 1024 - 1) 250 250 / (1024 * 1024); 251 printf(NAME ": Registered device %s: %" PRIu BN" blocks "251 printf(NAME ": Registered device %s: %" PRIuOFF64 " blocks " 252 252 "%" PRIu64 " MB.\n", name, part->length, size_mb); 253 253 -
uspace/srv/bd/rd/Makefile
rcf8cc36 rc47e1a8 29 29 30 30 USPACE_PREFIX = ../../.. 31 LIBS = $(LIBC_PREFIX)/libc.a 32 33 OUTPUT = rd 31 BINARY = rd 34 32 35 33 SOURCES = \ 36 34 rd.c 37 35 38 include ../../Makefile.common36 include $(USPACE_PREFIX)/Makefile.common -
uspace/srv/bd/rd/rd.c
rcf8cc36 rc47e1a8 32 32 /** @addtogroup rd 33 33 * @{ 34 */ 34 */ 35 35 36 36 /** 37 * @file rd.c38 * @brief Initial RAM disk for HelenOS.37 * @file rd.c 38 * @brief Initial RAM disk for HelenOS. 39 39 */ 40 40 … … 61 61 /** Pointer to the ramdisk's image */ 62 62 static void *rd_addr; 63 63 64 /** Size of the ramdisk */ 64 65 static size_t rd_size; … … 70 71 static int rd_write_blocks(uint64_t ba, size_t cnt, const void *buf); 71 72 72 /** 73 * This rwlock protects the ramdisk's data.73 /** This rwlock protects the ramdisk's data. 74 * 74 75 * 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 */ 78 80 fibril_rwlock_t rd_lock; 79 81 80 82 /** Handle one connection to ramdisk. 81 83 * 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. 84 86 */ 85 87 static void rd_connection(ipc_callid_t iid, ipc_call_t *icall) … … 92 94 size_t cnt; 93 95 size_t comm_size; 94 96 95 97 /* 96 98 * Answer the first IPC_M_CONNECT_ME_TO call. 97 99 */ 98 100 ipc_answer_0(iid, EOK); 99 101 100 102 /* 101 103 * Now we wait for the client to send us its communication as_area. … … 108 110 } else { 109 111 ipc_answer_0(callid, EHANGUP); 110 return; 112 return; 111 113 } 112 114 } else { … … 178 180 return ELIMIT; 179 181 } 180 182 181 183 fibril_rwlock_read_lock(&rd_lock); 182 184 memcpy(buf, rd_addr + ba * block_size, block_size * cnt); 183 185 fibril_rwlock_read_unlock(&rd_lock); 184 186 185 187 return EOK; 186 188 } … … 193 195 return ELIMIT; 194 196 } 195 197 196 198 fibril_rwlock_write_lock(&rd_lock); 197 199 memcpy(rd_addr + ba * block_size, buf, block_size * cnt); 198 200 fibril_rwlock_write_unlock(&rd_lock); 199 201 200 202 return EOK; 201 203 } … … 204 206 static bool rd_init(void) 205 207 { 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); 211 218 return false; 212 219 } … … 215 222 216 223 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, 218 225 ALIGN_UP(rd_size, PAGE_SIZE) >> PAGE_WIDTH, flags); 219 226 220 227 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); 226 233 227 234 int rc = devmap_driver_register(NAME, rd_connection); 228 235 if (rc < 0) { 229 printf( NAME ": Unable to register driver (%d)\n", rc);236 printf("%s: Unable to register driver (%d)\n", NAME, rc); 230 237 return false; 231 238 } … … 234 241 if (devmap_device_register("bd/initrd", &dev_handle) != EOK) { 235 242 devmap_hangup_phone(DEVMAP_DRIVER); 236 printf( NAME ": Unable to register device\n");243 printf("%s: Unable to register device\n", NAME); 237 244 return false; 238 245 } … … 245 252 int main(int argc, char **argv) 246 253 { 247 printf( NAME ": HelenOS RAM disk server\n");254 printf("%s: HelenOS RAM disk server\n", NAME); 248 255 249 256 if (!rd_init()) 250 257 return -1; 251 258 252 printf( NAME ": Accepting connections\n");259 printf("%s: Accepting connections\n", NAME); 253 260 async_manager(); 254 261
Note:
See TracChangeset
for help on using the changeset viewer.
