Changeset 827d73f in mainline for uspace/srv/bd
- Timestamp:
- 2010-02-12T14:09:22Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a70bda4
- Parents:
- 918e9910 (diff), e70edd1 (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:
-
- 4 added
- 5 deleted
- 8 edited
- 3 moved
-
ata_bd/Makefile (modified) (1 diff)
-
ata_bd/Makefile.build (deleted)
-
ata_bd/ata_bd.c (modified) (6 diffs)
-
file_bd/Makefile (modified) (1 diff)
-
file_bd/Makefile.build (deleted)
-
file_bd/file_bd.c (modified) (7 diffs)
-
gxe_bd/Makefile (modified) (1 diff)
-
gxe_bd/Makefile.build (deleted)
-
gxe_bd/gxe_bd.c (modified) (1 diff)
-
part/guid_part/Makefile (added)
-
part/guid_part/gpt.h (added)
-
part/guid_part/guid_part.c (added)
-
part/mbr_part/Makefile (added)
-
part/mbr_part/Makefile.build (moved) (moved from uspace/srv/part/mbr_part/Makefile.build )
-
part/mbr_part/Makefile.common (moved) (moved from uspace/srv/part/mbr_part/Makefile.common )
-
part/mbr_part/mbr_part.c (moved) (moved from uspace/srv/part/mbr_part/mbr_part.c ) (8 diffs)
-
rd/Makefile (modified) (1 diff)
-
rd/Makefile.build (deleted)
-
rd/Makefile.common (deleted)
-
rd/rd.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/bd/ata_bd/Makefile
r918e9910 r827d73f 28 28 # 29 29 30 include Makefile.common 30 USPACE_PREFIX = ../../.. 31 LIBS = $(LIBC_PREFIX)/libc.a 31 32 32 .PHONY: all clean 33 OUTPUT = ata_bd 33 34 34 all: $(LIBC_PREFIX)/../../../Makefile.config $(LIBC_PREFIX)/../../../config.h $(LIBC_PREFIX)/../../../config.defs $(LIBS) 35 -[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV) 36 $(MAKE) -f Makefile.build 35 SOURCES = \ 36 ata_bd.c 37 37 38 clean: 39 rm -f $(DEPEND) $(DEPEND_PREV) $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm 40 find . -name '*.o' -follow -exec rm \{\} \; 38 include ../../Makefile.common -
uspace/srv/bd/ata_bd/ata_bd.c
r918e9910 r827d73f 59 59 #include <devmap.h> 60 60 #include <sys/types.h> 61 #include <inttypes.h> 61 62 #include <errno.h> 62 63 #include <bool.h> … … 112 113 printf(NAME ": ATA disk driver\n"); 113 114 114 printf("I/O address 0x%p/0x%p\n", ctl_physical, cmd_physical);115 printf("I/O address %p/%p\n", ctl_physical, cmd_physical); 115 116 116 117 if (ata_bd_init() != EOK) … … 180 181 } 181 182 182 printf(" % llublocks", d->blocks, d->blocks / (2 * 1024));183 printf(" %" PRIu64 " blocks", d->blocks, d->blocks / (2 * 1024)); 183 184 184 185 mbytes = d->blocks / (2 * 1024); 185 186 if (mbytes > 0) 186 printf(" % lluMB.", mbytes);187 printf(" %" PRIu64 " MB.", mbytes); 187 188 188 189 printf("\n"); … … 296 297 ipc_answer_1(callid, EOK, block_size); 297 298 continue; 299 case BD_GET_NUM_BLOCKS: 300 ipc_answer_2(callid, EOK, LOWER32(disk[disk_id].blocks), 301 UPPER32(disk[disk_id].blocks)); 302 continue; 298 303 default: 299 304 retval = EINVAL; … … 495 500 496 501 d = &disk[disk_id]; 497 bc.h = 0; /* Silence warning. */ 502 503 /* Silence warning. */ 504 memset(&bc, 0, sizeof(bc)); 498 505 499 506 /* Compute block coordinates. */ … … 569 576 570 577 d = &disk[disk_id]; 571 bc.h = 0; /* Silence warning. */ 578 579 /* Silence warning. */ 580 memset(&bc, 0, sizeof(bc)); 572 581 573 582 /* Compute block coordinates. */ -
uspace/srv/bd/file_bd/Makefile
r918e9910 r827d73f 28 28 # 29 29 30 include Makefile.common 30 USPACE_PREFIX = ../../.. 31 LIBS = $(LIBC_PREFIX)/libc.a 31 32 32 .PHONY: all clean 33 OUTPUT = file_bd 33 34 34 all: $(LIBC_PREFIX)/../../../Makefile.config $(LIBC_PREFIX)/../../../config.h $(LIBC_PREFIX)/../../../config.defs $(LIBS) 35 -[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV) 36 $(MAKE) -f Makefile.build 35 SOURCES = \ 36 file_bd.c 37 37 38 clean: 39 rm -f $(DEPEND) $(DEPEND_PREV) $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm 40 find . -name '*.o' -follow -exec rm \{\} \; 38 include ../../Makefile.common -
uspace/srv/bd/file_bd/file_bd.c
r918e9910 r827d73f 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; 59 static aoff64_t num_blocks; 58 60 static FILE *img; 59 61 … … 99 101 { 100 102 int rc; 103 long img_size; 101 104 102 105 rc = devmap_driver_register(NAME, file_bd_connection); … … 109 112 if (img == NULL) 110 113 return EINVAL; 114 115 if (fseek(img, 0, SEEK_END) != 0) { 116 fclose(img); 117 return EIO; 118 } 119 120 img_size = ftell(img); 121 if (img_size < 0) { 122 fclose(img); 123 return EIO; 124 } 125 126 num_blocks = img_size / block_size; 111 127 112 128 fibril_mutex_initialize(&dev_lock); … … 174 190 ipc_answer_1(callid, EOK, block_size); 175 191 continue; 192 case BD_GET_NUM_BLOCKS: 193 ipc_answer_2(callid, EOK, LOWER32(num_blocks), 194 UPPER32(num_blocks)); 195 continue; 176 196 default: 177 197 retval = EINVAL; … … 186 206 { 187 207 size_t n_rd; 208 int rc; 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 } 188 217 189 218 fibril_mutex_lock(&dev_lock); 190 219 191 fseek(img, ba * block_size, SEEK_SET); 220 clearerr(img); 221 rc = fseek(img, ba * block_size, SEEK_SET); 222 if (rc < 0) { 223 fibril_mutex_unlock(&dev_lock); 224 return EIO; 225 } 226 192 227 n_rd = fread(buf, block_size, cnt, img); 193 228 … … 209 244 { 210 245 size_t n_wr; 246 int rc; 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 } 211 255 212 256 fibril_mutex_lock(&dev_lock); 213 257 214 fseek(img, ba * block_size, SEEK_SET); 215 n_wr = fread(buf, block_size, cnt, img); 258 clearerr(img); 259 rc = fseek(img, ba * block_size, SEEK_SET); 260 if (rc < 0) { 261 fibril_mutex_unlock(&dev_lock); 262 return EIO; 263 } 264 265 n_wr = fwrite(buf, block_size, cnt, img); 216 266 217 267 if (ferror(img) || n_wr < cnt) { 218 268 fibril_mutex_unlock(&dev_lock); 219 269 return EIO; /* Write error */ 270 } 271 272 if (fflush(img) != 0) { 273 fibril_mutex_unlock(&dev_lock); 274 return EIO; 220 275 } 221 276 -
uspace/srv/bd/gxe_bd/Makefile
r918e9910 r827d73f 28 28 # 29 29 30 include Makefile.common 30 USPACE_PREFIX = ../../.. 31 LIBS = $(LIBC_PREFIX)/libc.a 31 32 32 .PHONY: all clean 33 OUTPUT = gxe_bd 33 34 34 all: $(LIBC_PREFIX)/../../../Makefile.config $(LIBC_PREFIX)/../../../config.h $(LIBC_PREFIX)/../../../config.defs $(LIBS) 35 -[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV) 36 $(MAKE) -f Makefile.build 35 SOURCES = \ 36 gxe_bd.c 37 37 38 clean: 39 rm -f $(DEPEND) $(DEPEND_PREV) $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm 40 find . -name '*.o' -follow -exec rm \{\} \; 38 include ../../Makefile.common -
uspace/srv/bd/gxe_bd/gxe_bd.c
r918e9910 r827d73f 234 234 ipc_answer_1(callid, EOK, block_size); 235 235 continue; 236 case BD_GET_NUM_BLOCKS: 237 retval = ENOTSUP; 238 break; 236 239 default: 237 240 retval = EINVAL; -
uspace/srv/bd/part/mbr_part/mbr_part.c
r918e9910 r827d73f 64 64 #include <devmap.h> 65 65 #include <sys/types.h> 66 #include <sys/typefmt.h> 67 #include <inttypes.h> 66 68 #include <libblock.h> 67 69 #include <devmap.h> … … 95 97 bool present; 96 98 /** Address of first block */ 97 bn_t start_addr;99 aoff64_t start_addr; 98 100 /** Number of blocks */ 99 bn_t length;101 aoff64_t length; 100 102 /** Device representing the partition (outbound device) */ 101 103 dev_handle_t dev; … … 247 249 size_mb = (part->length * block_size + 1024 * 1024 - 1) 248 250 / (1024 * 1024); 249 printf(NAME ": Registered device %s: % llu blocks %llu MB.\n",250 name, part->length, size_mb);251 printf(NAME ": Registered device %s: %" PRIuOFF64 " blocks " 252 "%" PRIu64 " MB.\n", name, part->length, size_mb); 251 253 252 254 part->dev = dev; … … 274 276 if (brb == NULL) { 275 277 printf(NAME ": Failed allocating memory.\n"); 276 return ENOMEM; 278 return ENOMEM; 277 279 } 278 280 … … 289 291 sgn = uint16_t_le2host(brb->signature); 290 292 if (sgn != BR_SIGNATURE) { 291 printf(NAME ": Invalid boot record signature 0x%04X.\n", sgn); 293 printf(NAME ": Invalid boot record signature 0x%04" PRIX16 294 ".\n", sgn); 292 295 return EINVAL; 293 296 } … … 333 336 rc = block_read_direct(indev_handle, ba, 1, brb); 334 337 if (rc != EOK) { 335 printf(NAME ": Failed reading EBR block at %u.\n", ba); 338 printf(NAME ": Failed reading EBR block at %" 339 PRIu32 ".\n", ba); 336 340 return rc; 337 341 } … … 339 343 sgn = uint16_t_le2host(brb->signature); 340 344 if (sgn != BR_SIGNATURE) { 341 printf(NAME ": Invalid boot record signature 0x%04 X"342 " in EBR at %u.\n", sgn, ba);345 printf(NAME ": Invalid boot record signature 0x%04" 346 PRIX16 " in EBR at %" PRIu32 ".\n", sgn, ba); 343 347 return EINVAL; 344 348 } … … 463 467 ipc_answer_1(callid, EOK, block_size); 464 468 continue; 465 469 case BD_GET_NUM_BLOCKS: 470 ipc_answer_2(callid, EOK, LOWER32(part->length), 471 UPPER32(part->length)); 472 continue; 466 473 default: 467 474 retval = EINVAL; -
uspace/srv/bd/rd/Makefile
r918e9910 r827d73f 28 28 # 29 29 30 include Makefile.common 30 USPACE_PREFIX = ../../.. 31 LIBS = $(LIBC_PREFIX)/libc.a 31 32 32 .PHONY: all clean 33 OUTPUT = rd 33 34 34 all: $(LIBC_PREFIX)/../../../Makefile.config $(LIBC_PREFIX)/../../../config.h $(LIBC_PREFIX)/../../../config.defs $(LIBS) 35 -[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV) 36 $(MAKE) -f Makefile.build 35 SOURCES = \ 36 rd.c 37 37 38 clean: 39 rm -f $(DEPEND) $(DEPEND_PREV) $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm 40 find . -name '*.o' -follow -exec rm \{\} \; 38 include ../../Makefile.common -
uspace/srv/bd/rd/rd.c
r918e9910 r827d73f 153 153 ipc_answer_1(callid, EOK, block_size); 154 154 continue; 155 case BD_GET_NUM_BLOCKS: 156 ipc_answer_2(callid, EOK, LOWER32(rd_size / block_size), 157 UPPER32(rd_size / block_size)); 158 continue; 155 159 default: 156 160 /*
Note:
See TracChangeset
for help on using the changeset viewer.
