Changeset 1055 for Whitix

Show
Ignore:
Timestamp:
10/03/08 12:11:36 (2 months ago)
Author:
mwhitworth
Message:

Add to device layer, add class functions, add start of bus type, add to sdevice impl.

Location:
Whitix/branches/keobject/devices/kedev
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • Whitix/branches/keobject/devices/kedev/Makefile

    r978 r1055  
    11DEPTH=../../ 
    22 
    3 OBJS = device.o sdevice.o init.o 
     3OBJS = device.o sdevice.o init.o class.o bus.o 
    44 
    55build: $(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 
     7struct KeSet classRoot; 
     8 
     9int 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 
     21SYMBOL_EXPORT(DevClassCreate); 
     22 
     23int 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  
    1717 */ 
    1818 
    19 #include <device.h> 
     19#include <devices/device.h> 
     20#include <fs/devfs.h> 
    2021#include <keobject.h> 
     22#include <module.h> 
    2123 
    2224/* Set up the structure. */ 
    23 int KeDeviceInit(struct KeDevice* device, struct KeSet* type, DevId devId, void* devPriv) 
     25int KeDeviceInit(struct KeDevice* device, struct KeSet* type, DevId devId, 
     26        void* devPriv, int devType) 
    2427{ 
    2528        KeObjectInit(&device->object, type); 
     
    2730        device->devId = devId; 
    2831        device->devPriv = devPriv; 
     32        device->type = devType; 
    2933         
    3034        return 0; 
    3135} 
    3236 
     37SYMBOL_EXPORT(KeDeviceInit); 
     38 
     39int 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 
     52SYMBOL_EXPORT(KeDeviceVaAttach); 
     53 
    3354int KeDeviceAttach(struct KeDevice* device, const char* name, ...) 
    3455{ 
    3556        int err; 
     57        VaList args; 
    3658         
    3759        /* Bind the KeObject to the filesystem first. This creates a directory 
     
    3961         */ 
    4062          
    41         err = KeObjectAttach(&device->object, name); 
     63        VaStart(args, name); 
    4264         
    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; 
    4870} 
     71 
     72SYMBOL_EXPORT(KeDeviceAttach); 
  • Whitix/branches/keobject/devices/kedev/init.c

    r978 r1055  
    1717 */ 
    1818 
    19 #include <device.h> 
    20 #include <keobject.h> 
     19int BusInit(); 
     20int ClassInit(); 
     21int StorageInit(); 
    2122 
    2223int DeviceInit() 
    2324{ 
     25        ClassInit(); 
     26        BusInit(); 
     27         
    2428        return StorageInit(); 
    2529} 
  • Whitix/branches/keobject/devices/kedev/sdevice.c

    r1033 r1055  
    1717 */ 
    1818 
    19 #include <sdevice.h> 
     19#include <devices/class.h> 
     20#include <devices/sdevice.h> 
    2021#include <module.h> 
    2122#include <llist.h> 
     
    2930#include <print.h> 
    3031#include <fs/config.h> 
     32#include <fs/devfs.h> 
    3133 
    3234LIST_HEAD(sDeviceList); 
     
    3537 
    3638struct KeSubsystem storage; 
    37 struct KeSet storageSet; 
     39struct DevClass storageClass; 
    3840 
    3941int StorageDeviceInit(struct StorageDevice* dev, DevId devId) 
     
    4143        dev->softBlockSize=dev->blockSize;       
    4244         
    43         return KeDeviceInit(&dev->device, &storageSet, devId, dev); 
     45        return KeDeviceInit(&dev->device, &storageClass.set, devId, dev, DEVICE_BLOCK); 
    4446} 
    4547 
     
    6264int StorageDeviceAdd(struct StorageDevice* dev, const char* name, ...) 
    6365{ 
    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    
    8370                ConfigDir* dir=ConfigCreateDir(NULL, buf); 
    8471                 
     
    9077#endif 
    9178 
     79        /* General storage device setup. */ 
    9280        BlockCreateHashTable(dev); 
    93          
    9481        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; 
    9788} 
    9889 
     
    10192int StorageSetCreate(struct KeSet* set, struct KeObjType* type, const char* name) 
    10293{ 
    103         return KeSetCreate(set, &storageSet, type, name); 
     94        return KeSetCreate(set, &storageClass.set, type, name); 
    10495} 
    10596 
     
    154145/* 
    155146 * 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. 
    157148 */ 
    158149 
     
    247238        root = StorageParseCommandLine(commandLine); 
    248239         
    249         object = KeSetFind(&storageSet, root); 
     240        object = KeSetFind(&storageClass.set, root); 
    250241         
    251242        if (!object) 
     
    259250int StorageInit() 
    260251{ 
    261         return KeSetCreate(&storageSet, NULL, NULL, "Storage"); 
    262 } 
     252        return DevClassCreate(&storageClass, NULL, "Storage"); 
     253}