[EMAIL PROTECTED] wrote:
> But wouldn't it be "nicer" if, instead of returning null, it returns
> an error message describing what's wrong with the request, such as
> "out of bounds memory allocation", or "XYZ has already allocated that
> resource", and so on.
A DeviceAllocationException can be thrown, and it can be subclassed like
this:
ParameterIncorrectException extends DeviceAllocationException {
public String getParameterName();
public Object getParamterValue();
}
ParameterOutOfRangeException extends ParameterIncorrectException {
public String getParameterValueRange();
}
etc..
> Also, how would one deallocate the resource?
How about:
Device.close();
or
Device.deallocate();
?
Or, maybe:
URI uri =
new URI("device:modem:port://localhost/ports/serial/1/attached");
Modem modem = (Modem) DeviceManager.getDevice(uri);
modem.doSomething(parameter...);
DeviceManager.deallocate(modem);
> What if the particular JVM that allocated this resource crashed, would
> the resource then be unavailable to everyone, requiring a reboot?
Will the hardware crash or the software crash?
> Some other things to consider. How would a program discover which
> devices are available?
DeviceManager.listBuses();
DeviceManager.listPorts();
DeviceManager.listPhysicalDevices();
DeviceManager.listVirtualDevices();
DeviceManager.listDevices();
and most important of all:
DeviceManager.listDevices(String type);
> How would the admin then configure these devices so that they are
> setup correctly? I.e. how would you tell "device:sound://localhost/1"
> to use DMA channel 1 instead of channel 3?
"localhost/1" does not point to a device. Maybe something like this:
URI uri = new URI("device://localhost/bus/pci/4/attached");
String type = DeviceManager.resolveDeviceType(uri);
The resolve will be a probe with information regarding known device
types. If the device type is unknown, by definition, we don't have a
driver for it.
After you resolve it, you can use the Bean architecture to call methods
such as:
getDMAChannel();
setDMAChannel(1);
> Then again, how would you know that there aren't more than one sound card
> available on localhost?
JOS startup is responsible for probing the motherboard for everything
connected to it. If JOS cannot find something, the application simply
cannot use it.
> Perhaps I'm looking at the problem in the wrong direction. The URI
> here would be the way for the programs to allocate a resource.
No, I think the URI is a way of grabbing an interface to a device. Then,
that interface can be used to allocate whatever can be allocated.
Certain things cannot be allocated, right?
> Here we come down to how much configuration of the device should be
> done by the programmer, as opposed through internal setup. Does the
> programmer really need to know whether modem A is on a serial port or
> a USB port?
No, but he should be able to know if he wishes to. The JOS programmer
*must* be able to know that, though ;-)
> Would you want to have to type in
> "in:data:buffer:file:fat16:hdd://1?cylinders=255&tracks=65535&file=external.txt"?
No, this is long to type, but that's why JOS can map certain things
during start up. Of course, I do want to be *able* to type the above
thing. The "file:" protocol will be actually a shortcut to:
in:file:device:hdisk:ide://localhost/bus/ide/1/a/1/filesystem?path=...
Nor will I have to type anything to allocate memory, I can just do it
this way:
String string = new String("Hello!");
just as:
File file = new File("filname.ext");
> This may be a good place to add our diagnostic tools and configuration
> tools. But how do we do this? Do we add another scheme, such as
> "config:device:port:/ports/serial/1", or do we add it to the path:
> "device:port:/ports/serial/1/config"? I dunno.
The device finder and manager should return devices. We could do this:
Modem modem = (Modem)DeviceManager.getDevice(...);
DeviceConfiguration config = modem.getConfiguration();
config.setParameter(..., ...);
etc.
What do you think?
--
"Learn from others' mistakes, for you won't live long
enough to make them all yourself..."
________________________________________________________________________
[EMAIL: mailto:[EMAIL PROTECTED]] [URL: http://www.outworld.org/people/al]
[TEL1: (30) +31 422392] [TEL2: (30) +31 428154] [CELL: (30) +937 110247]
[ADDRESS: 14 Argonafton St., Kalamaria, 551 31, Thessaloniki, Greece GR]
PLEASE DO NOT SEND ME ANY UNSOLICITED COMMERCIAL EMAIL [DSS: 0xDBEF8ECC]
_______________________________________________
Kernel maillist - [EMAIL PROTECTED]
http://jos.org/mailman/listinfo/kernel