|
From: <wol...@us...> - 2002-08-25 11:51:53
|
Update of /cvsroot/subtrick/TiTan/doc/prog_guide/boot/kernelinit In directory usw-pr-cvs1:/tmp/cvs-serv22442/doc/prog_guide/boot/kernelinit Added Files: Detecting Processor Type.htm Log Message: Talks Basically About Detection Of 386+ Processor Types And A Little Bit Of History --- NEW FILE: Detecting Processor Type.htm --- <html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:st1="urn:schemas-microsoft-com:office:smarttags" xmlns="http://www.w3.org/TR/REC-html40"> <head> <meta http-equiv=Content-Type content="text/html; charset=windows-1252"> <meta name=ProgId content=Word.Document> <meta name=Generator content="Microsoft Word 10"> <meta name=Originator content="Microsoft Word 10"> <link rel=File-List href="Detecting%20Processor%20Type_files/filelist.xml"> <title>Detecting Processor Type:</title> <o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="date"/> <!--[if gte mso 9]><xml> <o:DocumentProperties> <o:Author>Amgad Madkour</o:Author> <o:Template>Normal</o:Template> <o:LastAuthor>Amgad Madkour</o:LastAuthor> <o:Revision>2</o:Revision> <o:TotalTime>1</o:TotalTime> <o:Created>2002-08-08T10:21:00Z</o:Created> <o:LastSaved>2002-08-08T10:21:00Z</o:LastSaved> <o:Pages>1</o:Pages> <o:Words>437</o:Words> <o:Characters>2491</o:Characters> <o:Company>Madkour</o:Company> <o:Lines>20</o:Lines> <o:Paragraphs>5</o:Paragraphs> <o:CharactersWithSpaces>2923</o:CharactersWithSpaces> <o:Version>10.2625</o:Version> </o:DocumentProperties> </xml><![endif]--><!--[if gte mso 9]><xml> <w:WordDocument> <w:SpellingState>Clean</w:SpellingState> <w:GrammarState>Clean</w:GrammarState> <w:Compatibility> <w:BreakWrappedTables/> <w:SnapToGridInCell/> <w:WrapTextWithPunct/> <w:UseAsianBreakRules/> </w:Compatibility> <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif]--><!--[if !mso]><object classid="clsid:38481807-CA0E-42D2-BF39-B33AF135CC4D" id=ieooui></object> <style> st1\:*{behavior:url(#ieooui) } </style> <![endif]--> <style> <!-- /* Font Definitions */ @font-face {font-family:Wingdings; panose-1:5 0 0 0 0 0 0 0 0 0; mso-font-charset:2; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:0 268435456 0 0 -2147483648 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman";} span.SpellE {mso-style-name:""; mso-spl-e:yes;} span.GramE {mso-style-name:""; mso-gram-e:yes;} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} /* List Definitions */ @list l0 {mso-list-id:586964878; mso-list-type:hybrid; mso-list-template-ids:1810376388 67698689 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;} @list l0:level1 {mso-level-start-at:15; mso-level-number-format:bullet; mso-level-text:\F0B7; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; font-family:Symbol; mso-fareast-font-family:"Times New Roman"; mso-bidi-font-family:"Times New Roman";} ol {margin-bottom:0in;} ul {margin-bottom:0in;} --> </style> <!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman";} </style> <![endif]--> </head> <body lang=EN-US style='tab-interval:.5in'> <div class=Section1> <p class=MsoNormal><o:p> </o:p></p> <div style='border:none;border-bottom:solid windowtext 1.0pt;mso-border-bottom-alt: solid windowtext .75pt;padding:0in 0in 1.0pt 0in'> <p class=MsoNormal style='border:none;mso-border-bottom-alt:solid windowtext .75pt; padding:0in;mso-padding-alt:0in 0in 1.0pt 0in'><b>Detecting Processor Type:<o:p></o:p></b></p> <p class=MsoNormal style='border:none;mso-border-bottom-alt:solid windowtext .75pt; padding:0in;mso-padding-alt:0in 0in 1.0pt 0in'><b><o:p> </o:p></b></p> </div> <p class=MsoNormal><o:p> </o:p></p> <p class=MsoNormal><span class=GramE><i>Author :</i></span><i> Amgad Magdy Madkour<o:p></o:p></i></p> <p class=MsoNormal><i>Operating System <span class=GramE>Sector :</span> Boot<o:p></o:p></i></p> <p class=MsoNormal><span class=GramE><i>Programming <span style='mso-spacerun:yes'> </span>Language</i></span><i> : Assembly<o:p></o:p></i></p> <p class=MsoNormal><span class=GramE><i>Revision :</i></span><i> None<o:p></o:p></i></p> <p class=MsoNormal><i>Last <span class=GramE>Update :</span> </i><st1:date Month="7" Day="24" Year="2002"><i>24/7/2002</i></st1:date><i><o:p></o:p></i></p> <p class=MsoNormal><o:p> </o:p></p> <p class=MsoNormal><o:p> </o:p></p> <p class=MsoNormal>The detecting of the type of the processor mainly depends on the flag register, in our version of the Operating system we are depending on having a processor of 386+ to work <span class=GramE>on ,</span> in this version we have an Extended Flag Register (EFLAGS) which is a 32 bit register , in our case we care about bits from 12 to 15 which are </p> <p class=MsoNormal><o:p> </o:p></p> <p class=MsoNormal><span class=GramE>12 :</span> IOPL = I/O Privilege Level flag , permissions are from 0-3</p> <p class=MsoNormal><span class=GramE>13 :</span> NT = Nested Task Flag</p> <p class=MsoNormal><span class=GramE>14 :</span> RF = Resume Flag </p> <p class=MsoNormal><span class=GramE>15 :</span> VM = Virtual Mode Flag or to be exact Virtual 86 Mode Flag<span style='mso-spacerun:yes'> </span></p> <p class=MsoNormal><o:p> </o:p></p> <p class=MsoNormal><o:p> </o:p></p> <p class=MsoNormal>In the case that the processor is a 386 those bits would be modifiable <span class=GramE>bits ,</span> in the 8086 processor those bits will be all set to 1 ( 1111) and wont be allowed to be modified . In case that the processor is not an 8086 and maybe an 80286 then the bits would be (0111) but we wont be implementing checking code for that because we will only care about a 386 processor and anything else would be <span class=GramE>refused .</span> </p> <p class=MsoNormal><o:p> </o:p></p> <p class=MsoNormal>Now with the <span class=GramE>coding :</span> </p> <p class=MsoNormal><o:p> </o:p></p> <p class=MsoNormal><span class=GramE>;Programmed</span> By Amgad Madkour</p> <p class=MsoNormal><span class=GramE>;First</span> of all we save the flag register by putting it into the stack</p> <p class=MsoNormal><span class=SpellE><span class=GramE>pushf</span></span> </p> <p class=MsoNormal><o:p> </o:p></p> <p class=MsoNormal><span class=GramE>;next</span> we make the high bit of the ax register = 0<span style='mso-spacerun:yes'> </span>, ah=0</p> <p class=MsoNormal><span class=SpellE><span class=GramE>xor</span></span> <span class=SpellE>ah,ah</span></p> <p class=MsoNormal><o:p> </o:p></p> <p class=MsoNormal><span class=GramE>;then</span> we push ax on the stack , now we have flags and ax in the stack</p> <p class=MsoNormal><span class=GramE>push</span> ax</p> <p class=MsoNormal><o:p> </o:p></p> <p class=MsoNormal><span class=GramE>;this</span> means pop <span class=SpellE>whats</span> in the stack (top element) into the flag register</p> <p class=MsoNormal>; <span class=GramE>what</span> will be popped is the ax which is all 0s into the flag register </p> <p class=MsoNormal><span class=SpellE><span class=GramE>popf</span></span></p> <p class=MsoNormal><o:p> </o:p></p> <p class=MsoNormal><o:p> </o:p></p> <p class=MsoNormal><span class=GramE>;push</span> what is in the flag register into the stack after modification in </p> <p class=MsoNormal><span class=GramE>;the</span> flag register via ax register</p> <p class=MsoNormal><span class=SpellE><span class=GramE>pushf</span></span></p> <p class=MsoNormal><o:p> </o:p></p> <p class=MsoNormal><span class=GramE>;pop</span> <span class=SpellE>whats</span> in the stack which is the modified flags into ax for inspection</p> <p class=MsoNormal><span class=GramE>pop</span> ax</p> <p class=MsoNormal><o:p> </o:p></p> <p class=MsoNormal><span class=GramE>;and</span> (1111) in what is stored in the ah which represents what has been modified </p> <p class=MsoNormal><span class=GramE>;the</span> result will be stored in the accumulator (ax)</p> <p class=MsoNormal>; <span class=GramE>we</span> want to and only the high bits if the (ax)</p> <p class=MsoNormal><span class=GramE>and</span> ah,0f0h</p> <p class=MsoNormal><o:p> </o:p></p> <p class=MsoNormal>; <span class=GramE>at</span> this point if the result in the ah is 1111</p> <p class=MsoNormal><span class=SpellE><span class=GramE>cmp</span></span> ah,0f0h</p> <p class=MsoNormal><o:p> </o:p></p> <p class=MsoNormal><span class=GramE>;then</span><span style='mso-spacerun:yes'> </span>the processor is not a 386</p> <p class=MsoNormal><span class=SpellE><span class=GramE>je</span></span> no386</p> <p class=MsoNormal><o:p> </o:p></p> <p class=MsoNormal><span class=GramE>;else</span> if not 1111 then it had been modified , then its a 386</p> <p class=MsoNormal><span class=GramE>;print</span> that the user is having a 386+ processor</p> <p class=MsoNormal><span class=GramE>;those</span> two are just printing procedures </p> <p class=MsoNormal><span class=SpellE><span class=GramE>mov</span></span> si,is386</p> <p class=MsoNormal><span class=GramE>call</span> <span class=SpellE>kprint</span></p> <p class=MsoNormal><o:p> </o:p></p> <ul style='margin-top:0in' type=disc> <li class=MsoNormal style='mso-list:l0 level1 lfo1;tab-stops:list .5in'><span class=GramE>Note :</span> some people would have said why we used <span class=SpellE>xor</span> operation for example , well that is because the (<span class=SpellE>xor</span>) is faster than a (<span class=SpellE>mov</span>) operation .</li> <li class=MsoNormal style='mso-list:l0 level1 lfo1;tab-stops:list .5in'>Another important point is why the many push and pops , well for one thing the an easy way to access the flag register is via using the <span class=SpellE>pushf</span> and <span class=SpellE>popf</span> instructions of the stack to deal with the flag register</li> </ul> <p class=MsoNormal><o:p> </o:p></p> <p class=MsoNormal><b><i><span style='font-size:14.0pt'>Conclusion <o:p></o:p></span></i></b></p> <p class=MsoNormal><o:p> </o:p></p> <p class=MsoNormal>This document has shown how to detect 386 + processor in a very simple way with small set of <span class=GramE>instructions .</span></p> <p class=MsoNormal><o:p> </o:p></p> <p class=MsoNormal><span class=SpellE>TiTan</span> OS <span class=GramE>Notes :</span></p> <p class=MsoNormal><o:p> </o:p></p> <p class=MsoNormal>This File Depends On </p> <p class=MsoNormal>None</p> <p class=MsoNormal><o:p> </o:p></p> <p class=MsoNormal>This File is used by</p> <p class=MsoNormal>Kernel Initialization structure </p> <div style='border:none;border-bottom:solid windowtext 1.0pt;mso-border-bottom-alt: solid windowtext .75pt;padding:0in 0in 1.0pt 0in'> <p class=MsoNormal style='border:none;mso-border-bottom-alt:solid windowtext .75pt; padding:0in;mso-padding-alt:0in 0in 1.0pt 0in'><o:p> </o:p></p> </div> <p class=MsoNormal><o:p> </o:p></p> <p class=MsoNormal style='margin-left:.25in'><i>Any questions and comments about what is written would be appreciated and I would receive them on my <span class=GramE>mail ,</span> amg...@ho...</i><span style='mso-spacerun:yes'> </span></p> <p class=MsoNormal style='margin-left:.25in'><o:p> </o:p></p> <p class=MsoNormal style='margin-left:.25in'><span style='mso-tab-count:7'> </span>Copyrights 2002 to the author </p> <p class=MsoNormal><o:p> </o:p></p> </div> </body> </html> |