Home arrow Forums
OSDEV Forums  


uck
User

Fresh Osdever
Posts: 2
graphgraph
Karma: 0  
hardware interfacing - 2006/10/30 11:06 Are there any books or articles out there about general hardware interfacing with assembly language? Such as peripherals and usb and other ports. Searching google and amazon I can't find anything that isn't specific to certain hardware/ports...
  | | The administrator has disabled public write access.
OSDEV
Community
Advertisement
   
gaf
User

Platinum Osdever
Posts: 153
graph
Karma: 10  
Re:hardware interfacing - 2006/10/30 14:25 Hello,
On the x86 architecture there are two address spaces that can be used to communicate with devices:

a) Some memory regions are mapped to certain devices that can then be accessed using regular mov instructions

The video console for example start at linear address 0xB8000 in memory. To write a large 'A' to the upper left corner, all you have to do is to move the ANSI character to this address:
Code:

 mov al'A' mov [0xB8000}, al



b) Port space is 16bit wide and can be accessed using the in/out instructions

An example for a device that uses ports is the console cursor (the small blinking thing on your boot screen). Setting its position is a bit tedious, but the idea is really simple:
Code:

 mov al0x0f    Command"Write lower 8bit" mov dx0x03d4  Command port out aldx      Send the command to the device mov al0x00    The lower 8bit (character #__XX) mov dx0x03d5  Data port out aldx      Send the data mov al0x0e    Command"Write upper 8bit" mov dx0x03d4  Command port out aldx      Send the command to the device mov al0x00    The upper 8bit (character #XX__) mov dx0x03d5  Data port out aldx      Send the data



Apart from that you should probably know that devices can use interrupt to inform the processor on an event. There are several tutorials about this topic on bonafide.

Searching google and amazon I can't find anything that isn't specific to certain hardware/ports.
Every device has its own command set and provides different functions. There really is no official standard that covers more than a group of devices (all floppy disks, all IDE devices, etc).

You can find a list of ports and memory ranges used by the most important hardware on Ralf Brown's site. If you told me which device(s) you're interested in I could probably provide you with some additional papers and information.

regards,
gaf
  | | The administrator has disabled public write access.
uck
User

Fresh Osdever
Posts: 2
graphgraph
Karma: 0  
Re:hardware interfacing - 2006/10/31 19:36 Thanks gaf. I know a little about ports, IRQ's and DMA, I guess my problem is understanding how they all fit together. For example, how does one come to know if there is a device in a certain PCI slot when the PC boots up? If there is a device in the slot then how does he know how to address it? What port/IRQ/address range does it use? It seems like pretty basic stuff I just can't find any resources that answer those questions in much depth...
  | | The administrator has disabled public write access.
gaf
Visitor
 
Re:hardware interfacing - 2006/11/02 10:02 How does one come to know if there is a device in a certain PCI slot when the PC boots up? If there is a device in the slot then how does he know how to address it?
The PCI Bus supports a plug & play mechanism to detect and configure installed devices. You could use the OSFAQ as a starting poin to search for more in depth information. Note however that PCI is already a quite adavanced topic that will require a lot of work.

Another way to detect the system hardware is to use the ACPI interface. The advantage of this technique is that all devices can be detected (not just PIC cards) and that there's a common standard for power management. Unfortunately the ACPI standard is extremly complex and hard to implement.

In my opinion the only viable way for a hobby operating system is to rely on the legacy hardware. These devices have usually been part of the x86 architecture for a long time, are extremly wide-spread and keep to a common standard:

  • Console and VGA
  • Floppy Disks
  • RTC and PIT Timers
  • Hardisks, CR-ROM, DVD-ROM

All of these devices can be consider to be present on virtually every computer. They can always be accessed using the same well-known ports or memory ranges and their command set is standartized. You can find more information about most of these devices in the aforementioned OSFAQ.

regards,
gaf
  | | The administrator has disabled public write access.

A WebArticles site. Sponsored by Evoleto. Motorola V525 / Business Directory / Delaware Incorporation / Home Made Bazaar