OSDev.org

The Place to Start for Operating System Developers
It is currently Wed Apr 24, 2024 7:08 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Virtual Drivers, Plug 'n' Play etc.
PostPosted: Wed Jul 14, 2004 7:29 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 9:01 am
Posts: 842
Considering the fact that most kernels do not allow direct access to hardware by user programs how is it then possible to install device drivers at runtime, i.e plug 'n' play. If this is supported then that means that the HAL is modified in some way, isn't that so? so can this be a security problem in an OS?
Also how do Virtual Drivers work, I'm referring to programs such as Virtual CD, CD Ghost etc for Windows 9X/XP (btw does linux have some such programs? or do we use mknod etc to do this?)

_________________
Only Human


Top
 Profile  
 
 Post subject: Re:Virtual Drivers, Plug 'n' Play etc.
PostPosted: Wed Jul 14, 2004 7:37 am 
For Plug'n'Play the kernel detects the hardware and then adds the driver. In an OS you have to rely on the fact that drivers will be well written. If they're not then the system probably won't work even if it doesn't crash.

Pete


Top
  
 
 Post subject: Re:Virtual Drivers, Plug 'n' Play etc.
PostPosted: Wed Jul 14, 2004 8:19 am 
Offline
Member
Member
User avatar

Joined: Thu Nov 16, 2006 12:01 pm
Posts: 7614
Location: Germany
Neo wrote:
Also how do Virtual Drivers work, I'm referring to programs such as Virtual CD, CD Ghost etc for Windows 9X/XP


You mean, accessing a hard drive file as if it were a CD-ROM?

The driver architecture is usually multi-leveled. For example, there was a tool for AmigaOS that allowed to virtually "write" to plain CD-ROM: On the filesystem level, it registered a new (logical) "device" (the "writeable" CD-ROM, think "drive letter" if you like). On the access level, it handled write access by writing files to hard drive, and read accesses by reading from CD-ROM unless the file in question was previously "written" to hard drive.

You see that there isn't even any real device driving involved; all that this "virtual CD driver" does is smartly delegating things.

The only real device stuff to be done is translating the generic read / write calls into whatever the hardware understands. Higher logic (like the "virtual CD" I described) can be done well inside user-land.

Quote:
btw does linux have some such programs?


Check the web or other favourite source of info for "loopback device".

_________________
Every good solution is obvious once you've found it.


Top
 Profile  
 
 Post subject: Re:Virtual Drivers, Plug 'n' Play etc.
PostPosted: Wed Jul 14, 2004 11:46 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 9:01 am
Posts: 842
what about the first part of my question, anything on that?

_________________
Only Human


Top
 Profile  
 
 Post subject: Re:Virtual Drivers, Plug 'n' Play etc.
PostPosted: Wed Jul 14, 2004 1:38 pm 
Quote:
For Plug'n'Play the kernel detects the hardware and then adds the driver.

The app doesn't access hardware


Top
  
 
 Post subject: Re:Virtual Drivers, Plug 'n' Play etc.
PostPosted: Thu Jul 15, 2004 1:30 pm 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 9:01 am
Posts: 842
Solar wrote:
You mean, accessing a hard drive file as if it were a CD-ROM?

The driver architecture is usually multi-leveled. For example, there was a tool for AmigaOS that allowed to virtually "write" to plain CD-ROM: On the filesystem level, it registered a new (logical) "device" (the "writeable" CD-ROM, think "drive letter" if you like). On the access level, it handled write access by writing files to hard drive, and read accesses by reading from CD-ROM unless the file in question was previously "written" to hard drive.


If you could explain that more it would be helpful. like how to register a new logical device (modify the partition table?) and how the access is trapped?

_________________
Only Human


Top
 Profile  
 
 Post subject: Re:Virtual Drivers, Plug 'n' Play etc.
PostPosted: Thu Jul 15, 2004 10:51 pm 
Offline
Member
Member
User avatar

Joined: Thu Nov 16, 2006 12:01 pm
Posts: 7614
Location: Germany
No, logical device, not logical partition...

Think an USB ZIP that is added at runtime.

The kernel detects the interrupt, or whatever heralds the addition of the USB ZIP to the system. It now looks up what driver is needed for the new device, loads the driver binary, and registers the new device with the driver system. "Add one read/write device, designate Sierra 4, to the array of available devices."

All the read/write device drivers translate a "device_read()" to the necessary bus action, likewise for a "device_write()". They have no idea of file systems etc. - they just take a defined interface (device_*()) and translate it to whatever device-specific magic is needed.

Now come the "layers". First, you'd like to make the drive accessible in some way - assign it a drive letter, or a mount point, or whatever your OS does with drives. Some magic that takes access to "ZIP:" and passes that to Sierra 4 in the array of read/write devices.

One level above that comes the file system. Since you usually don't do "read byte X to byte Y", but "read file Z", you need some code that keeps a catalog of the drive, and translates an fopen() / fscanf() to a series of read() calls to the ZIP: drive. (Translated by the access layer mentioned above.)

That's a rough layout. The details of this depend heavily on your OS architecture and your design of drive access.

_________________
Every good solution is obvious once you've found it.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Majestic-12 [Bot] and 217 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group