- Timestamp:
- 10/03/08 12:11:36 (2 months ago)
- Location:
- Whitix/branches/keobject/devices/kedev
- Files:
-
- 5 modified
Legend:
- Unmodified
- Added
- Removed
-
Whitix/branches/keobject/devices/kedev/Makefile
r978 r1055 1 1 DEPTH=../../ 2 2 3 OBJS = device.o sdevice.o init.o 3 OBJS = device.o sdevice.o init.o class.o bus.o 4 4 5 5 build: $(OBJS) -
Whitix/branches/keobject/devices/kedev/class.c
r978 r1055 1 #include <devices/device.h> 2 #include <devices/class.h> 3 #include <fs/devfs.h> 4 #include <module.h> 5 #include <keobject.h> 6 7 struct KeSet classRoot; 8 9 int DevClassCreate(struct DevClass* devClass, struct KeObjType* type, const char* name, ...) 10 { 11 int err; 12 13 err = KeSetCreate(&devClass->set, &classRoot, type, name); 14 15 if (err) 16 return err; 17 18 return DevFsAddDir(&devClass->set, name); 19 } 20 21 SYMBOL_EXPORT(DevClassCreate); 22 23 int ClassInit() 24 { 25 /* TODO: Create cache. */ 26 27 KeSetCreate(&classRoot, NULL, NULL, "Devices"); 28 29 return 0; 30 } -
Whitix/branches/keobject/devices/kedev/device.c
r978 r1055 17 17 */ 18 18 19 #include <device.h> 19 #include <devices/device.h> 20 #include <fs/devfs.h> 20 21 #include <keobject.h> 22 #include <module.h> 21 23 22 24 /* Set up the structure. */ 23 int KeDeviceInit(struct KeDevice* device, struct KeSet* type, DevId devId, void* devPriv) 25 int KeDeviceInit(struct KeDevice* device, struct KeSet* type, DevId devId, 26 void* devPriv, int devType) 24 27 { 25 28 KeObjectInit(&device->object, type); … … 27 30 device->devId = devId; 28 31 device->devPriv = devPriv; 32 device->type = devType; 29 33 30 34 return 0; 31 35 } 32 36 37 SYMBOL_EXPORT(KeDeviceInit); 38 39 int KeDeviceVaAttach(struct KeDevice* device, const char* name, VaList args) 40 { 41 int err; 42 43 err = KeObjectVaAttach(&device->object, name, args); 44 45 if (err) 46 return err; 47 48 /* Now add the device in the device filesystem. */ 49 return DevFsAddDevice(device, KeObjGetName(&device->object)); 50 } 51 52 SYMBOL_EXPORT(KeDeviceVaAttach); 53 33 54 int KeDeviceAttach(struct KeDevice* device, const char* name, ...) 34 55 { 35 56 int err; 57 VaList args; 36 58 37 59 /* Bind the KeObject to the filesystem first. This creates a directory … … 39 61 */ 40 62 41 err = KeObjectAttach(&device->object, name);63 VaStart(args, name); 42 64 43 if (err)44 return err;45 46 /* Now add the device in the device filesystem. */47 return DevFsAddDevice(device, name);65 err = KeDeviceVaAttach(device, name, args); 66 67 VaEnd(args); 68 69 return err; 48 70 } 71 72 SYMBOL_EXPORT(KeDeviceAttach); -
Whitix/branches/keobject/devices/kedev/init.c
r978 r1055 17 17 */ 18 18 19 #include <device.h> 20 #include <keobject.h> 19 int BusInit(); 20 int ClassInit(); 21 int StorageInit(); 21 22 22 23 int DeviceInit() 23 24 { 25 ClassInit(); 26 BusInit(); 27 24 28 return StorageInit(); 25 29 } -
Whitix/branches/keobject/devices/kedev/sdevice.c
r1033 r1055 17 17 */ 18 18 19 #include <sdevice.h> 19 #include <devices/class.h> 20 #include <devices/sdevice.h> 20 21 #include <module.h> 21 22 #include <llist.h> … … 29 30 #include <print.h> 30 31 #include <fs/config.h> 32 #include <fs/devfs.h> 31 33 32 34 LIST_HEAD(sDeviceList); … … 35 37 36 38 struct KeSubsystem storage; 37 struct KeSet storageSet;39 struct DevClass storageClass; 38 40 39 41 int StorageDeviceInit(struct StorageDevice* dev, DevId devId) … … 41 43 dev->softBlockSize=dev->blockSize; 42 44 43 return KeDeviceInit(&dev->device, &storage Set, devId, dev);45 return KeDeviceInit(&dev->device, &storageClass.set, devId, dev, DEVICE_BLOCK); 44 46 } 45 47 … … 62 64 int StorageDeviceAdd(struct StorageDevice* dev, const char* name, ...) 63 65 { 64 struct KeObject* object; 65 66 object=KeSetFind(&storageSet, name); 67 68 if (object) 69 return -EEXIST; 70 71 #if 0 72 if (dev->name) 73 { 74 char buf[255]; 75 76 name=(char*)MemAlloc(strlen(dev->name)+1); 77 strcpy(name,dev->name); 78 dev->name=name; 79 80 /* Add to the storage directory, along with a list of basic attributes. */ 81 sprintf(buf, "Devices/%s", dev->name); 82 66 int err; 67 VaList args; 68 69 #if 0 83 70 ConfigDir* dir=ConfigCreateDir(NULL, buf); 84 71 … … 90 77 #endif 91 78 79 /* General storage device setup. */ 92 80 BlockCreateHashTable(dev); 93 94 81 StorageQueueInit(dev); 95 96 return KeDeviceAttach(&dev->device, name); 82 83 VaStart(args, name); 84 err = KeDeviceVaAttach(&dev->device, name, args); 85 VaEnd(args); 86 87 return err; 97 88 } 98 89 … … 101 92 int StorageSetCreate(struct KeSet* set, struct KeObjType* type, const char* name) 102 93 { 103 return KeSetCreate(set, &storage Set, type, name);94 return KeSetCreate(set, &storageClass.set, type, name); 104 95 } 105 96 … … 154 145 /* 155 146 * Always hold a spinlock when dealing with the list, because an irq can alter the list 156 * at the end of it 's request, causing havoc with ListEmpty etc.147 * at the end of its request, causing havoc with ListEmpty etc. 157 148 */ 158 149 … … 247 238 root = StorageParseCommandLine(commandLine); 248 239 249 object = KeSetFind(&storage Set, root);240 object = KeSetFind(&storageClass.set, root); 250 241 251 242 if (!object) … … 259 250 int StorageInit() 260 251 { 261 return KeSetCreate(&storageSet, NULL, NULL, "Storage");262 } 252 return DevClassCreate(&storageClass, NULL, "Storage"); 253 }
