{"id":265,"date":"2020-08-18T19:23:47","date_gmt":"2020-08-18T20:23:47","guid":{"rendered":"http:\/\/www.linux-tutorial.info\/?page_id=77"},"modified":"2020-08-22T19:25:16","modified_gmt":"2020-08-22T20:25:16","slug":"this-is-the-page-title-toplevel-100","status":"publish","type":"page","link":"http:\/\/www.linux-tutorial.info\/?page_id=265","title":{"rendered":"Basic Input-Output Services and the System Bus"},"content":{"rendered":"\n<title>Basic Input-Output Services and the System Bus<\/title>\n<p>\nA key concept for this discussion is the <glossary>bus<\/glossary>. So, just what is a bus? In computer terms, it has a similar meaning as your local county public transit, as it is used to move\nsomething from one place to another. The county transit <glossary>bus<\/glossary>\nmoves people; a computer bus moves information.\n<\/p>\n<question id=\"209\" text=\"What is the term used for the collection of connections through which data is transfered?\" \/>\n<concept id=\"154\" description=\"The collection of connections through which data is transfered is called a 'bus'.\" \/>\n<p>\nThe information is transmitted along the <glossary>bus<\/glossary>\nas electric signals. If you have ever opened up a computer,\nyou probably saw that there is one central printed circuit board with the\n<glossary>CPU<\/glossary>, the expansion cards,\nand several chips sticking out of it. The electronic connections between these\nparts is referred to as a <glossary>bus<\/glossary>.\n<\/p>\n<question id=\"210\" text=\"What are the the two kinds of signals that move through a computer bus?\" \/>\n<p>\nThe signals that move along a computer <glossary>bus<\/glossary>\ncomes in two basic forms: control and data. Control signals do just that: they control things. Data signals are just that: data. I will get to how this happens and what each part does as we move along.\n<\/p>\n<p>\nIn todays PC computer\nmarket, there are several buses, many of which have the same functions but\napproach things quite differently. In this section, I am going to talk about the\ndifferent <glossary>bus<\/glossary> types, what goes on between\nthe different devices on the <glossary>bus<\/glossary>, and what the main components are that communicate along the bus.\n<\/p>\n<question id=\"211\" text=\"What is the term for the collection of functions used by older system (i.e. DOS) to access hardware?\" \/>\n<p>\nDespite differences in <glossary>bus<\/glossary>  types, certain aspects of the hardware are common among\nall PCs. The Basic Input Output System (BIOS), interrupts,\n<glossary>Direct Memory Access<\/glossary>\nchannels, and base\naddresses are just a few. Although once the <glossary>kernel<\/glossary>\nis loaded, Linux almost never needs the system\nBIOS. However, understanding the function and purpose of the BIOS is useful in understanding the\nprocess that the computer goes through when booting. That is, from the time you hit the power switch to\nwhen Linux has full control of the hardware.\n<\/p>\n<p>\nThe <glossary>BIOS<\/glossary> is the mechanism <glossary>DOS<\/glossary>\nuses to access the hardware. DOS (or a DOS\napplication) makes <glossary>BIOS<\/glossary>\ncalls that then transfer the data to and from the devices. Except for the\nfirst few moments of the <glossary>boot<\/glossary>\nprocess and the last moment of a shutdown, Linux may never use it again.\n<\/p>\n<p>\nBecause the BIOS can actually perform certains functions and does not simply provide information,\nit is common to think of the BIOS as a set of small programs which carry out the necessary functions. Although very limited in scope, one might also consider it sort of a &#8220;mini&#8221; operating system.\nIt is important to note that in modern computers, you will find a BIOS in places other than just on the motherboard. For example, it is very common to have disk controllers and even graphic cards with their own BIOS.\n<\/p>\n<p>\nWhen PCs first started becoming commonplace, users typically had to set the BIOS clock when the computer was first set up. Often there was was battery that powered an internal clock which kept track of time when the computer was turned off. Still, it was occassionally necessary to reset the system time on this &#8220;real-time&#8221; clock when the system rebooted.\n<\/p>\n<p>\nWhen Linux first boots, it checks the time of the hardware clock and then calls an internal function at regular intervals which updates the system time accordingly. It is interesting to note that the system clock update mechanism has a very low priority. Therefore, it is common on busy system, that updates are skipped in favor of processes with a high priority. The result is that the time might &#8220;drift&#8221; by a few minutes. This means that the system clock and hardware clock differ.  Eventually Linux started included the <command>hwclock<\/command> command, which is used to query and change the hardware clock. One addtional problem is the fact that the BIOS cannot handle changes due to daylight savings time or differences in time zone.\n<\/p>\n<p>\nTo overcome both the drift and differences with the hardward clock. you can implement the Network Time Protocol (NTP). This allows you to synchronize your system time with a more accurate clock. This can be a specific machine within your own network or you can update from public servers connected to the internet.\n<\/p>\n<p>\nThe standard <glossary>BIOS<\/glossary> for PCs is the IBM BIOS, but that&#8217;s simply because &#8220;PC&#8221; is\nan IBM standard. However, &#8220;standard&#8221; does not mean &#8220;most common,&#8221; as there are\nseveral other <glossary>BIOS<\/glossary> vendors, such as Phoenix and AMI.\n<\/p>\n<p>\n<glossary>DOS<\/glossary> or a DOS <glossary>application<\/glossary>\nmakes device\n<em>independent<\/em> calls to the <glossary>BIOS<\/glossary>\nto transfer data. The BIOS then translates this into device\n<em>dependent<\/em> instructions. For example, <glossary>DOS<\/glossary>\n(or the application) requests that the hard disk\nread a certain block of data. The <glossary>application<\/glossary>\ndoes not care what kind of hard disk hardware there\nis, nor should it. It is the BIOS&#8217;s job to make that translation to something the\nspecific hard disk can understand.\n<\/p>\n<question id=\"212\" text=\"What part of Linux takes over the function of the BIOS?\" \/>\n<concept id=\"155\" description=\"Device drivers take over the work the BIOS did with DOS and older versions of Windows.\" \/>\n<p>\nIn Linux, on the other hand, a special\nprogram called a <glossary>device driver<\/glossary> handles the\nfunctions of the <glossary>BIOS<\/glossary>. As we talked about in the section on the <glossary>kernel<\/glossary>, device drivers are sets of\nroutines that directly access the hardware, just as the <glossary>BIOS<\/glossary>\ndoes.\n<\/p>\n<p>\nThe fact that Linux by-passes the <glossary>BIOS<\/glossary>\nand goes directly to the hardware is one reason why some hardware will work under\nDOS but not under Linux. In some instances, the <glossary>BIOS<\/glossary>\nhas been specially designed for the machine on\nwhich it runs. Because of this, it can speak the same dialect of &#8220;machine language&#8221; that\nthe rest of the hardware speaks. However, because <glossary>UNIX<\/glossary>\ndoes not speak the same dialect, things get lost in the translation.\n<\/p>\n<question id=\"213\" text=\"The Intel 80x86 family of processors has an I\/O space that is distinct from memory space\" \/>\n<p>\nThe Intel 80&#215;86 family of processors has an\n<glossary>I\/O<\/glossary> space that is\ndistinct from memory space. What this means is that memory (or RAM) is treated\ndifferently than <glossary>I\/O<\/glossary>.\nOther machine architectures, such as the Motorola 68000 family, see accessing\nmemory and <glossary>I\/O<\/glossary>\nas the same thing. Although the addresses for <glossary>I\/O<\/glossary>\ndevices appears as &#8220;normal&#8221; memory addresses\nand the <glossary>CPU<\/glossary>\nis performing a read or write as it would to <glossary>RAM<\/glossary>,\n the result is completely different.\n<\/p><p>\nWhen accessing memory, either for a read or write, the <glossary>CPU<\/glossary>\nutilizes the same <glossary>address<\/glossary>\nand data\nlines as it does when accessing <glossary>RAM<\/glossary>.\nThe difference lies in the M\/IO# line on the <glossary>CPU<\/glossary>.\nFor those not familiar with digital electronics, this can also be described as the\n&#8220;Memory\/Not IO&#8221; line. That is, if the line is high (there is a signal on the line),\nthe <glossary>CPU<\/glossary> addresses memory. If it is low (no signal), it addresses\nan <glossary>I\/O<\/glossary> device.\n<\/p><p>\nAlthough the Linux <glossary>operating system<\/glossary>\nis much different from <glossary>DOS<\/glossary>,\n it still must access the\nhardware in the same fashion. There are assembly language instructions that allow\nan operating\nsystem (or any program for that matter) to access the hardware correctly. By\npassing these commands the <glossary>base address<\/glossary>\nof the <glossary>I\/O<\/glossary>\ndevice, the <glossary>CPU<\/glossary>\nknows to keep the M\/IO# line low and therefore access the device and not memory.\n<\/p>\n<p>\nYou can often see the <glossary>base address<\/glossary> of each device on the\nsystem when you <glossary>boot<\/glossary>. The hardware screen shows you the devices\nit recognizes along with certain values such as the <glossary>base address<\/glossary>, the\n<glossary>interrupt<\/glossary>\nvector, and the <glossary>DMA<\/glossary> channel. You can also see this same\ninformation by looking in the \/var\/log\/messages and several files in the \/proc file\nsystem.\n<\/p>\n<question id=\"214\" text=\"I\/O addresses higher than what may create 'image addresses' which can cause conflicts with other hardware.\" \/>\n<p>\nIf your motherboard only uses 10 <glossary>address<\/glossary>\nlines, devices on the motherboard that have an I\/O <glossary>address<\/glossary>\n(such as the <glossary>DMA<\/glossary>\ncontroller and PIC) will appear at their normal address, as well as at\n&#8220;image&#8221; addresses. This is because the higher 6 bits are ignored, so any\n16-bit <glossary>address<\/glossary>\nin\nwhich the lower 10 bits match will show up as an &#8220;image&#8221; <glossary>address<\/glossary>.\n Because 6 bits are ignored, there are 63 possible &#8220;image&#8221; addresses (64 minus the one for the\n&#8220;real&#8221; address).\n<\/p>\n<p>\nThese image addresses may cause conflicts with hardware that have\nI\/O addresses higher than 0x3FF (1023), which is the highest possible with\nonly 10 <glossary>address<\/glossary>\nlines.\nTherefore, if your motherboard only has 10 bits of <glossary>I\/O<\/glossary>\naddresses, you shouldn&#8217;t put devices at\naddresses higher than 0x3FF.\n<\/p>\n<question id=\"215\" text=\"Linux can access hardware with overlapping base addresses.\" \/>\n<p>\nWhen you install, it is vital that no two devices have\noverlapping (or identical) base addresses. Though you can share interrupts\nand <glossary>DMA<\/glossary> channels on some\nmachines, you can never share base addresses. If you attempt to read a device\nthat has an overlapping base <glossary>address<\/glossary>,\n you may get information from both devices.\n<\/p>\n<p>\nIf you are installing a\nboard whose default <glossary>base address<\/glossary>\nis the same as the one already on the system, you must change one\naddress before they both will work. Additionally, you are almost always asked\nfor the base address\nof a card when you install it. Therefore, you will need to keep track of\n<glossary>address<\/glossary>.\nSee the section on troubleshooting for tips on maintaining a notebook with this\nkind of information.\n<\/p>\n<p>\nNote that with current (2009) hardware most of these issues with interrupts, DMA channels and base addresses is becoming moot. Most cards today are either PCI or something even more advanced so it is no longer necessary to set anything on the cards yourself. The system does it all for you!\n<\/p>\n<p>\n<p>\nThe table below  contains a list of the more common devices and the <glossary>base address<\/glossary>\nranges that they use.\n<\/p>\n<p>\nTable &#8211; Common Hex Addresses\n<\/p><p><center>\n<table BORDER cellspacing=1 bordercolor=\"#000000\" cellpadding=7 WIDTH=451>\n<tr>\n<td><b><p>\nHexRange<\/b><\/td><td><b><p>Device <\/b><\/td><\/tr>\n<tr>\n<td><p>000-0ff <\/td><td><p>\nMotherboard devices (DMA Controller, <glossary>PIC<\/glossary>, timer chip, etc.) <\/td><\/tr>\n<tr>\n<td><p>1f0-1f8<\/td><td><p>\nFixed disk controller (WD10xx) <\/td><\/tr>\n<tr>\n<td><p>278-27f<\/td><td><p>\nParallel port 2<\/td><\/tr><tr><td>\n<p>2f8-2ff<\/td><td>\n<p>\nSerial port 2 <\/td><\/tr><tr><td>\n<p>378-37f<\/td><td><p>\nParallel port 1\n<\/td><\/tr>\n<tr>\n<td><p>3bc-3bf <\/td><td>\n<p>\nMonochrome display and parallel port 2 <\/td><\/tr>\n<tr>\n<td><p>3c0-3cf<\/td><td><p>\nEGA or <glossary>VGA<\/glossary> adapter <\/td><\/tr>\n<tr>\n<td><p>3d0-3df<\/td><td><p>\nCGA, <glossary>EGA<\/glossary>, or VGA adapter <\/td><\/tr>\n<tr>\n<td><p>3f0-3f7<\/td><td><p>\nFloppy disk controller <\/td><\/tr>\n<tr>\n<td><p>3f8-3ff<\/td><td><p>\nSerial port 1<\/td><\/tr><\/table><\/center>\n<\/p>\n<p>\nOne common BIOS feature is the ability to set one or more passwords. For example, you can set a user password which prevents the sytem from booting if the correct password is not provided. You can also set a system or admin password, which prevents unauthorized users from changing the configuration. When my kids were growing up I would set a BIOS password to keep them from playing too many video games. However, in my experience restricting physical access to the machine provides more security than a BIOS password as anyone who manages to walk away with the computer can find all sorts of information on the  Internet for overcoming BIOS passwords.\n<\/p>\n<p>\nAlthough universal, some new computers can detect configuration changes, including adding or removing hardware. When the system detects new hardware during the boot processes, the BIOS may prompt the user to acknowledge  the addition or removal of the hardware. For example, by pressing the the F1 or some other key. In some cases, if the BIOS is password protected, the user must input the appropriate password to continue.\n<\/p>\n<p>\nThe BIOS is also responsible for the Power-On Self Test (POST). As the name implies, a test is carried out when the system is powered on . Various type of hardware are checked to see if they exiss and if so, a diagnostic test is carried out. By default the extent of such tests is limited, but modern BIOSes typically have more detailed diagnostic tests, but these need to be enabled manually. Generally, these are only necessary if you suspect a hardware problem and can take several minutes to complete.  Should either type of test find an error this is referred to an  &#8220;<glossary>Irregular POST Condition<\/glossary>&#8220;, which may be displayed on the screen or the BIOS will genereate a series of beeps. What the pattern of beeps mean is found in the manual for the respective motherboard. Note that these patterns will differer even among motherboards from the same manufacturer. Therefore, if you are relying on these to diagnose a problem, be sure you have interpreted them correctly for your specific motherboard.\n<\/p>\n<p>\nIn addition to the POST, the BIOS also serves as an interface to a special memory that stores various hardware settings. This memory is call the Complementary Metal Oxide Semiconductor) memory or simply CMOS. Although the CMOS is <glossary>volatile memory<\/glossary>, your motherboad is provided with a battery that allows the CMOS to keeps its settings for years. However, like all batteries, it will eventually die and will need to be replaced. The most common symptom is that hardware settings are lost when the system is powered down. I have also seen some cases where the settings are different but not the default.\n<\/p>\n<p>\nAmong the information the CMOS may contain is the date, whether specific on-board hardware is enabled or not, and the boot order of various devices. This last one I feel is very important to keep track of. It is possible that your system allows you boot from floppy, hard disk, CD\/DVD, USB, and even from a network device. If you have multiple devices of the same type, you may have even more options. One common configuration is first floppy, then CD\/DVD then the first hard disk. If there is no floppy, this might appear at the end of the list of be disabled entirely. If you are trying to boot from a CD\/DVD, but your hard disk comes first in the boot order, the system logically will always attempt to boot from the hard disk first and if there is a bootable operating system, that is what is booted. If you have multiple hard disks it is possible that only the second one is bootable, but appears lower in the list. You then get an error when your try to boot from the first hard disk (for example &#8220;No oerating system found&#8221;). Some more modern BIOSes have an option whereby you press a certain button at boot-time (e.g. F12) and you are brought to a boot menu where you can select the boot device. This only applies for the current boot processes and the order is not stored in the CMOS.\n<\/p>\n<p>\n<\/p>\n<p>\nUsing the same battery as the one which keeps the configuration Information, a so-called &#8220;real-time&#8221; clock runs continually and is ofter used to set and maintain the clock the operating system uses. On the other hand, many operating systems like Linux and other UNIX-variants maintain the system time using <glossary term=\"interrupt\">>interrupts<\/glossary>. For example, there are 100 clock interrupts per second and the system clock is incremented by 1 second after 100 such interrupts. The problem here is that the clock interrupt has a low priority and on a busy system, it is possible that clock interrupts are ingored until the next one. If for example, this happens 10 times a second, it will actually take 110\/100 second to count 100 interrupts and thus add 1 second to the systme clock. This means that over time, the system clock is behind the real time. To address this problem, many operating systems (including Linux) use the Network Time Protocol (NTP) which reads the currents from a central server at regular intervals. Although the time can still drift, it is regularly corrected and is usually not noticed by normal users.\n<\/p>\n<p>\nIn recent years, Intel along with a number of other hardware manufacturer developed a new standard called the <glossary>Extensible Firmware Interface<\/glossary> (EFI). The EFI provides the same kind of functions as the BIOS, but does so in a completely different manner, as well as addresses limitation of the BIOS (e.g. 16-bit processor mode, 1 MB address space, and so forth.)\n<\/p>\n<p>\nMost of the information stored in the system BIOS and well as other hardware can be found in the \/proc directory. (\/sys on newer systems) You can get details about this in the section <site id=\"167\">Finding Out About Your System<\/site>.\n<\/p>\n<p>\nHard disks:\n<\/p>\n<p>\nOriginally the BIOS used Interrupt (INT) 13h as the interface to the hard disk. This mechanism had a limitation of 1024 cylinders, 256 heads and 64 sectors per track for a total of 8 GB. However, the original IDE specification has different limits: 65536 cylinders, 16 heads and 255 sectors per track. Since the smallest maximum value needs to be used, this works out to a maximum disk size of 504 MB. Because this depends on the cylinders, heads and sector, it is referred as the CHS specification and diskspace is calculated so:\n<\/p>\n<p>\ncylinders * heads * sectors per track  * 512 bytes per sector = capacity\n<\/p>\n<p>\nThe first method to get around this was problem was called Extended Cylinders Heads Sectors (ECHS). Typically you will see this in the BIOS as &#8220;Large Mode&#8221;, and is essentially a translation between the BIOS and INT13h. When activated, Large Mode takes the number of cylinders on the drive and calculates a &#8220;best fit&#8221; into the 1024 cylinders of INT13h by dividing the number of cylinders by a mulitple of 2 in order to get below 1024 cylinders. The number of heads is then mulitple by that same number. For example, if our disk has 4680 cylinders. In order to get this under 1024, we need to divide by 8, which gives us 585 cylinders which is then what the BIOS sees. Assuming the drive has 16 heades, we multiple 16 by 8 to get 128 heads.\n<\/p>\n<p>\nOne interesting and important aspect is that the IDE specification only supports up to 16 heads. This is <i>not<\/i> problem because the translation passes corrected <glossary>geometry<\/glossary> to the drive.\n<\/p>\n<p>\nEventually drives grew beyond the 8.4GB limitation of INT13h, so there was no way to define a translation that worked. The solution was Logical Block Addressing (LBA) which has actually become the most common way of getting around the 528MB limitation of IDE\/ATA drives. This is another type of transation and works by simply assigning each block a number starting a 0.\n<\/p>\n<p>\nModern operating system are no longer bothered with this problem anymore because the bypass the BIOS completely. Instead, they access the hardware directly and are not restricted by a limitaiton in the BIOS.\n<\/p>\n<p>\nMuch (if not most) of how your hardware is configured can be found by looking through the files in <glossary><directory>\/proc<\/directory><\/glossary> directpry.\n<\/p>\n<ul>\n<\/li>\/proc\/devices &#8211; <glossary>Major number<\/glossary> <\/li>\n<\/li>\/proc\/dma &#8211; DMA Channels <\/li>\n<\/li>\/proc\/interrupts &#8211; Interrupts <\/li>\n<\/li>\/proc\/ioports &#8211; IO Ports<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Basic Input-Output Services and the System Bus A key concept for this discussion is the bus. So, just what is a bus? In computer terms, it has a similar meaning as your local county public transit, as it is used &hellip; <a href=\"http:\/\/www.linux-tutorial.info\/?page_id=265\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-265","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages\/265","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=265"}],"version-history":[{"count":1,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages\/265\/revisions"}],"predecessor-version":[{"id":506,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages\/265\/revisions\/506"}],"wp:attachment":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=265"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}