diff options
| -rw-r--r-- | README.md | 17 | ||||
| -rw-r--r-- | linux/chudisk.c | 17 | ||||
| -rw-r--r-- | linux/makefile | 5 | ||||
| -rwxr-xr-x | linux/mkdev.sh | 2 |
4 files changed, 24 insertions, 17 deletions
@@ -114,7 +114,7 @@ decide which drive letters you prefer for the partitions on your pendrive. For that, go to Device Manager, Disk Drives, and select the CH375 USB Disk as follows: - + Partitions will be assigned to disk letters in order. @@ -180,17 +180,22 @@ You can then use/mount the `/dev/chuda1`, `/dev/chuda2` devices as usual. ## Usage +Load in the usual way, or put into `/etc/modules`. E.g., + +```` +modprobe chudisk io=0x260 +```` + The driver exposes the following parameters: * `io` the io address for your CH375, defaults to 0x260. -* `major` allows overriding the device's major number, in the rare case you -have a conflict. If you do this, also update `mkdev.sh`. +* `major` allows overriding the device's major number, in case you +have a conflict with the default (63). If you do this, also update `mkdev.sh`. * `force` will load the driver even if we can't find a CH375 at the specified address. * `softblk` allows setting the "block size" used for transfers. -Linux defaults to 1024. Higher values provide higher speed at the cost -of latency. Must be power of two. - +Linux defaults to 1024. Higher values provide higher throughput at the cost +of latency. Must be power of two, max is 4K. # Future work diff --git a/linux/chudisk.c b/linux/chudisk.c index 31dd9e5..c2eb2f7 100644 --- a/linux/chudisk.c +++ b/linux/chudisk.c @@ -28,8 +28,8 @@ /* module parameters */ /** configurable major number */ -/* by default, reuse the one from Mylex DAC960 PCI RAID controller; sixth controller" */ -static short major = 53; +/* by default, reuse one in the experimental space */ +static short major = 63; /** IO base */ static short io = 0x260; /** skip device proving */ @@ -39,7 +39,7 @@ static int softblk = 1024; /* for blk.h: (needs to be defined before blk.h/lnxabs.h is included) */ #define MAJOR_NR major -#define DEVICE_NAME "CH375" +#define DEVICE_NAME "chud" #define DEVICE_REQUEST do_chudisk_request #define DEVICE_NR(device) (MINOR(device)>>CHUDISK_MINOR_SHIFT) #define DEVICE_ON(device) @@ -50,7 +50,6 @@ static int softblk = 1024; #include "ch375lnx.h" #include <scsi.h> -#define ENABLE_DLOG 0 #if ENABLE_DLOG #define dprintf(args...) printk(KERN_DEBUG args) #else @@ -87,7 +86,7 @@ static struct ch375 chudisk_dev[CHUDISK_MAX_UNITS]; /** main gendisk layer data structure, which handles partioning */ static struct gendisk chudisk_gendisk = { - .major_name = "chud", + .major_name = DEVICE_NAME, .minor_shift = CHUDISK_MINOR_SHIFT, .max_p = CHUDISK_MAX_PARTITIONS, .max_nr = CHUDISK_MAX_UNITS, @@ -148,7 +147,7 @@ static unsigned disk_read_sectors(struct ch375 *dev, uint8_t *buffer, uint32_t l uint8_t result; unsigned total = 0; // Total bytes written - dprintf("disk read buf=%p sector=%lu num=%hu\n", buffer, lba, num); + dprintf("disk read buf=%p sector=%u num=%hu\n", buffer, lba, num); // Initiate read operation ch375_disk_read(dev, lba, num); @@ -197,7 +196,7 @@ static unsigned disk_write_sectors(struct ch375 *dev, uint8_t *buffer, uint32_t uint8_t result; unsigned total = 0; // Total bytes written - dprintf("disk write buf=%p sector=%lu num=%hu\n", buffer, lba, num); + dprintf("disk write buf=%p sector=%u num=%hu\n", buffer, lba, num); // Initiate operation ch375_disk_write(dev, lba, num); @@ -387,7 +386,7 @@ static int chudisk_revalidate(kdev_t devno) blk_size = ntohl(*(uint32_t*)&buffer[4]); sector_cnt = ntohl(*(uint32_t*)&buffer[0]); - dprintf("chudisk: sector size %u num sectors %u\n", blk_size, sector_cnt); + dprintf("chudisk[%d]: sector size %u num sectors %u\n", unit, blk_size, sector_cnt); // TODO Support non-default block_size dev->sec_size = blk_size; @@ -585,7 +584,7 @@ static __init int chudisk_init(void) blksize_size[MAJOR_NR] = chudisk_blksizes; hardsect_size[MAJOR_NR] = chudisk_hardsectsizes; - chudisk_gendisk.major = major; + chudisk_gendisk.major = MAJOR_NR; chudisk_gendisk.nr_real = 1; chudisk_gendisk.next = gendisk_head; gendisk_head = &chudisk_gendisk; diff --git a/linux/makefile b/linux/makefile index f293cc1..e88ebac 100644 --- a/linux/makefile +++ b/linux/makefile @@ -2,6 +2,9 @@ MODDIR := /lib/modules/$(shell uname -r) INCLUDE := -isystem $(MODDIR)/build/include -isystem ../inc CFLAGS := -O2 -D__KERNEL__ -DMODULE -Wall $(INCLUDE) +ifeq ($(debug),1) +CFLAGS += -DENABLE_DLOG +endif ifneq (,$(wildcard $(MODDIR)/build/include/linux/modversions.h)) CFLAGS += -DMODVERSIONS endif @@ -16,7 +19,7 @@ clean: install: chudisk.o install -m0644 chudisk.o $(MODDIR)/block - depmod -A + depmod uninstall: rm -f $(MODDIR)/block/chudisk.o diff --git a/linux/mkdev.sh b/linux/mkdev.sh index d1393e6..1a05b91 100755 --- a/linux/mkdev.sh +++ b/linux/mkdev.sh @@ -1,6 +1,6 @@ #!/bin/sh -major=53 +major=63 if [ $# -gt 0 ]; then major=$1 fi |
