How does OS detect hardware?

Discussion in 'Operating Systems' started by Maxwellius, Dec 31, 2009.

  1. Maxwellius

    Maxwellius New Member

    I've never been able to figure out how operating systems detect the hardware they're hooked up to. Google searching has so far been futile. Does the OS send a signal through all the buses asking for identification? This is important since I'm building a computer from scratch.
  2. tremmor

    tremmor Active Member

  3. Maxwellius

    Maxwellius New Member

    I mean like when my system boots up, the BIOS detects my hardware, displays a menu on my screen, and asks me what media I want to boot from. How does it know I have a monitor and a keyboard and a hard drive?
  4. S.T.A.R.S.

    S.T.A.R.S. banned

    When your OS is turned on,as soon as you plug any devices in,it detects them automatically.The reason is simple.The OS is programmed that way so it detects all the new devices and automatically installs the proper drivers that Microsoft included in the OS itself.All those error messages,information messages,warning messages,balloon tips....blabla....which you get while connecting the hardware to your computer you get again for the same reason....Microsoft programmed the OS that way and when you make the hardware change,the programmed code from the OS is executed in order to make what it should make wether if it installs the simple USB stick,new HDD,new monitor and so on......Some OS components even use the timer so they can scan for hardware changes every second or every 10 seconds or every minute or however they decided to make it.
    In short...EVERY SINGLE thing that you use and see in your OS contains the programming code which executes when needed and therefore makes what it should make.Here is a small example:

    You have a window with bunch of options.You adjust all those options just the way you want them and then you click the OK button which APPLIES ALL THOSE OPTIONS and also CLOSES the window.Now...that OK button seems very simple.You KNOW you must click it and after you do,the window is closed immediately.BUT what you do not see is the HUGE programmed code behind that button.By clicking that OK button,a LOT of programming code is executed and it makes what it should make.Wether if it saves some text,check box state,radio button state,all their functions and so on.In short...there is A LOT of code that one OS contains.A LOT...

    As for the keyboard and the monitor,as soon as the BIOS has fully loaded,it automatically points to the BOOT SECTOR on the HDD which tells the BIOS what to start loading.Wether should he start loading some OS such as XP,Vista,some DOS program or whatever you are trying to load...
    Your monitor and the keyboard WORK because the OS automatically starts loading their drivers as soon as it starts booting.So while the OS is booting up,during the boot up process they load ALL the neccessary drivers so that your devices could work properly after the OS is fully loaded.Wether if its the monitor,keyboard,mouse and so on...

    Usually the drivers are located under the: "C:\WINDOWS\system32\drivers\"
    There are few more places where the drivers are located.It depends of course on the driver itself and where that driver has installed its neccessary files.

    One more important thing is the REGISTRY.EVERY SINGLE installed hardware and its drivers writes their informations into the Windows registry.This is very important so that the OS KNOWS that you have those hardware drivers installed and therefore it can start loading them on the boot up process...
    If you just have the drivers,but their informations are NOT written into the Windows registry,the hardware drivers will not work then because the OS will not know that you have those hardware drivers at all and of course it wont use them and the OS will act like you dont have that hardware devices plugged into your computer...
    The registry file called "system" contains most of the hardware drivers informations and it can be located under the: "C:\WINDOWS\system32\config\system"

    Cheers and happy new 2010. year everyone!!!
    Last edited: Dec 31, 2009
  5. Maxwellius

    Maxwellius New Member

    First of all, I'm running Linux. You can't just assume people use Windows.

    Second of all, I'm not talking about the OS specifically. My BIOS does a great job at telling what sort of hardware I have, and I'm sure it doesn't have every type of driver hard-coded into a tiny little ROM chip. Does the manufacturer of the motherboard rig it up to talk to all the other hardware? On my little Z80 single-board computer I'm making, I'm just using a 2-port PIO chip. I can hard-code my processor to deal with only that chip. But on modern computers, it's much more complicated, and I can't quite figure out how Linux or my BIOS or whatever figures out what hardware I have installed even before it tries to interface with it.
  6. zombine210

    zombine210 New Member

    interesting, but i don't know,

    first i thought you were talking about the HAL, but i think that's windows specific.

    also, it might have to do with the motherboard's chipset collecting this data. each chipset can only recognize certain hardware, that's why you can't use a pentium IV on a PIII motherboard.

    also, each micro controller has it's own assembly language instruction set. the os must somehow know this language to be able to operate it. that's why when you chose a distro, you download the one for your particular cpu: i386, i486, x86.

    i didn't know there was a linux distro to run on a z80, interesting.

    please post back when you finish this project, i have an old gameboy that uses this chip. :)
  7. Maxwellius

    Maxwellius New Member

    Sorry, the computer I'm building is different from the computer I plan on using. It's just a tiny little experiment. Anyways, I think I figured it out. The manufacturer puts a chipset on the motherboard that interfaces the front-side bus, which connects the CPU to the rest of the computer, with the main memory and all the peripherals, like the hard drive I'm booting off of. So the motherboard, not the BIOS, has to figure out how to talk to the hardware.
  8. S.T.A.R.S.

    S.T.A.R.S. banned

    Hehehe now you know why its almost impossible to work with newest hardware components which are connected to the 20 years old motherboard.:D
    It's like you want to install Windows 95 on today's modern computers. ^^
  9. canivari

    canivari New Member

    In these days allmost all hardware cames with plugand play Bios inside of it
    When u power up your pc, the bios usually send echo requests to the chipset and chipset
    send the message to all plug and play hardware asking theyre capability,size,heads,cilinders,
    capacty,etc (i think u got the point) and each hardware send theyre especifications and where they are located.
    Bios reserves then an adress for each component so it can be used later
    from the OS booted up.
    In devices that are not plug and play like old printers that usually are conected
    from LPT or RS232, u ned to install them later inside the OS manually.
    And for what i could read in the thread, u are running Linux, and in Linux operates with hardware from the Kernel it self, in windows is
    used what we call an driver.
    Hope that helps.
    Last edited: Jan 1, 2010
  10. S.T.A.R.S.

    S.T.A.R.S. banned

    I agree with everything you said here.
  11. whs

    whs New Member

    The answer to the original question:
    The BIOS scans the ports and the OS gets an interrupt when you attach a device.

Share This Page