Changeset 5f70118 in mainline for uspace/lib/libblock
- Timestamp:
- 2010-01-10T12:16:59Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c77a64f
- Parents:
- 309ede1 (diff), 1ac3a52 (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/lib/libblock
- Files:
-
- 2 added
- 3 edited
-
Makefile (modified) (1 diff)
-
Makefile.build (added)
-
Makefile.common (added)
-
libblock.c (modified) (6 diffs)
-
libblock.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/libblock/Makefile
r309ede1 r5f70118 28 28 # 29 29 30 ## Common compiler flags 31 # 30 include Makefile.common 32 31 33 LIBC_PREFIX = ../libc 32 .PHONY: all clean 34 33 35 ## Setup toolchain 36 # 37 38 include $(LIBC_PREFIX)/Makefile.toolchain 39 40 CFLAGS += -Iinclude 41 42 ## Sources 43 # 44 45 SOURCES = \ 46 libblock.c 47 48 OBJECTS := $(addsuffix .o,$(basename $(SOURCES))) 49 50 .PHONY: all clean depend 51 52 all: libblock.a 53 54 -include Makefile.depend 34 all: $(LIBC_PREFIX)/../../../Makefile.config $(LIBC_PREFIX)/../../../config.h $(LIBC_PREFIX)/../../../config.defs $(LIBC_PREFIX)/libc.a 35 -[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV) 36 $(MAKE) -f Makefile.build PRECHECK=$(PRECHECK) 55 37 56 38 clean: 57 -rm -f libblock.a Makefile.depend39 rm -f $(DEPEND) $(DEPEND_PREV) $(JOB) $(LIBBLOCK) 58 40 find . -name '*.o' -follow -exec rm \{\} \; 59 60 depend:61 -makedepend -f - -- $(DEPEND_DEFS) $(CFLAGS) -- $(SOURCES) > Makefile.depend 2> /dev/null62 63 libblock.a: depend $(OBJECTS)64 $(AR) rc libblock.a $(OBJECTS)65 66 %.o: %.c67 $(CC) $(DEFS) $(CFLAGS) -c $< -o $@ -
uspace/lib/libblock/libblock.c
r309ede1 r5f70118 47 47 #include <as.h> 48 48 #include <assert.h> 49 #include <fibril_sync .h>49 #include <fibril_synch.h> 50 50 #include <adt/list.h> 51 51 #include <adt/hash_table.h> … … 87 87 static int write_blocks(devcon_t *devcon, bn_t ba, size_t cnt); 88 88 static int get_block_size(int dev_phone, size_t *bsize); 89 static int get_num_blocks(int dev_phone, bn_t *nblocks); 89 90 90 91 static devcon_t *devcon_search(dev_handle_t dev_handle) … … 168 169 } 169 170 170 rc = ipc_share_out_start(dev_phone, comm_area,171 rc = async_share_out_start(dev_phone, comm_area, 171 172 AS_AREA_READ | AS_AREA_WRITE); 172 173 if (rc != EOK) { … … 714 715 715 716 memcpy(devcon->comm_area, data, devcon->pblock_size * cnt); 716 rc = read_blocks(devcon, ba, cnt);717 rc = write_blocks(devcon, ba, cnt); 717 718 718 719 fibril_mutex_unlock(&devcon->comm_area_lock); … … 736 737 737 738 return get_block_size(devcon->dev_phone, bsize); 739 } 740 741 /** Get number of blocks on device. 742 * 743 * @param dev_handle Device handle of the block device. 744 * @param nblocks Output number of blocks. 745 * 746 * @return EOK on success or negative error code on failure. 747 */ 748 int block_get_nblocks(dev_handle_t dev_handle, bn_t *nblocks) 749 { 750 devcon_t *devcon; 751 752 devcon = devcon_search(dev_handle); 753 assert(devcon); 754 755 return get_num_blocks(devcon->dev_phone, nblocks); 738 756 } 739 757 … … 789 807 } 790 808 809 /** Get total number of blocks on block device. */ 810 static int get_num_blocks(int dev_phone, bn_t *nblocks) 811 { 812 ipcarg_t nb_l, nb_h; 813 int rc; 814 815 rc = async_req_0_2(dev_phone, BD_GET_NUM_BLOCKS, &nb_l, &nb_h); 816 if (rc == EOK) { 817 *nblocks = (bn_t) MERGE_LOUP32(nb_l, nb_h); 818 } 819 820 return rc; 821 } 822 791 823 /** @} 792 824 */ -
uspace/lib/libblock/libblock.h
r309ede1 r5f70118 36 36 37 37 #ifndef LIBBLOCK_LIBBLOCK_H_ 38 #define LIBBLOCK_LIBBLOCK_H_38 #define LIBBLOCK_LIBBLOCK_H_ 39 39 40 40 #include <stdint.h> 41 41 #include "../../srv/vfs/vfs.h" 42 #include <fibril_sync .h>42 #include <fibril_synch.h> 43 43 #include <adt/hash_table.h> 44 44 #include <adt/list.h> … … 59 59 */ 60 60 #define BLOCK_FLAGS_NOREAD 1 61 62 typedef uint64_t bn_t; /**< Block number type. */63 61 64 62 typedef struct block { … … 110 108 111 109 extern int block_get_bsize(dev_handle_t, size_t *); 110 extern int block_get_nblocks(dev_handle_t, bn_t *); 112 111 extern int block_read_direct(dev_handle_t, bn_t, size_t, void *); 113 112 extern int block_write_direct(dev_handle_t, bn_t, size_t, const void *);
Note:
See TracChangeset
for help on using the changeset viewer.
