{"id":460,"date":"2010-11-16T01:00:57","date_gmt":"2010-11-16T09:00:57","guid":{"rendered":"http:\/\/www.pagetable.com\/?p=460"},"modified":"2010-11-16T01:00:57","modified_gmt":"2010-11-16T09:00:57","slug":"the-intel-80376-a-legacy-free-i386-with-a-twist","status":"publish","type":"post","link":"https:\/\/www.pagetable.com\/?p=460","title":{"rendered":"The Intel 80376 &#8211; a Legacy-Free i386 (with a Twist!)"},"content":{"rendered":"<p>25 years after the introduction of the 32 bit Intel i386 CPU, all Intel compatibles still start up (and wake up!) in 16 bit stone-age mode, and they have to be <a href=\"http:\/\/www.pagetable.com\/?p=276\">switched into 32\/64 bit mode<\/a> to be usable.<\/p>\n<p>Wouldn&#8217;t it be nice if a modern i386\/x86_64 CPU started at least in 32 bit protected mode? Can&#8217;t they make a legacy-free CPU that does not support 16 bit mode at all? Such a CPU exists, well, existed. It&#8217;s the 1989-2001 <a href=\"http:\/\/en.wikipedia.org\/wiki\/Intel_80376\">Intel 80376<\/a>, an embedded version of the Intel i386.<\/p>\n<p>The <a href=\"http:\/\/datasheets.chipdb.org\/Intel\/x86\/376\/datashts\/24018204.PDF\">datasheet<\/a> describes all the interesting differences. The 80376 does not support any 16 bit mode, so the &#8220;D&#8221; bit in segment descriptors must be set to 1 (page 25), forcing 32 bit code and data segments. 286-style descriptors are not supported either (page 27). (The 0x66 and 0x67 opcode prefixes still exists, so code can work on 16 bit registers and generate 16 bit addresses (page 14), just like an i386 in 32 bit mode.)<\/p>\n<p>Since the CPU does not support 16 bit modes, it cannot do real mode, so CR0.PE is always 1. Consequently, a 80376 starts up in 32 bit protected mode, but otherwise, startup is just like on the i386 (page 19): EIP is 0x0000FFF0, CS is 0xF000, CS.BASE is 0xFFFF0000, CS.LIMIT is 0xFFFF, and the other segment registers are 0x0000, with a base of 0x00000000 and a limit of 0xFFFF. No GDT is set up, and in order to get the system into a sane state, loading a GDT and reloading the segment registers is still necessary. Too bad they didn&#8217;t set all bases to 0, all limits to 0xFFFFFFFF and EIP to 0xFFFFFFF0.<\/p>\n<p>The 80376 is designed to be forward-compatible with the i386, so unsupported features are documented as &#8220;reserved&#8221; or &#8220;must be 0\/1&#8221;, and legacy properties like the garbled segment descriptors are unchanged. All (properly written) 80376 software should also run on an i386 (page 1) &#8211; except for the first few startup instructions of course. Intel provides the following code sequence (page 20) that is to be executed directly after RESET to distinguish between the 80376 and the i386:<\/p>\n<pre>\nsmsw bx\ntest bl, 1\njnz is_80376\n<\/pre>\n<p>This tests for CR0.PE, which is hardcoded to 1 on the 80376 and is 0 on RESET on an i386. The three instructions are bitness agnostic, i.e. the encoding is identical in 16 and 32 bit mode.<\/p>\n<p>Sounds like the perfect CPU? Well, here comes the catch: The 80376 doesn&#8217;t do paging. CR2 and CR3 don&#8217;t exist (it is undocumented whether accessing them causes an exception), CR0.PG is hardcoded to 0 (page 8) and the #PF exception does not exist (page 17). A man can dream though&#8230; a man can dream.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>25 years after the introduction of the 32 bit Intel i386 CPU, all Intel compatibles still start up (and wake up!) in 16 bit stone-age mode, and they have to be switched into 32\/64 bit mode to be usable. Wouldn&#8217;t it be nice if a modern i386\/x86_64 CPU started at least in 32 bit protected &#8230; <a title=\"The Intel 80376 &#8211; a Legacy-Free i386 (with a Twist!)\" class=\"read-more\" href=\"https:\/\/www.pagetable.com\/?p=460\" aria-label=\"Read more about The Intel 80376 &#8211; a Legacy-Free i386 (with a Twist!)\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,36,38],"tags":[],"class_list":["post-460","post","type-post","status-publish","format-standard","hentry","category-archeology","category-whines","category-x86"],"_links":{"self":[{"href":"https:\/\/www.pagetable.com\/index.php?rest_route=\/wp\/v2\/posts\/460","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pagetable.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.pagetable.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.pagetable.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pagetable.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=460"}],"version-history":[{"count":0,"href":"https:\/\/www.pagetable.com\/index.php?rest_route=\/wp\/v2\/posts\/460\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.pagetable.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=460"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pagetable.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=460"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pagetable.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=460"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}