010-fixes-1.patch 130 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490
  1. Submitted By: Jim Gifford (jim at linuxfromscratch dot org)
  2. Date: 2006-07-04
  3. Initial Package Version: 0.97
  4. Origin: Debian
  5. Upstream Status: Unknown
  6. Description: Contains various fixes and enhancements
  7. Graphics mode support
  8. Fixes for Raid Support
  9. XFS Filesystem Boot Freeze Fixes
  10. Removed 2GB Memory Limitation
  11. Freebsd support
  12. Fixes for initrd support
  13. Grub installation Fixes
  14. Linux 2.6 geometry Fixes
  15. Intel Mac Support
  16. Autoconf and aclocal updates
  17. http://trac.cross-lfs.org/browser/trunk/patches/grub-0.97-fixes-1.patch
  18. diff -Naur grub-0.97.orig/aclocal.m4 grub-0.97/aclocal.m4
  19. --- grub-0.97.orig/aclocal.m4 2005-05-07 19:41:18.000000000 -0700
  20. +++ grub-0.97/aclocal.m4 2006-07-04 00:08:22.000000000 -0700
  21. @@ -1,7 +1,7 @@
  22. -# generated automatically by aclocal 1.9.4 -*- Autoconf -*-
  23. +# generated automatically by aclocal 1.9.6 -*- Autoconf -*-
  24. -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
  25. -# Free Software Foundation, Inc.
  26. +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
  27. +# 2005 Free Software Foundation, Inc.
  28. # This file is free software; the Free Software Foundation
  29. # gives unlimited permission to copy and/or distribute it,
  30. # with or without modifications, as long as this notice is preserved.
  31. @@ -11,23 +11,11 @@
  32. # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  33. # PARTICULAR PURPOSE.
  34. -# -*- Autoconf -*-
  35. -# Copyright (C) 2002, 2003 Free Software Foundation, Inc.
  36. -# Generated from amversion.in; do not edit by hand.
  37. -
  38. -# This program is free software; you can redistribute it and/or modify
  39. -# it under the terms of the GNU General Public License as published by
  40. -# the Free Software Foundation; either version 2, or (at your option)
  41. -# any later version.
  42. -
  43. -# This program is distributed in the hope that it will be useful,
  44. -# but WITHOUT ANY WARRANTY; without even the implied warranty of
  45. -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  46. -# GNU General Public License for more details.
  47. -
  48. -# You should have received a copy of the GNU General Public License
  49. -# along with this program; if not, write to the Free Software
  50. -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  51. +# Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc.
  52. +#
  53. +# This file is free software; the Free Software Foundation
  54. +# gives unlimited permission to copy and/or distribute it,
  55. +# with or without modifications, as long as this notice is preserved.
  56. # AM_AUTOMAKE_VERSION(VERSION)
  57. # ----------------------------
  58. @@ -40,26 +28,15 @@
  59. # Call AM_AUTOMAKE_VERSION so it can be traced.
  60. # This function is AC_REQUIREd by AC_INIT_AUTOMAKE.
  61. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
  62. - [AM_AUTOMAKE_VERSION([1.9.4])])
  63. -
  64. -# AM_AUX_DIR_EXPAND
  65. -
  66. -# Copyright (C) 2001, 2003 Free Software Foundation, Inc.
  67. + [AM_AUTOMAKE_VERSION([1.9.6])])
  68. -# This program is free software; you can redistribute it and/or modify
  69. -# it under the terms of the GNU General Public License as published by
  70. -# the Free Software Foundation; either version 2, or (at your option)
  71. -# any later version.
  72. +# AM_AUX_DIR_EXPAND -*- Autoconf -*-
  73. -# This program is distributed in the hope that it will be useful,
  74. -# but WITHOUT ANY WARRANTY; without even the implied warranty of
  75. -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  76. -# GNU General Public License for more details.
  77. -
  78. -# You should have received a copy of the GNU General Public License
  79. -# along with this program; if not, write to the Free Software
  80. -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  81. -# 02111-1307, USA.
  82. +# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
  83. +#
  84. +# This file is free software; the Free Software Foundation
  85. +# gives unlimited permission to copy and/or distribute it,
  86. +# with or without modifications, as long as this notice is preserved.
  87. # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
  88. # $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to
  89. @@ -106,26 +83,16 @@
  90. am_aux_dir=`cd $ac_aux_dir && pwd`
  91. ])
  92. -# AM_CONDITIONAL -*- Autoconf -*-
  93. +# AM_CONDITIONAL -*- Autoconf -*-
  94. -# Copyright (C) 1997, 2000, 2001, 2003, 2004 Free Software Foundation, Inc.
  95. -
  96. -# This program is free software; you can redistribute it and/or modify
  97. -# it under the terms of the GNU General Public License as published by
  98. -# the Free Software Foundation; either version 2, or (at your option)
  99. -# any later version.
  100. -
  101. -# This program is distributed in the hope that it will be useful,
  102. -# but WITHOUT ANY WARRANTY; without even the implied warranty of
  103. -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  104. -# GNU General Public License for more details.
  105. -
  106. -# You should have received a copy of the GNU General Public License
  107. -# along with this program; if not, write to the Free Software
  108. -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  109. -# 02111-1307, USA.
  110. +# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005
  111. +# Free Software Foundation, Inc.
  112. +#
  113. +# This file is free software; the Free Software Foundation
  114. +# gives unlimited permission to copy and/or distribute it,
  115. +# with or without modifications, as long as this notice is preserved.
  116. -# serial 6
  117. +# serial 7
  118. # AM_CONDITIONAL(NAME, SHELL-CONDITION)
  119. # -------------------------------------
  120. @@ -149,26 +116,15 @@
  121. Usually this means the macro was only invoked conditionally.]])
  122. fi])])
  123. -# serial 7 -*- Autoconf -*-
  124. -# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004
  125. +# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
  126. # Free Software Foundation, Inc.
  127. +#
  128. +# This file is free software; the Free Software Foundation
  129. +# gives unlimited permission to copy and/or distribute it,
  130. +# with or without modifications, as long as this notice is preserved.
  131. -# This program is free software; you can redistribute it and/or modify
  132. -# it under the terms of the GNU General Public License as published by
  133. -# the Free Software Foundation; either version 2, or (at your option)
  134. -# any later version.
  135. -
  136. -# This program is distributed in the hope that it will be useful,
  137. -# but WITHOUT ANY WARRANTY; without even the implied warranty of
  138. -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  139. -# GNU General Public License for more details.
  140. -
  141. -# You should have received a copy of the GNU General Public License
  142. -# along with this program; if not, write to the Free Software
  143. -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  144. -# 02111-1307, USA.
  145. -
  146. +# serial 8
  147. # There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
  148. # written in clear, in which case automake, when reading aclocal.m4,
  149. @@ -177,7 +133,6 @@
  150. # CC etc. in the Makefile, will ask for an AC_PROG_CC use...
  151. -
  152. # _AM_DEPENDENCIES(NAME)
  153. # ----------------------
  154. # See how the compiler implements dependency checking.
  155. @@ -317,27 +272,16 @@
  156. AC_SUBST([AMDEPBACKSLASH])
  157. ])
  158. -# Generate code to set up dependency tracking. -*- Autoconf -*-
  159. -
  160. -# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004
  161. -# Free Software Foundation, Inc.
  162. -
  163. -# This program is free software; you can redistribute it and/or modify
  164. -# it under the terms of the GNU General Public License as published by
  165. -# the Free Software Foundation; either version 2, or (at your option)
  166. -# any later version.
  167. +# Generate code to set up dependency tracking. -*- Autoconf -*-
  168. -# This program is distributed in the hope that it will be useful,
  169. -# but WITHOUT ANY WARRANTY; without even the implied warranty of
  170. -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  171. -# GNU General Public License for more details.
  172. -
  173. -# You should have received a copy of the GNU General Public License
  174. -# along with this program; if not, write to the Free Software
  175. -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  176. -# 02111-1307, USA.
  177. +# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
  178. +# Free Software Foundation, Inc.
  179. +#
  180. +# This file is free software; the Free Software Foundation
  181. +# gives unlimited permission to copy and/or distribute it,
  182. +# with or without modifications, as long as this notice is preserved.
  183. -#serial 2
  184. +#serial 3
  185. # _AM_OUTPUT_DEPENDENCY_COMMANDS
  186. # ------------------------------
  187. @@ -396,30 +340,19 @@
  188. [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
  189. ])
  190. -# Do all the work for Automake. -*- Autoconf -*-
  191. +# Do all the work for Automake. -*- Autoconf -*-
  192. -# This macro actually does too much some checks are only needed if
  193. -# your package does certain things. But this isn't really a big deal.
  194. -
  195. -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
  196. +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
  197. # Free Software Foundation, Inc.
  198. +#
  199. +# This file is free software; the Free Software Foundation
  200. +# gives unlimited permission to copy and/or distribute it,
  201. +# with or without modifications, as long as this notice is preserved.
  202. -# This program is free software; you can redistribute it and/or modify
  203. -# it under the terms of the GNU General Public License as published by
  204. -# the Free Software Foundation; either version 2, or (at your option)
  205. -# any later version.
  206. -
  207. -# This program is distributed in the hope that it will be useful,
  208. -# but WITHOUT ANY WARRANTY; without even the implied warranty of
  209. -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  210. -# GNU General Public License for more details.
  211. -
  212. -# You should have received a copy of the GNU General Public License
  213. -# along with this program; if not, write to the Free Software
  214. -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  215. -# 02111-1307, USA.
  216. +# serial 12
  217. -# serial 11
  218. +# This macro actually does too much. Some checks are only needed if
  219. +# your package does certain things. But this isn't really a big deal.
  220. # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
  221. # AM_INIT_AUTOMAKE([OPTIONS])
  222. @@ -521,51 +454,27 @@
  223. done
  224. echo "timestamp for $1" >`AS_DIRNAME([$1])`/stamp-h[]$_am_stamp_count])
  225. +# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
  226. +#
  227. +# This file is free software; the Free Software Foundation
  228. +# gives unlimited permission to copy and/or distribute it,
  229. +# with or without modifications, as long as this notice is preserved.
  230. +
  231. # AM_PROG_INSTALL_SH
  232. # ------------------
  233. # Define $install_sh.
  234. -
  235. -# Copyright (C) 2001, 2003 Free Software Foundation, Inc.
  236. -
  237. -# This program is free software; you can redistribute it and/or modify
  238. -# it under the terms of the GNU General Public License as published by
  239. -# the Free Software Foundation; either version 2, or (at your option)
  240. -# any later version.
  241. -
  242. -# This program is distributed in the hope that it will be useful,
  243. -# but WITHOUT ANY WARRANTY; without even the implied warranty of
  244. -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  245. -# GNU General Public License for more details.
  246. -
  247. -# You should have received a copy of the GNU General Public License
  248. -# along with this program; if not, write to the Free Software
  249. -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  250. -# 02111-1307, USA.
  251. -
  252. AC_DEFUN([AM_PROG_INSTALL_SH],
  253. [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
  254. install_sh=${install_sh-"$am_aux_dir/install-sh"}
  255. AC_SUBST(install_sh)])
  256. -# -*- Autoconf -*-
  257. -# Copyright (C) 2003 Free Software Foundation, Inc.
  258. -
  259. -# This program is free software; you can redistribute it and/or modify
  260. -# it under the terms of the GNU General Public License as published by
  261. -# the Free Software Foundation; either version 2, or (at your option)
  262. -# any later version.
  263. -
  264. -# This program is distributed in the hope that it will be useful,
  265. -# but WITHOUT ANY WARRANTY; without even the implied warranty of
  266. -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  267. -# GNU General Public License for more details.
  268. -
  269. -# You should have received a copy of the GNU General Public License
  270. -# along with this program; if not, write to the Free Software
  271. -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  272. -# 02111-1307, USA.
  273. +# Copyright (C) 2003, 2005 Free Software Foundation, Inc.
  274. +#
  275. +# This file is free software; the Free Software Foundation
  276. +# gives unlimited permission to copy and/or distribute it,
  277. +# with or without modifications, as long as this notice is preserved.
  278. -# serial 1
  279. +# serial 2
  280. # Check whether the underlying file-system supports filenames
  281. # with a leading dot. For instance MS-DOS doesn't.
  282. @@ -580,28 +489,17 @@
  283. rmdir .tst 2>/dev/null
  284. AC_SUBST([am__leading_dot])])
  285. -# Add --enable-maintainer-mode option to configure.
  286. +# Add --enable-maintainer-mode option to configure. -*- Autoconf -*-
  287. # From Jim Meyering
  288. -# Copyright (C) 1996, 1998, 2000, 2001, 2002, 2003, 2004
  289. +# Copyright (C) 1996, 1998, 2000, 2001, 2002, 2003, 2004, 2005
  290. # Free Software Foundation, Inc.
  291. +#
  292. +# This file is free software; the Free Software Foundation
  293. +# gives unlimited permission to copy and/or distribute it,
  294. +# with or without modifications, as long as this notice is preserved.
  295. -# This program is free software; you can redistribute it and/or modify
  296. -# it under the terms of the GNU General Public License as published by
  297. -# the Free Software Foundation; either version 2, or (at your option)
  298. -# any later version.
  299. -
  300. -# This program is distributed in the hope that it will be useful,
  301. -# but WITHOUT ANY WARRANTY; without even the implied warranty of
  302. -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  303. -# GNU General Public License for more details.
  304. -
  305. -# You should have received a copy of the GNU General Public License
  306. -# along with this program; if not, write to the Free Software
  307. -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  308. -# 02111-1307, USA.
  309. -
  310. -# serial 3
  311. +# serial 4
  312. AC_DEFUN([AM_MAINTAINER_MODE],
  313. [AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
  314. @@ -620,26 +518,15 @@
  315. AU_DEFUN([jm_MAINTAINER_MODE], [AM_MAINTAINER_MODE])
  316. -# Check to see how 'make' treats includes. -*- Autoconf -*-
  317. -
  318. -# Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
  319. +# Check to see how 'make' treats includes. -*- Autoconf -*-
  320. -# This program is free software; you can redistribute it and/or modify
  321. -# it under the terms of the GNU General Public License as published by
  322. -# the Free Software Foundation; either version 2, or (at your option)
  323. -# any later version.
  324. -
  325. -# This program is distributed in the hope that it will be useful,
  326. -# but WITHOUT ANY WARRANTY; without even the implied warranty of
  327. -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  328. -# GNU General Public License for more details.
  329. -
  330. -# You should have received a copy of the GNU General Public License
  331. -# along with this program; if not, write to the Free Software
  332. -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  333. -# 02111-1307, USA.
  334. +# Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
  335. +#
  336. +# This file is free software; the Free Software Foundation
  337. +# gives unlimited permission to copy and/or distribute it,
  338. +# with or without modifications, as long as this notice is preserved.
  339. -# serial 2
  340. +# serial 3
  341. # AM_MAKE_INCLUDE()
  342. # -----------------
  343. @@ -683,27 +570,16 @@
  344. rm -f confinc confmf
  345. ])
  346. -# -*- Autoconf -*-
  347. -
  348. -
  349. -# Copyright (C) 1997, 1999, 2000, 2001, 2003 Free Software Foundation, Inc.
  350. -
  351. -# This program is free software; you can redistribute it and/or modify
  352. -# it under the terms of the GNU General Public License as published by
  353. -# the Free Software Foundation; either version 2, or (at your option)
  354. -# any later version.
  355. +# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*-
  356. -# This program is distributed in the hope that it will be useful,
  357. -# but WITHOUT ANY WARRANTY; without even the implied warranty of
  358. -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  359. -# GNU General Public License for more details.
  360. -
  361. -# You should have received a copy of the GNU General Public License
  362. -# along with this program; if not, write to the Free Software
  363. -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  364. -# 02111-1307, USA.
  365. +# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2005
  366. +# Free Software Foundation, Inc.
  367. +#
  368. +# This file is free software; the Free Software Foundation
  369. +# gives unlimited permission to copy and/or distribute it,
  370. +# with or without modifications, as long as this notice is preserved.
  371. -# serial 3
  372. +# serial 4
  373. # AM_MISSING_PROG(NAME, PROGRAM)
  374. # ------------------------------
  375. @@ -729,27 +605,16 @@
  376. fi
  377. ])
  378. +# Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
  379. +#
  380. +# This file is free software; the Free Software Foundation
  381. +# gives unlimited permission to copy and/or distribute it,
  382. +# with or without modifications, as long as this notice is preserved.
  383. +
  384. # AM_PROG_MKDIR_P
  385. # ---------------
  386. # Check whether `mkdir -p' is supported, fallback to mkinstalldirs otherwise.
  387. -
  388. -# Copyright (C) 2003, 2004 Free Software Foundation, Inc.
  389. -
  390. -# This program is free software; you can redistribute it and/or modify
  391. -# it under the terms of the GNU General Public License as published by
  392. -# the Free Software Foundation; either version 2, or (at your option)
  393. -# any later version.
  394. -
  395. -# This program is distributed in the hope that it will be useful,
  396. -# but WITHOUT ANY WARRANTY; without even the implied warranty of
  397. -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  398. -# GNU General Public License for more details.
  399. -
  400. -# You should have received a copy of the GNU General Public License
  401. -# along with this program; if not, write to the Free Software
  402. -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  403. -# 02111-1307, USA.
  404. -
  405. +#
  406. # Automake 1.8 used `mkdir -m 0755 -p --' to ensure that directories
  407. # created by `make install' are always world readable, even if the
  408. # installer happens to have an overly restrictive umask (e.g. 077).
  409. @@ -803,26 +668,15 @@
  410. fi
  411. AC_SUBST([mkdir_p])])
  412. -# Helper functions for option handling. -*- Autoconf -*-
  413. +# Helper functions for option handling. -*- Autoconf -*-
  414. -# Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
  415. -
  416. -# This program is free software; you can redistribute it and/or modify
  417. -# it under the terms of the GNU General Public License as published by
  418. -# the Free Software Foundation; either version 2, or (at your option)
  419. -# any later version.
  420. -
  421. -# This program is distributed in the hope that it will be useful,
  422. -# but WITHOUT ANY WARRANTY; without even the implied warranty of
  423. -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  424. -# GNU General Public License for more details.
  425. -
  426. -# You should have received a copy of the GNU General Public License
  427. -# along with this program; if not, write to the Free Software
  428. -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  429. -# 02111-1307, USA.
  430. +# Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
  431. +#
  432. +# This file is free software; the Free Software Foundation
  433. +# gives unlimited permission to copy and/or distribute it,
  434. +# with or without modifications, as long as this notice is preserved.
  435. -# serial 2
  436. +# serial 3
  437. # _AM_MANGLE_OPTION(NAME)
  438. # -----------------------
  439. @@ -847,28 +701,16 @@
  440. AC_DEFUN([_AM_IF_OPTION],
  441. [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
  442. -#
  443. -# Check to make sure that the build environment is sane.
  444. -#
  445. -
  446. -# Copyright (C) 1996, 1997, 2000, 2001, 2003 Free Software Foundation, Inc.
  447. -
  448. -# This program is free software; you can redistribute it and/or modify
  449. -# it under the terms of the GNU General Public License as published by
  450. -# the Free Software Foundation; either version 2, or (at your option)
  451. -# any later version.
  452. +# Check to make sure that the build environment is sane. -*- Autoconf -*-
  453. -# This program is distributed in the hope that it will be useful,
  454. -# but WITHOUT ANY WARRANTY; without even the implied warranty of
  455. -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  456. -# GNU General Public License for more details.
  457. -
  458. -# You should have received a copy of the GNU General Public License
  459. -# along with this program; if not, write to the Free Software
  460. -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  461. -# 02111-1307, USA.
  462. +# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005
  463. +# Free Software Foundation, Inc.
  464. +#
  465. +# This file is free software; the Free Software Foundation
  466. +# gives unlimited permission to copy and/or distribute it,
  467. +# with or without modifications, as long as this notice is preserved.
  468. -# serial 3
  469. +# serial 4
  470. # AM_SANITY_CHECK
  471. # ---------------
  472. @@ -911,25 +753,14 @@
  473. fi
  474. AC_MSG_RESULT(yes)])
  475. -# AM_PROG_INSTALL_STRIP
  476. -
  477. -# Copyright (C) 2001, 2003 Free Software Foundation, Inc.
  478. -
  479. -# This program is free software; you can redistribute it and/or modify
  480. -# it under the terms of the GNU General Public License as published by
  481. -# the Free Software Foundation; either version 2, or (at your option)
  482. -# any later version.
  483. -
  484. -# This program is distributed in the hope that it will be useful,
  485. -# but WITHOUT ANY WARRANTY; without even the implied warranty of
  486. -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  487. -# GNU General Public License for more details.
  488. -
  489. -# You should have received a copy of the GNU General Public License
  490. -# along with this program; if not, write to the Free Software
  491. -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  492. -# 02111-1307, USA.
  493. +# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
  494. +#
  495. +# This file is free software; the Free Software Foundation
  496. +# gives unlimited permission to copy and/or distribute it,
  497. +# with or without modifications, as long as this notice is preserved.
  498. +# AM_PROG_INSTALL_STRIP
  499. +# ---------------------
  500. # One issue with vendor `install' (even GNU) is that you can't
  501. # specify the program used to strip binaries. This is especially
  502. # annoying in cross-compiling environments, where the build's strip
  503. @@ -952,25 +783,13 @@
  504. # Check how to create a tarball. -*- Autoconf -*-
  505. -# Copyright (C) 2004 Free Software Foundation, Inc.
  506. -
  507. -# This program is free software; you can redistribute it and/or modify
  508. -# it under the terms of the GNU General Public License as published by
  509. -# the Free Software Foundation; either version 2, or (at your option)
  510. -# any later version.
  511. -
  512. -# This program is distributed in the hope that it will be useful,
  513. -# but WITHOUT ANY WARRANTY; without even the implied warranty of
  514. -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  515. -# GNU General Public License for more details.
  516. -
  517. -# You should have received a copy of the GNU General Public License
  518. -# along with this program; if not, write to the Free Software
  519. -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  520. -# 02111-1307, USA.
  521. -
  522. -# serial 1
  523. +# Copyright (C) 2004, 2005 Free Software Foundation, Inc.
  524. +#
  525. +# This file is free software; the Free Software Foundation
  526. +# gives unlimited permission to copy and/or distribute it,
  527. +# with or without modifications, as long as this notice is preserved.
  528. +# serial 2
  529. # _AM_PROG_TAR(FORMAT)
  530. # --------------------
  531. diff -Naur grub-0.97.orig/ChangeLog grub-0.97/ChangeLog
  532. --- grub-0.97.orig/ChangeLog 2005-05-07 19:47:02.000000000 -0700
  533. +++ grub-0.97/ChangeLog 2006-07-04 00:01:50.000000000 -0700
  534. @@ -1,3 +1,51 @@
  535. +2006-05-02 Pavel Roskin <[email protected]>
  536. +
  537. + * stage2/stage2.c (run_menu): Fix "savedefault" to save only top
  538. + level menu positions. Remember current position when calling a
  539. + submenu. Don't recalculate it when booting from a submenu.
  540. +
  541. + * grub/main.c (main): Make sure the boot drive number doesn't
  542. + exceed 255.
  543. +
  544. +2006-05-02 Vesa Jaaskelainen <[email protected]>
  545. +
  546. + * stage2/shared.h (vbe_mode): Back ported aligment fix from GRUB 2
  547. + to GRUB Legacy. Problem reported by Gerardo Richarte.
  548. +
  549. +2006-04-23 Robert Millan <[email protected]>
  550. +
  551. + * grub/asmstub.c (get_diskinfo): Optimize sysctl routine.
  552. +
  553. +2006-04-20 Robert Millan <[email protected]>
  554. +
  555. + Fixes for kernel of FreeBSD:
  556. + * grub/asmstub.c (get_diskinfo): Toggle "kern.geom.debugflags" sysctl
  557. + before opening a device for writing.
  558. + * util/grub-install.in: Devices don't have this "r" prefix anymore.
  559. +
  560. +2006-04-16 Yoshinori K. Okuji <[email protected]>
  561. +
  562. + * docs/multiboot.texi: Correct the offset of address
  563. + fields. Reported by Jeroen Dekkers.
  564. +
  565. +2006-03-21 Yoshinori K. Okuji <[email protected]>
  566. +
  567. + * stage2/builtins.c (setup_func): Specify the size of DEVICE to
  568. + grub_strncat instead of a strange number 256. Reported by Vitaly
  569. + Fertman <[email protected]>.
  570. +
  571. +2005-09-29 Yoshinori K. Okuji <[email protected]>
  572. +
  573. + * docs/multiboot.texi: Fix a bug in the byte order of
  574. + boot_device. I hope this won't affect any OS image.
  575. + Increased the version number to 0.6.94.
  576. +
  577. +2005-09-28 Yoshinori K. Okuji <[email protected]>
  578. +
  579. + * stage2/boot.c (load_image): Even if an OS image is an ELF
  580. + object, use the a.out kludge if MULTIBOOT_AOUT_KLUDGE is
  581. + specified.
  582. +
  583. 2005-05-08 Yoshinori K. Okuji <[email protected]>
  584. * configure.ac (AC_INIT): Upgraded to 0.97.
  585. diff -Naur grub-0.97.orig/configure grub-0.97/configure
  586. --- grub-0.97.orig/configure 2005-05-07 19:48:12.000000000 -0700
  587. +++ grub-0.97/configure 2006-07-04 00:08:05.000000000 -0700
  588. @@ -311,7 +311,7 @@
  589. # include <unistd.h>
  590. #endif"
  591. -ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar build build_cpu build_vendor build_os host host_cpu host_vendor host_os MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT PERL CC ac_ct_CC CFLAGS LDFLAGS CPPFLAGS EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CCAS RANLIB ac_ct_RANLIB STAGE1_CFLAGS STAGE2_CFLAGS GRUB_CFLAGS OBJCOPY ac_ct_OBJCOPY GRUB_LIBS CPP EGREP NETBOOT_SUPPORT_TRUE NETBOOT_SUPPORT_FALSE DISKLESS_SUPPORT_TRUE DISKLESS_SUPPORT_FALSE HERCULES_SUPPORT_TRUE HERCULES_SUPPORT_FALSE SERIAL_SUPPORT_TRUE SERIAL_SUPPORT_FALSE SERIAL_SPEED_SIMULATION_TRUE SERIAL_SPEED_SIMULATION_FALSE BUILD_EXAMPLE_KERNEL_TRUE BUILD_EXAMPLE_KERNEL_FALSE FSYS_CFLAGS NET_CFLAGS NET_EXTRAFLAGS NETBOOT_DRIVERS CCASFLAGS LIBOBJS LTLIBOBJS'
  592. +ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar build build_cpu build_vendor build_os host host_cpu host_vendor host_os MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT PERL CC ac_ct_CC CFLAGS LDFLAGS CPPFLAGS EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CCAS RANLIB ac_ct_RANLIB STAGE1_CFLAGS STAGE2_CFLAGS GRUB_CFLAGS OBJCOPY ac_ct_OBJCOPY GRUB_LIBS CPP EGREP NETBOOT_SUPPORT_TRUE NETBOOT_SUPPORT_FALSE DISKLESS_SUPPORT_TRUE DISKLESS_SUPPORT_FALSE GRAPHICS_SUPPORT_TRUE GRAPHICS_SUPPORT_FALSE HERCULES_SUPPORT_TRUE HERCULES_SUPPORT_FALSE SERIAL_SUPPORT_TRUE SERIAL_SUPPORT_FALSE SERIAL_SPEED_SIMULATION_TRUE SERIAL_SPEED_SIMULATION_FALSE BUILD_EXAMPLE_KERNEL_TRUE BUILD_EXAMPLE_KERNEL_FALSE FSYS_CFLAGS NET_CFLAGS NET_EXTRAFLAGS NETBOOT_DRIVERS CCASFLAGS LIBOBJS LTLIBOBJS'
  593. ac_subst_files=''
  594. # Initialize some variables set by options.
  595. @@ -914,6 +914,7 @@
  596. set the default memory location for WD/SMC
  597. --enable-cs-scan=LIST probe for CS89x0 base address using LIST
  598. --enable-diskless enable diskless support
  599. + --disable-graphics disable graphics terminal support
  600. --disable-hercules disable hercules terminal support
  601. --disable-serial disable serial terminal support
  602. --enable-serial-speed-simulation
  603. @@ -5966,6 +5967,22 @@
  604. fi
  605. +# Check whether --enable-graphics or --disable-graphics was given.
  606. +if test "${enable_graphics+set}" = set; then
  607. + enableval="$enable_graphics"
  608. +
  609. +fi;
  610. +
  611. +
  612. +if test "x$enable_graphics" != xno; then
  613. + GRAPHICS_SUPPORT_TRUE=
  614. + GRAPHICS_SUPPORT_FALSE='#'
  615. +else
  616. + GRAPHICS_SUPPORT_TRUE='#'
  617. + GRAPHICS_SUPPORT_FALSE=
  618. +fi
  619. +
  620. +
  621. # Check whether --enable-hercules or --disable-hercules was given.
  622. if test "${enable_hercules+set}" = set; then
  623. enableval="$enable_hercules"
  624. @@ -6270,6 +6287,13 @@
  625. Usually this means the macro was only invoked conditionally." >&2;}
  626. { (exit 1); exit 1; }; }
  627. fi
  628. +if test -z "${GRAPHICS_SUPPORT_TRUE}" && test -z "${GRAPHICS_SUPPORT_FALSE}"; then
  629. + { { echo "$as_me:$LINENO: error: conditional \"GRAPHICS_SUPPORT\" was never defined.
  630. +Usually this means the macro was only invoked conditionally." >&5
  631. +echo "$as_me: error: conditional \"GRAPHICS_SUPPORT\" was never defined.
  632. +Usually this means the macro was only invoked conditionally." >&2;}
  633. + { (exit 1); exit 1; }; }
  634. +fi
  635. if test -z "${HERCULES_SUPPORT_TRUE}" && test -z "${HERCULES_SUPPORT_FALSE}"; then
  636. { { echo "$as_me:$LINENO: error: conditional \"HERCULES_SUPPORT\" was never defined.
  637. Usually this means the macro was only invoked conditionally." >&5
  638. @@ -6907,6 +6931,8 @@
  639. s,@NETBOOT_SUPPORT_FALSE@,$NETBOOT_SUPPORT_FALSE,;t t
  640. s,@DISKLESS_SUPPORT_TRUE@,$DISKLESS_SUPPORT_TRUE,;t t
  641. s,@DISKLESS_SUPPORT_FALSE@,$DISKLESS_SUPPORT_FALSE,;t t
  642. +s,@GRAPHICS_SUPPORT_TRUE@,$GRAPHICS_SUPPORT_TRUE,;t t
  643. +s,@GRAPHICS_SUPPORT_FALSE@,$GRAPHICS_SUPPORT_FALSE,;t t
  644. s,@HERCULES_SUPPORT_TRUE@,$HERCULES_SUPPORT_TRUE,;t t
  645. s,@HERCULES_SUPPORT_FALSE@,$HERCULES_SUPPORT_FALSE,;t t
  646. s,@SERIAL_SUPPORT_TRUE@,$SERIAL_SUPPORT_TRUE,;t t
  647. diff -Naur grub-0.97.orig/configure.ac grub-0.97/configure.ac
  648. --- grub-0.97.orig/configure.ac 2005-05-07 19:36:03.000000000 -0700
  649. +++ grub-0.97/configure.ac 2006-07-03 23:58:41.000000000 -0700
  650. @@ -595,6 +595,11 @@
  651. [ --enable-diskless enable diskless support])
  652. AM_CONDITIONAL(DISKLESS_SUPPORT, test "x$enable_diskless" = xyes)
  653. +dnl Graphical splashscreen support
  654. +AC_ARG_ENABLE(graphics,
  655. + [ --disable-graphics disable graphics terminal support])
  656. +AM_CONDITIONAL(GRAPHICS_SUPPORT, test "x$enable_graphics" != xno)
  657. +
  658. dnl Hercules terminal
  659. AC_ARG_ENABLE(hercules,
  660. [ --disable-hercules disable hercules terminal support])
  661. diff -Naur grub-0.97.orig/docs/grub.8 grub-0.97/docs/grub.8
  662. --- grub-0.97.orig/docs/grub.8 2005-05-07 19:48:56.000000000 -0700
  663. +++ grub-0.97/docs/grub.8 2006-07-04 00:01:50.000000000 -0700
  664. @@ -1,5 +1,5 @@
  665. .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.23.
  666. -.TH GRUB "8" "May 2005" "grub (GNU GRUB 0.97)" FSF
  667. +.TH GRUB "8" "September 2005" "grub (GNU GRUB 0.97)" FSF
  668. .SH NAME
  669. grub \- the grub shell
  670. .SH SYNOPSIS
  671. diff -Naur grub-0.97.orig/docs/grub.texi grub-0.97/docs/grub.texi
  672. --- grub-0.97.orig/docs/grub.texi 2005-05-07 19:59:59.000000000 -0700
  673. +++ grub-0.97/docs/grub.texi 2006-07-04 00:00:54.000000000 -0700
  674. @@ -2199,6 +2199,7 @@
  675. * rarp:: Initialize a network device via RARP
  676. * serial:: Set up a serial device
  677. * setkey:: Configure the key map
  678. +* splashimage:: Use a splash image
  679. * terminal:: Choose a terminal
  680. * terminfo:: Define escape sequences for a terminal
  681. * tftpserver:: Specify a TFTP server
  682. @@ -2578,6 +2579,16 @@
  683. @end deffn
  684. +@node splashimage
  685. +@subsection splashimage
  686. +
  687. +@deffn Command splashimage file
  688. +Select an image to use as the background image. This should be
  689. +specified using normal GRUB device naming syntax. The format of the
  690. +file is a gzipped xpm which is 640x480 with a 14 color palette.
  691. +@end deffn
  692. +
  693. +
  694. @node terminal
  695. @subsection terminal
  696. @@ -2685,6 +2696,7 @@
  697. * module:: Load a module
  698. * modulenounzip:: Load a module without decompression
  699. * pause:: Wait for a key press
  700. +* print:: Print a message
  701. * quit:: Exit from the grub shell
  702. * reboot:: Reboot your computer
  703. * read:: Read data from memory
  704. @@ -3091,6 +3103,16 @@
  705. @end deffn
  706. +@node print
  707. +@subsection print
  708. +
  709. +@deffn Command print message @dots{}
  710. +Print the @var{message}. Note that placing @key{^G} (ASCII code 7) in the
  711. +message will cause the speaker to emit the standard beep sound, which is
  712. +useful for visually impaired people.
  713. +@end deffn
  714. +
  715. +
  716. @node quit
  717. @subsection quit
  718. diff -Naur grub-0.97.orig/docs/multiboot.texi grub-0.97/docs/multiboot.texi
  719. --- grub-0.97.orig/docs/multiboot.texi 2003-07-09 04:45:36.000000000 -0700
  720. +++ grub-0.97/docs/multiboot.texi 2006-07-04 00:01:50.000000000 -0700
  721. @@ -25,7 +25,7 @@
  722. @ifinfo
  723. Copyright @copyright{} 1995, 96 Bryan Ford <baford@@cs.utah.edu>
  724. Copyright @copyright{} 1995, 96 Erich Stefan Boleyn <erich@@uruk.org>
  725. -Copyright @copyright{} 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
  726. +Copyright @copyright{} 1999, 2000, 2001, 2002, 2005, 2006 Free Software Foundation, Inc.
  727. Permission is granted to make and distribute verbatim copies of
  728. this manual provided the copyright notice and this permission notice
  729. @@ -57,7 +57,7 @@
  730. @vskip 0pt plus 1filll
  731. Copyright @copyright{} 1995, 96 Bryan Ford <baford@@cs.utah.edu>
  732. Copyright @copyright{} 1995, 96 Erich Stefan Boleyn <erich@@uruk.org>
  733. -Copyright @copyright{} 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
  734. +Copyright @copyright{} 1999, 2000, 2001, 2002, 2005, 2006 Free Software Foundation, Inc.
  735. Permission is granted to make and distribute verbatim copies of
  736. this manual provided the copyright notice and this permission notice
  737. @@ -80,7 +80,7 @@
  738. @top Multiboot Specification
  739. This file documents Multiboot Specification, the proposal for the boot
  740. -sequence standard. This edition documents version 0.6.93.
  741. +sequence standard. This edition documents version 0.6.94.
  742. @end ifnottex
  743. @menu
  744. @@ -426,7 +426,7 @@
  745. kernel.
  746. If bit 16 in the @samp{flags} word is set, then the fields at offsets
  747. -8-24 in the Multiboot header are valid, and the boot loader should use
  748. +12-28 in the Multiboot header are valid, and the boot loader should use
  749. them instead of the fields in the actual executable header to calculate
  750. where to load the OS image. This information does not need to be
  751. provided if the kernel image is in @sc{elf} format, but it @emph{must}
  752. @@ -677,7 +677,7 @@
  753. @example
  754. @group
  755. +-------+-------+-------+-------+
  756. -| drive | part1 | part2 | part3 |
  757. +| part3 | part2 | part1 | drive |
  758. +-------+-------+-------+-------+
  759. @end group
  760. @end example
  761. @@ -1199,6 +1199,13 @@
  762. @email{bug-grub@@gnu.org}, from Bryan Ford and Erich Stefan Boleyn.
  763. @end itemize
  764. +@item
  765. +The byte order of the @samp{boot_device} in Multiboot information is
  766. +reversed. This was a mistake.
  767. +
  768. +@item
  769. +The offset of the address fields were wrong.
  770. +
  771. @item 0.6
  772. @itemize @bullet
  773. @item
  774. diff -Naur grub-0.97.orig/grub/asmstub.c grub-0.97/grub/asmstub.c
  775. --- grub-0.97.orig/grub/asmstub.c 2005-02-16 12:45:14.000000000 -0800
  776. +++ grub-0.97/grub/asmstub.c 2006-07-04 00:01:50.000000000 -0700
  777. @@ -42,6 +42,12 @@
  778. #include <sys/time.h>
  779. #include <termios.h>
  780. #include <signal.h>
  781. +#include <sys/mman.h>
  782. +
  783. +#include <limits.h>
  784. +#ifndef PAGESIZE
  785. +#define PAGESIZE 4096
  786. +#endif
  787. #ifdef __linux__
  788. # include <sys/ioctl.h> /* ioctl */
  789. @@ -55,6 +61,10 @@
  790. # endif /* ! BLKFLSBUF */
  791. #endif /* __linux__ */
  792. +#if defined(__FreeBSD_kernel__) || defined(__FreeBSD__)
  793. +# include <sys/sysctl.h>
  794. +#endif
  795. +
  796. /* We want to prevent any circularararity in our stubs, as well as
  797. libc name clashes. */
  798. #define WITHOUT_LIBC_STUBS 1
  799. @@ -144,6 +154,22 @@
  800. assert (grub_scratch_mem == 0);
  801. scratch = malloc (0x100000 + EXTENDED_MEMSIZE + 15);
  802. assert (scratch);
  803. +
  804. + {
  805. + char *p;
  806. + int ret;
  807. +
  808. + /* Align to a multiple of PAGESIZE, assumed to be a power of two. */
  809. + p = (char *) (((long) scratch) & ~(PAGESIZE - 1));
  810. +
  811. + /* The simulated stack needs to be executable, since GCC uses stack
  812. + * trampolines to implement nested functions.
  813. + */
  814. + ret = mprotect (p, 0x100000 + EXTENDED_MEMSIZE + 15,
  815. + PROT_READ | PROT_WRITE | PROT_EXEC);
  816. + assert (ret == 0);
  817. + }
  818. +
  819. grub_scratch_mem = (char *) ((((int) scratch) >> 4) << 4);
  820. /* FIXME: simulate the memory holes using mprot, if available. */
  821. @@ -777,7 +803,39 @@
  822. /* Open read/write, or read-only if that failed. */
  823. if (! read_only)
  824. - disks[drive].flags = open (devname, O_RDWR);
  825. + {
  826. +/* By default, kernel of FreeBSD does not allow overwriting MBR */
  827. +#if defined(__FreeBSD_kernel__) || defined(__FreeBSD__)
  828. +#define GEOM_SYSCTL "kern.geom.debugflags"
  829. + int old_flags, flags;
  830. + size_t sizeof_int = sizeof (int);
  831. +
  832. + if (sysctlbyname (GEOM_SYSCTL, &old_flags, &sizeof_int, NULL, 0) != 0)
  833. + grub_printf ("failed to get " GEOM_SYSCTL "sysctl: %s\n", strerror (errno));
  834. +
  835. + if ((old_flags & 0x10) == 0)
  836. + {
  837. + /* "allow foot shooting", see geom(4) */
  838. + flags = old_flags | 0x10;
  839. +
  840. + if (sysctlbyname (GEOM_SYSCTL, NULL, NULL, &flags, sizeof (int)) != 0)
  841. + {
  842. + flags = old_flags;
  843. + grub_printf ("failed to set " GEOM_SYSCTL "sysctl: %s\n", strerror (errno));
  844. + }
  845. + }
  846. + else
  847. + flags = old_flags;
  848. +#endif
  849. + disks[drive].flags = open (devname, O_RDWR);
  850. +#if defined(__FreeBSD_kernel__) || defined(__FreeBSD__)
  851. + if (flags != old_flags)
  852. + {
  853. + if (sysctlbyname (GEOM_SYSCTL, NULL, NULL, &old_flags, sizeof (int)) != 0)
  854. + grub_printf ("failed to set " GEOM_SYSCTL "sysctl: %s\n", strerror (errno));
  855. + }
  856. +#endif
  857. + }
  858. if (disks[drive].flags == -1)
  859. {
  860. diff -Naur grub-0.97.orig/grub/main.c grub-0.97/grub/main.c
  861. --- grub-0.97.orig/grub/main.c 2003-07-09 04:45:36.000000000 -0700
  862. +++ grub-0.97/grub/main.c 2006-07-04 00:01:50.000000000 -0700
  863. @@ -32,6 +32,7 @@
  864. #define WITHOUT_LIBC_STUBS 1
  865. #include <shared.h>
  866. #include <term.h>
  867. +#include <device.h>
  868. char *program_name = 0;
  869. int use_config_file = 1;
  870. @@ -192,6 +193,12 @@
  871. perror ("strtoul");
  872. exit (1);
  873. }
  874. + if (boot_drive >= NUM_DISKS)
  875. + {
  876. + fprintf (stderr, "boot_drive should be from 0 to %d\n",
  877. + NUM_DISKS - 1);
  878. + exit (1);
  879. + }
  880. break;
  881. case OPT_NO_CONFIG_FILE:
  882. diff -Naur grub-0.97.orig/lib/device.c grub-0.97/lib/device.c
  883. --- grub-0.97.orig/lib/device.c 2005-03-27 15:14:25.000000000 -0800
  884. +++ grub-0.97/lib/device.c 2006-07-04 00:00:44.000000000 -0700
  885. @@ -131,6 +131,152 @@
  886. #include <shared.h>
  887. #include <device.h>
  888. +#if defined(__linux__)
  889. +/* The 2.6 kernel has removed all of the geometry handling for IDE drives
  890. + * that did fixups for LBA, etc. This means that the geometry we get
  891. + * with the ioctl has a good chance of being wrong. So, we get to
  892. + * also know about partition tables and try to read what the geometry
  893. + * is there. *grumble* Very closely based on code from cfdisk
  894. + */
  895. +static void get_kernel_geometry(int fd, long long *cyl, int *heads, int *sectors) {
  896. + struct hd_geometry hdg;
  897. +
  898. + if (ioctl (fd, HDIO_GETGEO, &hdg))
  899. + return;
  900. +
  901. + *cyl = hdg.cylinders;
  902. + *heads = hdg.heads;
  903. + *sectors = hdg.sectors;
  904. +}
  905. +
  906. +struct partition {
  907. + unsigned char boot_ind; /* 0x80 - active */
  908. + unsigned char head; /* starting head */
  909. + unsigned char sector; /* starting sector */
  910. + unsigned char cyl; /* starting cylinder */
  911. + unsigned char sys_ind; /* What partition type */
  912. + unsigned char end_head; /* end head */
  913. + unsigned char end_sector; /* end sector */
  914. + unsigned char end_cyl; /* end cylinder */
  915. + unsigned char start4[4]; /* starting sector counting from 0 */
  916. + unsigned char size4[4]; /* nr of sectors in partition */
  917. +};
  918. +
  919. +#define ALIGNMENT 2
  920. +typedef union {
  921. + struct {
  922. + unsigned char align[ALIGNMENT];
  923. + unsigned char b[SECTOR_SIZE];
  924. + } c;
  925. + struct {
  926. + unsigned char align[ALIGNMENT];
  927. + unsigned char buffer[0x1BE];
  928. + struct partition part[4];
  929. + unsigned char magicflag[2];
  930. + } p;
  931. +} partition_table;
  932. +
  933. +#define PART_TABLE_FLAG0 0x55
  934. +#define PART_TABLE_FLAG1 0xAA
  935. +
  936. +static void
  937. +get_partition_table_geometry(partition_table *bufp, long long *cyl, int *heads,
  938. + int *sectors) {
  939. + struct partition *p;
  940. + int i,h,s,hh,ss;
  941. + int first = 1;
  942. + int bad = 0;
  943. +
  944. + if (bufp->p.magicflag[0] != PART_TABLE_FLAG0 ||
  945. + bufp->p.magicflag[1] != PART_TABLE_FLAG1) {
  946. + /* Matthew Wilcox: slightly friendlier version of
  947. + fatal(_("Bad signature on partition table"), 3);
  948. + */
  949. + fprintf(stderr, "Unknown partition table signature\n");
  950. + return;
  951. + }
  952. +
  953. + hh = ss = 0;
  954. + for (i=0; i<4; i++) {
  955. + p = &(bufp->p.part[i]);
  956. + if (p->sys_ind != 0) {
  957. + h = p->end_head + 1;
  958. + s = (p->end_sector & 077);
  959. + if (first) {
  960. + hh = h;
  961. + ss = s;
  962. + first = 0;
  963. + } else if (hh != h || ss != s)
  964. + bad = 1;
  965. + }
  966. + }
  967. +
  968. + if (!first && !bad) {
  969. + *heads = hh;
  970. + *sectors = ss;
  971. + }
  972. +}
  973. +
  974. +static long long my_lseek (unsigned int fd, long long offset,
  975. + unsigned int origin)
  976. +{
  977. +#if defined(__linux__) && (!defined(__GLIBC__) || \
  978. + ((__GLIBC__ < 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ < 1))))
  979. + /* Maybe libc doesn't have large file support. */
  980. + loff_t offset, result;
  981. + static int _llseek (uint filedes, ulong hi, ulong lo,
  982. + loff_t *res, uint wh);
  983. + _syscall5 (int, _llseek, uint, filedes, ulong, hi, ulong, lo,
  984. + loff_t *, res, uint, wh);
  985. +
  986. + if (_llseek (fd, offset >> 32, offset & 0xffffffff, &result, SEEK_SET) < 0)
  987. + return (long long) -1;
  988. + return result;
  989. +#else
  990. + return lseek(fd, offset, SEEK_SET);
  991. +#endif
  992. +}
  993. +
  994. +static void get_linux_geometry (int fd, struct geometry *geom) {
  995. + long long kern_cyl = 0; int kern_head = 0, kern_sectors = 0;
  996. + long long pt_cyl = 0; int pt_head = 0, pt_sectors = 0;
  997. + partition_table bufp;
  998. + char *buff, *buf_unaligned;
  999. +
  1000. + buf_unaligned = malloc(sizeof(partition_table) + 4095);
  1001. + buff = (char *) (((unsigned long)buf_unaligned + 4096 - 1) &
  1002. + (~(4096-1)));
  1003. +
  1004. + get_kernel_geometry(fd, &kern_cyl, &kern_head, &kern_sectors);
  1005. +
  1006. + if (my_lseek (fd, 0*SECTOR_SIZE, SEEK_SET) < 0) {
  1007. + fprintf(stderr, "Unable to seek");
  1008. + }
  1009. +
  1010. + if (read(fd, buff, SECTOR_SIZE) == SECTOR_SIZE) {
  1011. + memcpy(bufp.c.b, buff, SECTOR_SIZE);
  1012. + get_partition_table_geometry(&bufp, &pt_cyl, &pt_head, &pt_sectors);
  1013. + } else {
  1014. + fprintf(stderr, "Unable to read partition table: %s\n", strerror(errno));
  1015. + }
  1016. +
  1017. + if (pt_head && pt_sectors) {
  1018. + int cyl_size;
  1019. +
  1020. + geom->heads = pt_head;
  1021. + geom->sectors = pt_sectors;
  1022. + cyl_size = pt_head * pt_sectors;
  1023. + geom->cylinders = geom->total_sectors/cyl_size;
  1024. + } else {
  1025. + geom->heads = kern_head;
  1026. + geom->sectors = kern_sectors;
  1027. + geom->cylinders = kern_cyl;
  1028. + }
  1029. +
  1030. + return;
  1031. +}
  1032. +#endif
  1033. +
  1034. /* Get the geometry of a drive DRIVE. */
  1035. void
  1036. get_drive_geometry (struct geometry *geom, char **map, int drive)
  1037. @@ -151,21 +297,16 @@
  1038. #if defined(__linux__)
  1039. /* Linux */
  1040. {
  1041. - struct hd_geometry hdg;
  1042. unsigned long nr;
  1043. -
  1044. - if (ioctl (fd, HDIO_GETGEO, &hdg))
  1045. - goto fail;
  1046. if (ioctl (fd, BLKGETSIZE, &nr))
  1047. goto fail;
  1048. /* Got the geometry, so save it. */
  1049. - geom->cylinders = hdg.cylinders;
  1050. - geom->heads = hdg.heads;
  1051. - geom->sectors = hdg.sectors;
  1052. geom->total_sectors = nr;
  1053. -
  1054. + get_linux_geometry(fd, geom);
  1055. + if (!geom->heads && !geom->cylinders && !geom->sectors)
  1056. + goto fail;
  1057. goto success;
  1058. }
  1059. @@ -403,6 +544,18 @@
  1060. }
  1061. static void
  1062. +get_cciss_disk_name (char *name, int controller, int drive)
  1063. +{
  1064. + sprintf (name, "/dev/cciss/c%dd%d", controller, drive);
  1065. +}
  1066. +
  1067. +static void
  1068. +get_ida_disk_name (char *name, int controller, int drive)
  1069. +{
  1070. + sprintf (name, "/dev/ida/c%dd%d", controller, drive);
  1071. +}
  1072. +
  1073. +static void
  1074. get_ataraid_disk_name (char *name, int unit)
  1075. {
  1076. sprintf (name, "/dev/ataraid/d%c", unit + '0');
  1077. @@ -801,6 +954,74 @@
  1078. }
  1079. }
  1080. }
  1081. +
  1082. + /* This is for CCISS, its like the DAC960 - we have
  1083. + /dev/cciss/<controller>d<logical drive>p<partition>
  1084. +
  1085. + It currently supports up to 3 controllers, 10 logical volumes
  1086. + and 10 partitions
  1087. +
  1088. + Code gratuitously copied from DAC960 above.
  1089. + Horms <[email protected]> 23rd July 2004
  1090. + */
  1091. + {
  1092. + int controller, drive;
  1093. +
  1094. + for (controller = 0; controller < 2; controller++)
  1095. + {
  1096. + for (drive = 0; drive < 9; drive++)
  1097. + {
  1098. + char name[24];
  1099. +
  1100. + get_cciss_disk_name (name, controller, drive);
  1101. + if (check_device (name))
  1102. + {
  1103. + (*map)[num_hd + 0x80] = strdup (name);
  1104. + assert ((*map)[num_hd + 0x80]);
  1105. +
  1106. + /* If the device map file is opened, write the map. */
  1107. + if (fp)
  1108. + fprintf (fp, "(hd%d)\t%s\n", num_hd, name);
  1109. +
  1110. + num_hd++;
  1111. + }
  1112. + }
  1113. + }
  1114. + }
  1115. +
  1116. + /* This is for Compaq Smart Array, its like the DAC960 - we have
  1117. + /dev/ida/<controller>d<logical drive>p<partition>
  1118. +
  1119. + It currently supports up to 3 controllers, 10 logical volumes
  1120. + and 15 partitions
  1121. +
  1122. + Code gratuitously copied from DAC960 above.
  1123. + Piotr Roszatycki <[email protected]>
  1124. + */
  1125. + {
  1126. + int controller, drive;
  1127. +
  1128. + for (controller = 0; controller < 2; controller++)
  1129. + {
  1130. + for (drive = 0; drive < 9; drive++)
  1131. + {
  1132. + char name[24];
  1133. +
  1134. + get_ida_disk_name (name, controller, drive);
  1135. + if (check_device (name))
  1136. + {
  1137. + (*map)[num_hd + 0x80] = strdup (name);
  1138. + assert ((*map)[num_hd + 0x80]);
  1139. +
  1140. + /* If the device map file is opened, write the map. */
  1141. + if (fp)
  1142. + fprintf (fp, "(hd%d)\t%s\n", num_hd, name);
  1143. +
  1144. + num_hd++;
  1145. + }
  1146. + }
  1147. + }
  1148. + }
  1149. #endif /* __linux__ */
  1150. /* OK, close the device map file if opened. */
  1151. @@ -844,6 +1065,7 @@
  1152. {
  1153. char dev[PATH_MAX]; /* XXX */
  1154. int fd;
  1155. + off_t offset = (off_t) sector * (off_t) SECTOR_SIZE;
  1156. if ((partition & 0x00FF00) != 0x00FF00)
  1157. {
  1158. @@ -861,8 +1083,14 @@
  1159. if (strcmp (dev + strlen(dev) - 5, "/disc") == 0)
  1160. strcpy (dev + strlen(dev) - 5, "/part");
  1161. }
  1162. - sprintf (dev + strlen(dev), "%d", ((partition >> 16) & 0xFF) + 1);
  1163. -
  1164. + sprintf (dev + strlen(dev), "%s%d",
  1165. + /* Compaq smart and others */
  1166. + (strncmp(dev, "/dev/ida/", 9) == 0 ||
  1167. + strncmp(dev, "/dev/ataraid/", 13) == 0 ||
  1168. + strncmp(dev, "/dev/cciss/", 11) == 0 ||
  1169. + strncmp(dev, "/dev/rd/", 8) == 0) ? "p" : "",
  1170. + ((partition >> 16) & 0xFF) + 1);
  1171. +
  1172. /* Open the partition. */
  1173. fd = open (dev, O_RDWR);
  1174. if (fd < 0)
  1175. @@ -870,35 +1098,13 @@
  1176. errnum = ERR_NO_PART;
  1177. return 0;
  1178. }
  1179. -
  1180. -#if defined(__linux__) && (!defined(__GLIBC__) || \
  1181. - ((__GLIBC__ < 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ < 1))))
  1182. - /* Maybe libc doesn't have large file support. */
  1183. - {
  1184. - loff_t offset, result;
  1185. - static int _llseek (uint filedes, ulong hi, ulong lo,
  1186. - loff_t *res, uint wh);
  1187. - _syscall5 (int, _llseek, uint, filedes, ulong, hi, ulong, lo,
  1188. - loff_t *, res, uint, wh);
  1189. - offset = (loff_t) sector * (loff_t) SECTOR_SIZE;
  1190. - if (_llseek (fd, offset >> 32, offset & 0xffffffff, &result, SEEK_SET))
  1191. - {
  1192. - errnum = ERR_DEV_VALUES;
  1193. - return 0;
  1194. - }
  1195. - }
  1196. -#else
  1197. - {
  1198. - off_t offset = (off_t) sector * (off_t) SECTOR_SIZE;
  1199. - if (lseek (fd, offset, SEEK_SET) != offset)
  1200. - {
  1201. - errnum = ERR_DEV_VALUES;
  1202. - return 0;
  1203. - }
  1204. - }
  1205. -#endif
  1206. + if (my_lseek(fd, offset, SEEK_SET) != offset)
  1207. + {
  1208. + errnum = ERR_DEV_VALUES;
  1209. + return 0;
  1210. + }
  1211. if (write (fd, buf, size * SECTOR_SIZE) != (size * SECTOR_SIZE))
  1212. {
  1213. diff -Naur grub-0.97.orig/stage2/asm.S grub-0.97/stage2/asm.S
  1214. --- grub-0.97.orig/stage2/asm.S 2004-06-19 09:55:22.000000000 -0700
  1215. +++ grub-0.97/stage2/asm.S 2006-07-04 00:01:19.000000000 -0700
  1216. @@ -1651,7 +1651,29 @@
  1217. jnz 3f
  1218. ret
  1219. -3: /* use keyboard controller */
  1220. +3: /*
  1221. + * try to switch gateA20 using PORT92, the "Fast A20 and Init"
  1222. + * register
  1223. + */
  1224. + mov $0x92, %dx
  1225. + inb %dx, %al
  1226. + /* skip the port92 code if it's unimplemented (read returns 0xff) */
  1227. + cmpb $0xff, %al
  1228. + jz 6f
  1229. +
  1230. + /* set or clear bit1, the ALT_A20_GATE bit */
  1231. + movb 4(%esp), %ah
  1232. + testb %ah, %ah
  1233. + jz 4f
  1234. + orb $2, %al
  1235. + jmp 5f
  1236. +4: and $0xfd, %al
  1237. +
  1238. + /* clear the INIT_NOW bit don't accidently reset the machine */
  1239. +5: and $0xfe, %al
  1240. + outb %al, %dx
  1241. +
  1242. +6: /* use keyboard controller */
  1243. pushl %eax
  1244. call gloop1
  1245. @@ -1661,9 +1683,12 @@
  1246. gloopint1:
  1247. inb $K_STATUS
  1248. + cmpb $0xff, %al
  1249. + jz gloopint1_done
  1250. andb $K_IBUF_FUL, %al
  1251. jnz gloopint1
  1252. +gloopint1_done:
  1253. movb $KB_OUTPUT_MASK, %al
  1254. cmpb $0, 0x8(%esp)
  1255. jz gdoit
  1256. @@ -1684,6 +1709,8 @@
  1257. gloop1:
  1258. inb $K_STATUS
  1259. + cmpb $0xff, %al
  1260. + jz gloop2ret
  1261. andb $K_IBUF_FUL, %al
  1262. jnz gloop1
  1263. @@ -1991,6 +2018,11 @@
  1264. ENTRY(console_getkey)
  1265. push %ebp
  1266. +wait_for_key:
  1267. + call EXT_C(console_checkkey)
  1268. + incl %eax
  1269. + jz wait_for_key
  1270. +
  1271. call EXT_C(prot_to_real)
  1272. .code16
  1273. @@ -2216,7 +2248,304 @@
  1274. pop %ebx
  1275. pop %ebp
  1276. ret
  1277. -
  1278. +
  1279. +
  1280. +/* graphics mode functions */
  1281. +#ifdef SUPPORT_GRAPHICS
  1282. +VARIABLE(cursorX)
  1283. +.word 0
  1284. +VARIABLE(cursorY)
  1285. +.word 0
  1286. +VARIABLE(cursorCount)
  1287. +.word 0
  1288. +VARIABLE(cursorBuf)
  1289. +.byte 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
  1290. +
  1291. +
  1292. +/*
  1293. + * set_int1c_handler(void)
  1294. + */
  1295. +ENTRY(set_int1c_handler)
  1296. + pushl %edi
  1297. +
  1298. + /* save the original int1c handler */
  1299. + movl $0x70, %edi
  1300. + movw (%edi), %ax
  1301. + movw %ax, ABS(int1c_offset)
  1302. + movw 2(%edi), %ax
  1303. + movw %ax, ABS(int1c_segment)
  1304. +
  1305. + /* save the new int1c handler */
  1306. + movw $ABS(int1c_handler), %ax
  1307. + movw %ax, (%edi)
  1308. + xorw %ax, %ax
  1309. + movw %ax, 2(%edi)
  1310. +
  1311. + popl %edi
  1312. + ret
  1313. +
  1314. +
  1315. +/*
  1316. + * unset_int1c_handler(void)
  1317. + */
  1318. +ENTRY(unset_int1c_handler)
  1319. + pushl %edi
  1320. +
  1321. + /* check if int1c_handler is set */
  1322. + movl $0x70, %edi
  1323. + movw $ABS(int1c_handler), %ax
  1324. + cmpw %ax, (%edi)
  1325. + jne int1c_1
  1326. + xorw %ax, %ax
  1327. + cmpw %ax, 2(%edi)
  1328. + jne int1c_1
  1329. +
  1330. + /* restore the original */
  1331. + movw ABS(int1c_offset), %ax
  1332. + movw %ax, (%edi)
  1333. + movw ABS(int1c_segment), %ax
  1334. + movw %ax, 2(%edi)
  1335. +
  1336. +int1c_1:
  1337. + popl %edi
  1338. + ret
  1339. +
  1340. +
  1341. +/*
  1342. + * blinks graphics cursor
  1343. + */
  1344. + .code16
  1345. +write_data:
  1346. + movw $0, %ax
  1347. + movw %ax, %ds
  1348. +
  1349. + mov $0xA000, %ax /* video in es:di */
  1350. + mov %ax, %es
  1351. + mov $80, %ax
  1352. + movw $ABS(cursorY), %si
  1353. + mov %ds:(%si), %bx
  1354. + mul %bx
  1355. + movw $ABS(cursorX), %si
  1356. + mov %ds:(%si), %bx
  1357. + shr $3, %bx /* %bx /= 8 */
  1358. + add %bx, %ax
  1359. + mov %ax, %di
  1360. +
  1361. + movw $ABS(cursorBuf), %si /* fontBuf in ds:si */
  1362. +
  1363. + /* prepare for data moving */
  1364. + mov $16, %dx /* altura da fonte */
  1365. + mov $80, %bx /* bytes por linha */
  1366. +
  1367. +write_loop:
  1368. + movb %ds:(%si), %al
  1369. + xorb $0xff, %al
  1370. + movb %al, %ds:(%si) /* invert cursorBuf */
  1371. + movb %al, %es:(%di) /* write to video */
  1372. + add %bx, %di
  1373. + inc %si
  1374. + dec %dx
  1375. + jg write_loop
  1376. + ret
  1377. +
  1378. +int1c_handler:
  1379. + pusha
  1380. + mov $0, %ax
  1381. + mov %ax, %ds
  1382. + mov $ABS(cursorCount), %si
  1383. + mov %ds:(%si), %ax
  1384. + inc %ax
  1385. + mov %ax, %ds:(%si)
  1386. + cmp $9, %ax
  1387. + jne int1c_done
  1388. +
  1389. + mov $0, %ax
  1390. + mov %ax, %ds:(%si)
  1391. + call write_data
  1392. +
  1393. +int1c_done:
  1394. + popa
  1395. + iret
  1396. + /* call previous int1c handler */
  1397. + /* ljmp */
  1398. + .byte 0xea
  1399. +int1c_offset: .word 0
  1400. +int1c_segment: .word 0
  1401. + .code32
  1402. +
  1403. +
  1404. +/*
  1405. + * unsigned char set_videomode(unsigned char mode)
  1406. + * BIOS call "INT 10H Function 0h" to set video mode
  1407. + * Call with %ah = 0x0
  1408. + * %al = video mode
  1409. + * Returns old videomode.
  1410. + */
  1411. +ENTRY(set_videomode)
  1412. + pushl %ebp
  1413. + movl %esp,%ebp
  1414. + pushl %ebx
  1415. + pushl %ecx
  1416. +
  1417. + movb 8(%ebp), %cl
  1418. +
  1419. + call EXT_C(prot_to_real)
  1420. + .code16
  1421. +
  1422. + xorb %al, %al
  1423. + movb $0xf, %ah
  1424. + int $0x10 /* Get Current Video mode */
  1425. + movb %al, %ch
  1426. + xorb %ah, %ah
  1427. + movb %cl, %al
  1428. + int $0x10 /* Set Video mode */
  1429. +
  1430. + DATA32 call EXT_C(real_to_prot)
  1431. + .code32
  1432. +
  1433. + xorl %eax, %eax
  1434. + movb %ch, %al
  1435. +
  1436. + popl %ecx
  1437. + popl %ebx
  1438. + popl %ebp
  1439. + ret
  1440. +
  1441. +
  1442. +/*
  1443. + * int get_videomode()
  1444. + * BIOS call "INT 10H Function 0Fh" to get current video mode
  1445. + * Call with %al = 0x0
  1446. + * %ah = 0xF
  1447. + * Returns current videomode.
  1448. + */
  1449. +ENTRY(get_videomode)
  1450. + pushl %ebp
  1451. + movl %esp,%ebp
  1452. + pushl %ebx
  1453. + pushl %ecx
  1454. +
  1455. + call EXT_C(prot_to_real)
  1456. + .code16
  1457. +
  1458. + xorb %al, %al
  1459. + movb $0xF, %ah
  1460. + int $0x10 /* Get Current Video mode */
  1461. + movb %al, %cl /* For now we only want display mode */
  1462. +
  1463. + DATA32 call EXT_C(real_to_prot)
  1464. + .code32
  1465. +
  1466. + xorl %eax, %eax
  1467. + movb %cl, %al
  1468. +
  1469. + popl %ecx
  1470. + popl %ebx
  1471. + popl %ebp
  1472. + ret
  1473. +
  1474. +
  1475. +/*
  1476. + * unsigned char * graphics_get_font()
  1477. + * BIOS call "INT 10H Function 11h" to set font
  1478. + * Call with %ah = 0x11
  1479. + */
  1480. +ENTRY(graphics_get_font)
  1481. + push %ebp
  1482. + push %ebx
  1483. + push %ecx
  1484. + push %edx
  1485. +
  1486. + call EXT_C(prot_to_real)
  1487. + .code16
  1488. +
  1489. + movw $0x1130, %ax
  1490. + movb $6, %bh /* font 8x16 */
  1491. + int $0x10
  1492. + movw %bp, %dx
  1493. + movw %es, %cx
  1494. +
  1495. + DATA32 call EXT_C(real_to_prot)
  1496. + .code32
  1497. +
  1498. + xorl %eax, %eax
  1499. + movw %cx, %ax
  1500. + shll $4, %eax
  1501. + movw %dx, %ax
  1502. +
  1503. + pop %edx
  1504. + pop %ecx
  1505. + pop %ebx
  1506. + pop %ebp
  1507. + ret
  1508. +
  1509. +
  1510. +/*
  1511. + * graphics_set_palette(index, red, green, blue)
  1512. + * BIOS call "INT 10H Function 10h" to set individual dac register
  1513. + * Call with %ah = 0x10
  1514. + * %bx = register number
  1515. + * %ch = new value for green (0-63)
  1516. + * %cl = new value for blue (0-63)
  1517. + * %dh = new value for red (0-63)
  1518. + */
  1519. +
  1520. +ENTRY(graphics_set_palette)
  1521. + push %ebp
  1522. + push %eax
  1523. + push %ebx
  1524. + push %ecx
  1525. + push %edx
  1526. +
  1527. + movw $0x3c8, %bx /* address write mode register */
  1528. +
  1529. + /* wait vertical retrace */
  1530. + movw $0x3da, %dx
  1531. +l1b:
  1532. + inb %dx, %al /* wait vertical active display */
  1533. + test $8, %al
  1534. + jnz l1b
  1535. +
  1536. +l2b:
  1537. + inb %dx, %al /* wait vertical retrace */
  1538. + test $8, %al
  1539. + jnz l2b
  1540. +
  1541. + mov %bx, %dx
  1542. + movb 0x18(%esp), %al /* index */
  1543. + outb %al, %dx
  1544. + inc %dx
  1545. +
  1546. + movb 0x1c(%esp), %al /* red */
  1547. + outb %al, %dx
  1548. +
  1549. + movb 0x20(%esp), %al /* green */
  1550. + outb %al, %dx
  1551. +
  1552. + movb 0x24(%esp), %al /* blue */
  1553. + outb %al, %dx
  1554. +
  1555. + movw 0x18(%esp), %bx
  1556. +
  1557. + call EXT_C(prot_to_real)
  1558. + .code16
  1559. +
  1560. + movb %bl, %bh
  1561. + movw $0x1000, %ax
  1562. + int $0x10
  1563. +
  1564. + DATA32 call EXT_C(real_to_prot)
  1565. + .code32
  1566. +
  1567. + pop %edx
  1568. + pop %ecx
  1569. + pop %ebx
  1570. + pop %eax
  1571. + pop %ebp
  1572. + ret
  1573. +#endif /* SUPPORT_GRAPHICS */
  1574. +
  1575. +
  1576. /*
  1577. * getrtsecs()
  1578. * if a seconds value can be read, read it and return it (BCD),
  1579. diff -Naur grub-0.97.orig/stage2/boot.c grub-0.97/stage2/boot.c
  1580. --- grub-0.97.orig/stage2/boot.c 2004-03-30 03:44:08.000000000 -0800
  1581. +++ grub-0.97/stage2/boot.c 2006-07-04 00:01:50.000000000 -0700
  1582. @@ -1,7 +1,7 @@
  1583. /* boot.c - load and bootstrap a kernel */
  1584. /*
  1585. * GRUB -- GRand Unified Bootloader
  1586. - * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc.
  1587. + * Copyright (C) 1999,2000,2001,2002,2003,2004,2005 Free Software Foundation, Inc.
  1588. *
  1589. * This program is free software; you can redistribute it and/or modify
  1590. * it under the terms of the GNU General Public License as published by
  1591. @@ -29,6 +29,8 @@
  1592. entry_func entry_addr;
  1593. static struct mod_list mll[99];
  1594. static int linux_mem_size;
  1595. +static int elf_kernel_addr;
  1596. +static int elf_kernel_size;
  1597. /*
  1598. * The next two functions, 'load_image' and 'load_module', are the building
  1599. @@ -96,7 +98,7 @@
  1600. lh = (struct linux_kernel_header *) buffer;
  1601. /* ELF loading supported if multiboot, FreeBSD and NetBSD. */
  1602. - if ((type == KERNEL_TYPE_MULTIBOOT
  1603. + if (((type == KERNEL_TYPE_MULTIBOOT && ! (flags & MULTIBOOT_AOUT_KLUDGE))
  1604. || pu.elf->e_ident[EI_OSABI] == ELFOSABI_FREEBSD
  1605. || grub_strcmp (pu.elf->e_ident + EI_BRAND, "FreeBSD") == 0
  1606. || suggested_type == KERNEL_TYPE_NETBSD)
  1607. @@ -594,6 +596,7 @@
  1608. /* reset this to zero for now */
  1609. cur_addr = 0;
  1610. + elf_kernel_addr = ~0;
  1611. /* scan for program segments */
  1612. for (i = 0; i < pu.elf->e_phnum; i++)
  1613. @@ -630,6 +633,8 @@
  1614. /* mark memory as used */
  1615. if (cur_addr < memaddr + memsiz)
  1616. cur_addr = memaddr + memsiz;
  1617. + if (elf_kernel_addr > cur_addr)
  1618. + elf_kernel_addr = cur_addr;
  1619. printf (", <0x%x:0x%x:0x%x>", memaddr, filesiz,
  1620. memsiz - filesiz);
  1621. /* increment number of segments */
  1622. @@ -647,6 +652,8 @@
  1623. }
  1624. }
  1625. + elf_kernel_size = cur_addr - elf_kernel_addr;
  1626. +
  1627. if (! errnum)
  1628. {
  1629. if (! loaded)
  1630. @@ -824,8 +831,11 @@
  1631. moveto = (mbi.mem_upper + 0x400) << 10;
  1632. moveto = (moveto - len) & 0xfffff000;
  1633. - max_addr = (lh->header == LINUX_MAGIC_SIGNATURE && lh->version >= 0x0203
  1634. - ? lh->initrd_addr_max : LINUX_INITRD_MAX_ADDRESS);
  1635. + max_addr = LINUX_INITRD_MAX_ADDRESS;
  1636. + if (lh->header == LINUX_MAGIC_SIGNATURE &&
  1637. + lh->version >= 0x0203 &&
  1638. + lh->initrd_addr_max < max_addr)
  1639. + max_addr = lh->initrd_addr_max;
  1640. if (moveto + len >= max_addr)
  1641. moveto = (max_addr - len) & 0xfffff000;
  1642. @@ -864,6 +874,129 @@
  1643. }
  1644. #endif
  1645. +#define mem_align4k(p) ((p) + 0xFFF) & 0xFFFFF000
  1646. +
  1647. +static void
  1648. +kfreebsd_setenv (char *env, const char *var, const char *value)
  1649. +{
  1650. + while (1)
  1651. + {
  1652. + if (env[0] == '\0' && env[1] == '\0')
  1653. + {
  1654. + env++;
  1655. + break;
  1656. + }
  1657. + else
  1658. + env++;
  1659. + }
  1660. +
  1661. + grub_sprintf (env, "%s=%s", var, value);
  1662. + env[grub_strlen (env) + 1] = '\0';
  1663. +}
  1664. +
  1665. +static char *
  1666. +kfreebsd_read_hints (char *buf)
  1667. +{
  1668. + char *buf_end = buf;
  1669. +
  1670. + if (grub_open ("/boot/device.hints"))
  1671. + {
  1672. + char *line_start;
  1673. + int line_len = 0;
  1674. + char *envp;
  1675. + int env_len;
  1676. +
  1677. + env_len = grub_read (buf, -1);
  1678. + if (env_len)
  1679. + {
  1680. + buf_end += env_len;
  1681. + *(buf_end++) = '\0';
  1682. + }
  1683. + else
  1684. + return buf_end;
  1685. +
  1686. + grub_close ();
  1687. +
  1688. + envp = line_start = buf;
  1689. + while (*envp)
  1690. + {
  1691. + char *envp_current = envp;
  1692. +
  1693. + switch (*envp)
  1694. + {
  1695. + case ' ':
  1696. + while (*envp == ' ')
  1697. + {
  1698. + envp++;
  1699. + env_len--;
  1700. + }
  1701. + grub_memmove (envp_current, envp, env_len + 1);
  1702. + envp = envp_current;
  1703. + break;
  1704. + case '#':
  1705. + while (*envp != '\n')
  1706. + {
  1707. + envp++;
  1708. + env_len--;
  1709. + }
  1710. + if (!line_len)
  1711. + envp++;
  1712. + grub_memmove (envp_current, envp, env_len + 1);
  1713. + envp = envp_current;
  1714. + break;
  1715. + case '\n':
  1716. + if (!line_len)
  1717. + {
  1718. + env_len--;
  1719. + grub_memmove (line_start, envp, env_len + 1);
  1720. + }
  1721. + *(envp++) = '\0';
  1722. + line_len = 0;
  1723. + line_start = envp;
  1724. + default:
  1725. + envp++;
  1726. + line_len++;
  1727. + break;
  1728. + }
  1729. + }
  1730. +
  1731. + buf_end = buf + env_len;
  1732. + *(buf_end++) = '\0';
  1733. + }
  1734. +
  1735. + return buf_end;
  1736. +}
  1737. +
  1738. +static u32_t *
  1739. +kfreebsd_set_module_string (u32_t type, u32_t *dst, char *src)
  1740. +{
  1741. + int size;
  1742. +
  1743. + *(dst++) = type;
  1744. + *(dst++) = size = grub_strlen (src) + 1;
  1745. + grub_strcpy ((void *) dst, src);
  1746. +
  1747. + return dst + (size + sizeof(u32_t) - 1) / sizeof(u32_t);
  1748. +}
  1749. +
  1750. +static u32_t *
  1751. +kfreebsd_set_module_var (u32_t type, u32_t *dst, u32_t src)
  1752. +{
  1753. + *(dst++) = type;
  1754. + *(dst++) = sizeof(u32_t);
  1755. + *(dst++) = src;
  1756. +
  1757. + return dst;
  1758. +}
  1759. +
  1760. +static u32_t *
  1761. +kfreebsd_set_modules (u32_t *modulep)
  1762. +{
  1763. + /* XXX: Need to copy the whole module structure. */
  1764. + /* XXX: How to pass the module name ? */
  1765. +
  1766. + return modulep;
  1767. +}
  1768. /*
  1769. * All "*_boot" commands depend on the images being loaded into memory
  1770. @@ -877,7 +1010,10 @@
  1771. bsd_boot (kernel_t type, int bootdev, char *arg)
  1772. {
  1773. char *str;
  1774. - int clval = 0, i;
  1775. + char *kernelname;
  1776. + char *bsd_root;
  1777. + int clval = 0;
  1778. + int i;
  1779. struct bootinfo bi;
  1780. #ifdef GRUB_UTIL
  1781. @@ -886,8 +1022,21 @@
  1782. stop_floppy ();
  1783. #endif
  1784. + while (*arg != '/')
  1785. + arg++;
  1786. + kernelname = arg;
  1787. +
  1788. while (*(++arg) && *arg != ' ');
  1789. + *(arg++) = 0;
  1790. str = arg;
  1791. +
  1792. + bsd_root = grub_strstr (str, "root=");
  1793. + if (bsd_root)
  1794. + {
  1795. + bsd_root += 5;
  1796. + /* XXX: should copy the str or terminate it. */
  1797. + }
  1798. +
  1799. while (*str)
  1800. {
  1801. if (*str == '-')
  1802. @@ -910,6 +1059,8 @@
  1803. clval |= RB_GDB;
  1804. if (*str == 'h')
  1805. clval |= RB_SERIAL;
  1806. + if (*str == 'p')
  1807. + clval |= RB_PAUSE;
  1808. if (*str == 'm')
  1809. clval |= RB_MUTE;
  1810. if (*str == 'r')
  1811. @@ -927,14 +1078,17 @@
  1812. if (type == KERNEL_TYPE_FREEBSD)
  1813. {
  1814. + char *envp;
  1815. + u32_t *modp;
  1816. +
  1817. clval |= RB_BOOTINFO;
  1818. bi.bi_version = BOOTINFO_VERSION;
  1819. - *arg = 0;
  1820. - while ((--arg) > (char *) MB_CMDLINE_BUF && *arg != '/');
  1821. - if (*arg == '/')
  1822. - bi.bi_kernelname = arg + 1;
  1823. + bi.bi_pad[0] = bi.bi_pad[1] = 0;
  1824. +
  1825. + if (*kernelname == '/')
  1826. + bi.bi_kernelname = kernelname;
  1827. else
  1828. bi.bi_kernelname = 0;
  1829. @@ -961,6 +1115,30 @@
  1830. bi.bi_basemem = mbi.mem_lower;
  1831. bi.bi_extmem = extended_memory;
  1832. + /* Setup the environment. */
  1833. + bi.bi_envp = cur_addr = mem_align4k (cur_addr);
  1834. + grub_memset ((void *) cur_addr, 0, 2);
  1835. + cur_addr = (int) kfreebsd_read_hints ((void *) cur_addr);
  1836. +
  1837. + envp = (char *) bi.bi_envp;
  1838. + kfreebsd_setenv (envp, "kernelname", kernelname);
  1839. + kfreebsd_setenv (envp, "vfs.root.mountfrom", bsd_root);
  1840. +
  1841. + /* Setup the modules list. */
  1842. + bi.bi_modulep = cur_addr = mem_align4k (cur_addr);
  1843. + modp = (u32_t *) bi.bi_modulep;
  1844. + /* The first module is the kernel. */
  1845. + modp = kfreebsd_set_module_string (MODINFO_NAME, modp, kernelname);
  1846. + modp = kfreebsd_set_module_string (MODINFO_TYPE, modp, "elf kernel");
  1847. + modp = kfreebsd_set_module_string (MODINFO_ARGS, modp, arg);
  1848. + modp = kfreebsd_set_module_var (MODINFO_ADDR, modp, elf_kernel_addr);
  1849. + modp = kfreebsd_set_module_var (MODINFO_SIZE, modp, elf_kernel_size);
  1850. + /* Now the real modules. */
  1851. + modp = kfreebsd_set_modules(modp);
  1852. +
  1853. + /* Set the kernel end. */
  1854. + bi.bi_kernend = cur_addr = mem_align4k (((int) modp) + 1);
  1855. +
  1856. if (mbi.flags & MB_INFO_AOUT_SYMS)
  1857. {
  1858. bi.bi_symtab = mbi.syms.a.addr;
  1859. @@ -970,8 +1148,9 @@
  1860. #if 0
  1861. else if (mbi.flags & MB_INFO_ELF_SHDR)
  1862. {
  1863. - /* FIXME: Should check if a symbol table exists and, if exists,
  1864. - pass the table to BI. */
  1865. + bi.bi_symtab = mbi.syms.e.addr;
  1866. + bi.bi_esymtab = mbi.syms.e.addr
  1867. + + mbi.syms.e.size * mbi.syms.e.num * mbi.syms.e.shndx;
  1868. }
  1869. #endif
  1870. else
  1871. diff -Naur grub-0.97.orig/stage2/builtins.c grub-0.97/stage2/builtins.c
  1872. --- grub-0.97.orig/stage2/builtins.c 2005-02-15 13:58:23.000000000 -0800
  1873. +++ grub-0.97/stage2/builtins.c 2006-07-04 00:01:50.000000000 -0700
  1874. @@ -28,6 +28,10 @@
  1875. #include <filesys.h>
  1876. #include <term.h>
  1877. +#ifdef SUPPORT_GRAPHICS
  1878. +# include <graphics.h>
  1879. +#endif
  1880. +
  1881. #ifdef SUPPORT_NETBOOT
  1882. # define GRUB 1
  1883. # include <etherboot.h>
  1884. @@ -82,6 +86,10 @@
  1885. inside other functions. */
  1886. static int configfile_func (char *arg, int flags);
  1887. +static int savedefault_helper (char *arg, int flags);
  1888. +
  1889. +static int savedefault_shell (char *arg, int flags);
  1890. +
  1891. /* Initialize the data for builtins. */
  1892. void
  1893. init_builtins (void)
  1894. @@ -237,12 +245,22 @@
  1895. static int
  1896. boot_func (char *arg, int flags)
  1897. {
  1898. + struct term_entry *prev_term = current_term;
  1899. /* Clear the int15 handler if we can boot the kernel successfully.
  1900. This assumes that the boot code never fails only if KERNEL_TYPE is
  1901. not KERNEL_TYPE_NONE. Is this assumption is bad? */
  1902. if (kernel_type != KERNEL_TYPE_NONE)
  1903. unset_int15_handler ();
  1904. + /* if our terminal needed initialization, we should shut it down
  1905. + * before booting the kernel, but we want to save what it was so
  1906. + * we can come back if needed */
  1907. + if (current_term->shutdown)
  1908. + {
  1909. + current_term->shutdown();
  1910. + current_term = term_table; /* assumption: console is first */
  1911. + }
  1912. +
  1913. #ifdef SUPPORT_NETBOOT
  1914. /* Shut down the networking. */
  1915. cleanup_net ();
  1916. @@ -306,6 +324,13 @@
  1917. return 1;
  1918. }
  1919. + /* if we get back here, we should go back to what our term was before */
  1920. + current_term = prev_term;
  1921. + if (current_term->startup)
  1922. + /* if our terminal fails to initialize, fall back to console since
  1923. + * it should always work */
  1924. + if (current_term->startup() == 0)
  1925. + current_term = term_table; /* we know that console is first */
  1926. return 0;
  1927. }
  1928. @@ -852,6 +877,251 @@
  1929. };
  1930. #endif /* SUPPORT_NETBOOT */
  1931. +#ifdef SUPPORT_GRAPHICS
  1932. +
  1933. +static int splashimage_func(char *arg, int flags) {
  1934. + int i;
  1935. +
  1936. + /* filename can only be 256 characters due to our buffer size */
  1937. + if (grub_strlen(arg) > 256) {
  1938. + grub_printf("Splash image filename too large\n");
  1939. + grub_printf("Press any key to continue...");
  1940. + getkey();
  1941. + return 1;
  1942. + }
  1943. +
  1944. + /* get rid of TERM_NEED_INIT from the graphics terminal. */
  1945. + for (i = 0; term_table[i].name; i++) {
  1946. + if (grub_strcmp (term_table[i].name, "graphics") == 0) {
  1947. + term_table[i].flags &= ~TERM_NEED_INIT;
  1948. + break;
  1949. + }
  1950. + }
  1951. +
  1952. + graphics_set_splash(arg);
  1953. +
  1954. + if (flags == BUILTIN_CMDLINE && graphics_inited) {
  1955. + graphics_end();
  1956. + if (graphics_init() == 0) {
  1957. + /* Fallback to default term */
  1958. + current_term = term_table;
  1959. + max_lines = current_term->max_lines;
  1960. + if (current_term->cls)
  1961. + current_term->cls();
  1962. + grub_printf("Failed to set splash image and/or graphics mode\n");
  1963. + return 1;
  1964. + }
  1965. + graphics_cls();
  1966. + }
  1967. +
  1968. + if (flags == BUILTIN_MENU)
  1969. + current_term = term_table + i;
  1970. +
  1971. + return 0;
  1972. +}
  1973. +
  1974. +static struct builtin builtin_splashimage =
  1975. +{
  1976. + "splashimage",
  1977. + splashimage_func,
  1978. + BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_HELP_LIST,
  1979. + "splashimage FILE",
  1980. + "Load FILE as the background image when in graphics mode."
  1981. +};
  1982. +
  1983. +
  1984. +/* shade */
  1985. +static int
  1986. +shade_func(char *arg, int flags)
  1987. +{
  1988. + int new_shade;
  1989. +
  1990. + if (!arg || safe_parse_maxint(&arg, &new_shade) == 0)
  1991. + return (1);
  1992. +
  1993. + if (shade != new_shade) {
  1994. + shade = new_shade;
  1995. + if (flags == BUILTIN_CMDLINE && graphics_inited) {
  1996. + graphics_end();
  1997. + graphics_init();
  1998. + graphics_cls();
  1999. + }
  2000. + }
  2001. +
  2002. + return 0;
  2003. +}
  2004. +
  2005. +static struct builtin builtin_shade =
  2006. +{
  2007. + "shade",
  2008. + shade_func,
  2009. + BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_HELP_LIST,
  2010. + "shade INTEGER",
  2011. + "If set to 0, disables the use of shaded text, else enables it."
  2012. +};
  2013. +
  2014. +
  2015. +/* foreground */
  2016. +static int
  2017. +foreground_func(char *arg, int flags)
  2018. +{
  2019. + if (grub_strlen(arg) == 6) {
  2020. + int r = ((hex(arg[0]) << 4) | hex(arg[1])) >> 2;
  2021. + int g = ((hex(arg[2]) << 4) | hex(arg[3])) >> 2;
  2022. + int b = ((hex(arg[4]) << 4) | hex(arg[5])) >> 2;
  2023. +
  2024. + foreground = (r << 16) | (g << 8) | b;
  2025. + if (graphics_inited)
  2026. + graphics_set_palette(15, r, g, b);
  2027. +
  2028. + return 0;
  2029. + }
  2030. +
  2031. + return 1;
  2032. +}
  2033. +
  2034. +static struct builtin builtin_foreground =
  2035. +{
  2036. + "foreground",
  2037. + foreground_func,
  2038. + BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_HELP_LIST,
  2039. + "foreground RRGGBB",
  2040. + "Sets the foreground color when in graphics mode."
  2041. + "RR is red, GG is green, and BB blue. Numbers must be in hexadecimal."
  2042. +};
  2043. +
  2044. +
  2045. +/* background */
  2046. +static int
  2047. +background_func(char *arg, int flags)
  2048. +{
  2049. + if (grub_strlen(arg) == 6) {
  2050. + int r = ((hex(arg[0]) << 4) | hex(arg[1])) >> 2;
  2051. + int g = ((hex(arg[2]) << 4) | hex(arg[3])) >> 2;
  2052. + int b = ((hex(arg[4]) << 4) | hex(arg[5])) >> 2;
  2053. +
  2054. + background = (r << 16) | (g << 8) | b;
  2055. + if (graphics_inited)
  2056. + graphics_set_palette(0, r, g, b);
  2057. + return 0;
  2058. + }
  2059. +
  2060. + return 1;
  2061. +}
  2062. +
  2063. +static struct builtin builtin_background =
  2064. +{
  2065. + "background",
  2066. + background_func,
  2067. + BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_HELP_LIST,
  2068. + "background RRGGBB",
  2069. + "Sets the background color when in graphics mode."
  2070. + "RR is red, GG is green, and BB blue. Numbers must be in hexadecimal."
  2071. +};
  2072. +
  2073. +
  2074. +/* border */
  2075. +static int
  2076. +border_func(char *arg, int flags)
  2077. +{
  2078. + if (grub_strlen(arg) == 6) {
  2079. + int r = ((hex(arg[0]) << 4) | hex(arg[1])) >> 2;
  2080. + int g = ((hex(arg[2]) << 4) | hex(arg[3])) >> 2;
  2081. + int b = ((hex(arg[4]) << 4) | hex(arg[5])) >> 2;
  2082. +
  2083. + window_border = (r << 16) | (g << 8) | b;
  2084. + if (graphics_inited)
  2085. + graphics_set_palette(0x11, r, g, b);
  2086. +
  2087. + return 0;
  2088. + }
  2089. +
  2090. + return 1;
  2091. +}
  2092. +
  2093. +static struct builtin builtin_border =
  2094. +{
  2095. + "border",
  2096. + border_func,
  2097. + BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_HELP_LIST,
  2098. + "border RRGGBB",
  2099. + "Sets the border video color when in graphics mode."
  2100. + "RR is red, GG is green, and BB blue. Numbers must be in hexadecimal."
  2101. +};
  2102. +
  2103. +
  2104. +/* viewport */
  2105. +static int
  2106. +viewport_func (char *arg, int flags)
  2107. +{
  2108. + int i;
  2109. + int x0 = 0, y0 = 0, x1 = 80, y1 = 30;
  2110. + int *pos[4] = { &x0, &y0, &x1, &y1 };
  2111. +
  2112. + if (!arg)
  2113. + return (1);
  2114. + for (i = 0; i < 4; i++) {
  2115. + if (!*arg)
  2116. + return (1);
  2117. + while (*arg && (*arg == ' ' || *arg == '\t'))
  2118. + ++arg;
  2119. + if (!safe_parse_maxint(&arg, pos[i]))
  2120. + return (1);
  2121. + while (*arg && (*arg != ' ' && *arg != '\t'))
  2122. + ++arg;
  2123. + }
  2124. +
  2125. + /* minimum size is 65 colums and 16 rows */
  2126. + if (x0 > x1 - 66 || y0 > y1 - 16 || x0 < 0 || y0 < 0 || x1 > 80 || y1 > 30)
  2127. + return 1;
  2128. +
  2129. + view_x0 = x0;
  2130. + view_y0 = y0;
  2131. + view_x1 = x1;
  2132. + view_y1 = y1;
  2133. +
  2134. + if (flags == BUILTIN_CMDLINE && graphics_inited) {
  2135. + graphics_end();
  2136. + graphics_init();
  2137. + graphics_cls();
  2138. + }
  2139. +
  2140. + return 0;
  2141. +}
  2142. +
  2143. +static struct builtin builtin_viewport =
  2144. +{
  2145. + "viewport",
  2146. + viewport_func,
  2147. + BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_HELP_LIST,
  2148. + "viewport x0 y0 x1 y1",
  2149. + "Changes grub internals to output text in the window defined by"
  2150. + " four parameters. The x and y parameters are 0 based. This option"
  2151. + " only works with the graphics interface."
  2152. +};
  2153. +
  2154. +#endif /* SUPPORT_GRAPHICS */
  2155. +
  2156. +
  2157. +/* clear */
  2158. +static int
  2159. +clear_func()
  2160. +{
  2161. + if (current_term->cls)
  2162. + current_term->cls();
  2163. +
  2164. + return 0;
  2165. +}
  2166. +
  2167. +static struct builtin builtin_clear =
  2168. +{
  2169. + "clear",
  2170. + clear_func,
  2171. + BUILTIN_CMDLINE | BUILTIN_HELP_LIST,
  2172. + "clear",
  2173. + "Clear the screen"
  2174. +};
  2175. +
  2176. /* displayapm */
  2177. static int
  2178. @@ -1454,14 +1724,20 @@
  2179. /* help */
  2180. -#define MAX_SHORT_DOC_LEN 39
  2181. -#define MAX_LONG_DOC_LEN 66
  2182. -
  2183. static int
  2184. help_func (char *arg, int flags)
  2185. {
  2186. - int all = 0;
  2187. -
  2188. + int all = 0, max_short_doc_len, max_long_doc_len;
  2189. + max_short_doc_len = 39;
  2190. + max_long_doc_len = 66;
  2191. +#ifdef SUPPORT_GRAPHICS
  2192. + if (grub_memcmp (current_term->name, "graphics", sizeof ("graphics") - 1) == 0)
  2193. + {
  2194. + max_short_doc_len = (view_x1 - view_x0 + 1) / 2 - 1;
  2195. + max_long_doc_len = (view_x1 - view_x0) - 14;
  2196. + }
  2197. +#endif
  2198. +
  2199. if (grub_memcmp (arg, "--all", sizeof ("--all") - 1) == 0)
  2200. {
  2201. all = 1;
  2202. @@ -1491,13 +1767,13 @@
  2203. len = grub_strlen ((*builtin)->short_doc);
  2204. /* If the length of SHORT_DOC is too long, truncate it. */
  2205. - if (len > MAX_SHORT_DOC_LEN - 1)
  2206. - len = MAX_SHORT_DOC_LEN - 1;
  2207. + if (len > max_short_doc_len - 1)
  2208. + len = max_short_doc_len - 1;
  2209. for (i = 0; i < len; i++)
  2210. grub_putchar ((*builtin)->short_doc[i]);
  2211. - for (; i < MAX_SHORT_DOC_LEN; i++)
  2212. + for (; i < max_short_doc_len; i++)
  2213. grub_putchar (' ');
  2214. if (! left)
  2215. @@ -1546,10 +1822,10 @@
  2216. int i;
  2217. /* If LEN is too long, fold DOC. */
  2218. - if (len > MAX_LONG_DOC_LEN)
  2219. + if (len > max_long_doc_len)
  2220. {
  2221. /* Fold this line at the position of a space. */
  2222. - for (len = MAX_LONG_DOC_LEN; len > 0; len--)
  2223. + for (len = max_long_doc_len; len > 0; len--)
  2224. if (doc[len - 1] == ' ')
  2225. break;
  2226. }
  2227. @@ -2323,6 +2599,25 @@
  2228. "Probe I/O ports used for the drive DRIVE."
  2229. };
  2230. +/* print */
  2231. +static int
  2232. +print_func (char *arg, int flags)
  2233. +{
  2234. + printf("%s\n", arg);
  2235. +
  2236. + return 0;
  2237. +}
  2238. +
  2239. +static struct builtin builtin_print =
  2240. +{
  2241. + "print",
  2242. + print_func,
  2243. + BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_NO_ECHO,
  2244. + "print [MESSAGE ...]",
  2245. + "Print MESSAGE."
  2246. +};
  2247. +
  2248. +
  2249. /* kernel */
  2250. static int
  2251. @@ -3221,7 +3516,102 @@
  2252. static int
  2253. savedefault_func (char *arg, int flags)
  2254. {
  2255. -#if !defined(SUPPORT_DISKLESS) && !defined(GRUB_UTIL)
  2256. +#if !defined(SUPPORT_DISKLESS)
  2257. + #if !defined(GRUB_UTIL)
  2258. + savedefault_helper(arg, flags);
  2259. + #else
  2260. + savedefault_shell(arg, flags);
  2261. + #endif
  2262. +#else /* !SUPPORT_DISKLESS */
  2263. + errnum = ERR_UNRECOGNIZED;
  2264. + return 1;
  2265. +#endif /* !SUPPORT_DISKLESS */
  2266. +}
  2267. +
  2268. +#if !defined(SUPPORT_DISKLESS) && defined(GRUB_UTIL)
  2269. +/* savedefault_shell */
  2270. +static int
  2271. +savedefault_shell(char *arg, int flags)
  2272. + {
  2273. + int once_only = 0;
  2274. + int new_default;
  2275. + int curr_default = -1;
  2276. + int curr_prev_default = -1;
  2277. + int new_prev_default = -1;
  2278. + FILE *fp;
  2279. + size_t bytes = 10;
  2280. + char line[bytes];
  2281. + char *default_file = (char *) DEFAULT_FILE_BUF;
  2282. + char buf[bytes];
  2283. + int i;
  2284. +
  2285. + while (1)
  2286. + {
  2287. + if (grub_memcmp ("--default=", arg, sizeof ("--default=") - 1) == 0)
  2288. + {
  2289. + char *p = arg + sizeof ("--default=") - 1;
  2290. + if (! safe_parse_maxint (&p, &new_default))
  2291. + return 1;
  2292. + arg = skip_to (0, arg);
  2293. + }
  2294. + else if (grub_memcmp ("--once", arg, sizeof ("--once") - 1) == 0)
  2295. + {
  2296. + once_only = 1;
  2297. + arg = skip_to (0, arg);
  2298. + }
  2299. + else
  2300. + break;
  2301. + }
  2302. +
  2303. + *default_file = 0;
  2304. + grub_strncat (default_file, config_file, DEFAULT_FILE_BUFLEN);
  2305. + for (i = grub_strlen(default_file); i >= 0; i--)
  2306. + if (default_file[i] == '/')
  2307. + {
  2308. + i++;
  2309. + break;
  2310. + }
  2311. + default_file[i] = 0;
  2312. + grub_strncat (default_file + i, "default", DEFAULT_FILE_BUFLEN - i);
  2313. +
  2314. + if(!(fp = fopen(default_file,"w")))
  2315. + {
  2316. + errnum = ERR_READ;
  2317. + goto fail;
  2318. + }
  2319. +
  2320. + read(&line, -1);
  2321. +
  2322. + sscanf(line, "%d:%d", &curr_prev_default, &curr_default);
  2323. +
  2324. + if(curr_default != -1)
  2325. + new_prev_default = curr_default;
  2326. + else
  2327. + {
  2328. + if(curr_prev_default != -1)
  2329. + new_prev_default = curr_prev_default;
  2330. + else
  2331. + new_prev_default = 0;
  2332. + }
  2333. +
  2334. + if(once_only)
  2335. + sprintf(buf, "%d:%d\n", new_prev_default, new_default);
  2336. + else
  2337. + sprintf(buf, "%d\n", new_default);
  2338. +
  2339. + fprintf(fp, buf);
  2340. +
  2341. +fail:
  2342. + fclose(fp);
  2343. + return errnum;
  2344. +}
  2345. +#endif
  2346. +
  2347. +/* savedefault_helper */
  2348. +static int
  2349. +savedefault_helper (char *arg, int flags)
  2350. +{
  2351. +#if !defined(SUPPORT_DISKLESS)
  2352. unsigned long tmp_drive = saved_drive;
  2353. unsigned long tmp_partition = saved_partition;
  2354. char *default_file = (char *) DEFAULT_FILE_BUF;
  2355. @@ -3300,19 +3690,23 @@
  2356. disk_read_hook = 0;
  2357. grub_close ();
  2358. - if (len != sizeof (buf))
  2359. - {
  2360. - /* This is too small. Do not modify the file manually, please! */
  2361. - errnum = ERR_READ;
  2362. - goto fail;
  2363. - }
  2364. -
  2365. if (sector_count > 2)
  2366. {
  2367. /* Is this possible?! Too fragmented! */
  2368. errnum = ERR_FSYS_CORRUPT;
  2369. goto fail;
  2370. }
  2371. +
  2372. + char *tmp;
  2373. + if((tmp = grub_strstr(buf, ":")) != NULL)
  2374. + {
  2375. + int f_len = grub_strlen(buf) - grub_strlen(tmp);
  2376. + char *def;
  2377. + int a;
  2378. + for(a = 0; a < f_len; a++)
  2379. + grub_memcpy(&def[a], &buf[a], sizeof(char));
  2380. + safe_parse_maxint (&def, &entryno);
  2381. + }
  2382. /* Set up a string to be written. */
  2383. grub_memset (buf, '\n', sizeof (buf));
  2384. @@ -3830,15 +4224,15 @@
  2385. {
  2386. char tmp[16];
  2387. grub_sprintf (tmp, ",%d", (partition >> 16) & 0xFF);
  2388. - grub_strncat (device, tmp, 256);
  2389. + grub_strncat (device, tmp, sizeof (device));
  2390. }
  2391. if ((partition & 0x00FF00) != 0x00FF00)
  2392. {
  2393. char tmp[16];
  2394. grub_sprintf (tmp, ",%c", 'a' + ((partition >> 8) & 0xFF));
  2395. - grub_strncat (device, tmp, 256);
  2396. + grub_strncat (device, tmp, sizeof (device));
  2397. }
  2398. - grub_strncat (device, ")", 256);
  2399. + grub_strncat (device, ")", sizeof (device));
  2400. }
  2401. int embed_stage1_5 (char *stage1_5, int drive, int partition)
  2402. @@ -4085,7 +4479,7 @@
  2403. };
  2404. -#if defined(SUPPORT_SERIAL) || defined(SUPPORT_HERCULES)
  2405. +#if defined(SUPPORT_SERIAL) || defined(SUPPORT_HERCULES) || defined(SUPPORT_GRAPHICS)
  2406. /* terminal */
  2407. static int
  2408. terminal_func (char *arg, int flags)
  2409. @@ -4244,17 +4638,29 @@
  2410. end:
  2411. current_term = term_table + default_term;
  2412. current_term->flags = term_flags;
  2413. -
  2414. +
  2415. if (lines)
  2416. max_lines = lines;
  2417. else
  2418. - /* 24 would be a good default value. */
  2419. - max_lines = 24;
  2420. -
  2421. + max_lines = current_term->max_lines;
  2422. +
  2423. /* If the interface is currently the command-line,
  2424. restart it to repaint the screen. */
  2425. - if (current_term != prev_term && (flags & BUILTIN_CMDLINE))
  2426. + if ((current_term != prev_term) && (flags & BUILTIN_CMDLINE)){
  2427. + if (prev_term->shutdown)
  2428. + prev_term->shutdown();
  2429. + if (current_term->startup) {
  2430. + /* If startup fails, return to previous term */
  2431. + if (current_term->startup() == 0) {
  2432. + current_term = prev_term;
  2433. + max_lines = current_term->max_lines;
  2434. + if (current_term->cls) {
  2435. + current_term->cls();
  2436. + }
  2437. + }
  2438. + }
  2439. grub_longjmp (restart_cmdline_env, 0);
  2440. + }
  2441. return 0;
  2442. }
  2443. @@ -4264,7 +4670,7 @@
  2444. "terminal",
  2445. terminal_func,
  2446. BUILTIN_MENU | BUILTIN_CMDLINE | BUILTIN_HELP_LIST,
  2447. - "terminal [--dumb] [--no-echo] [--no-edit] [--timeout=SECS] [--lines=LINES] [--silent] [console] [serial] [hercules]",
  2448. + "terminal [--dumb] [--no-echo] [--no-edit] [--timeout=SECS] [--lines=LINES] [--silent] [console] [serial] [hercules] [graphics]",
  2449. "Select a terminal. When multiple terminals are specified, wait until"
  2450. " you push any key to continue. If both console and serial are specified,"
  2451. " the terminal to which you input a key first will be selected. If no"
  2452. @@ -4276,7 +4682,7 @@
  2453. " seconds. The option --lines specifies the maximum number of lines."
  2454. " The option --silent is used to suppress messages."
  2455. };
  2456. -#endif /* SUPPORT_SERIAL || SUPPORT_HERCULES */
  2457. +#endif /* SUPPORT_SERIAL || SUPPORT_HERCULES || SUPPORT_GRAPHICS */
  2458. #ifdef SUPPORT_SERIAL
  2459. @@ -4795,13 +5201,20 @@
  2460. /* The table of builtin commands. Sorted in dictionary order. */
  2461. struct builtin *builtin_table[] =
  2462. {
  2463. +#ifdef SUPPORT_GRAPHICS
  2464. + &builtin_background,
  2465. +#endif
  2466. &builtin_blocklist,
  2467. &builtin_boot,
  2468. #ifdef SUPPORT_NETBOOT
  2469. &builtin_bootp,
  2470. #endif /* SUPPORT_NETBOOT */
  2471. +#ifdef SUPPORT_GRAPHICS
  2472. + &builtin_border,
  2473. +#endif
  2474. &builtin_cat,
  2475. &builtin_chainloader,
  2476. + &builtin_clear,
  2477. &builtin_cmp,
  2478. &builtin_color,
  2479. &builtin_configfile,
  2480. @@ -4821,6 +5234,9 @@
  2481. &builtin_embed,
  2482. &builtin_fallback,
  2483. &builtin_find,
  2484. +#ifdef SUPPORT_GRAPHICS
  2485. + &builtin_foreground,
  2486. +#endif
  2487. &builtin_fstest,
  2488. &builtin_geometry,
  2489. &builtin_halt,
  2490. @@ -4848,6 +5264,7 @@
  2491. &builtin_parttype,
  2492. &builtin_password,
  2493. &builtin_pause,
  2494. + &builtin_print,
  2495. #ifdef GRUB_UTIL
  2496. &builtin_quit,
  2497. #endif /* GRUB_UTIL */
  2498. @@ -4864,9 +5281,13 @@
  2499. #endif /* SUPPORT_SERIAL */
  2500. &builtin_setkey,
  2501. &builtin_setup,
  2502. -#if defined(SUPPORT_SERIAL) || defined(SUPPORT_HERCULES)
  2503. +#ifdef SUPPORT_GRAPHICS
  2504. + &builtin_shade,
  2505. + &builtin_splashimage,
  2506. +#endif /* SUPPORT_GRAPHICS */
  2507. +#if defined(SUPPORT_SERIAL) || defined(SUPPORT_HERCULES) || defined(SUPPORT_GRAPHICS)
  2508. &builtin_terminal,
  2509. -#endif /* SUPPORT_SERIAL || SUPPORT_HERCULES */
  2510. +#endif /* SUPPORT_SERIAL || SUPPORT_HERCULES || SUPPORT_GRAPHICS */
  2511. #ifdef SUPPORT_SERIAL
  2512. &builtin_terminfo,
  2513. #endif /* SUPPORT_SERIAL */
  2514. @@ -4880,5 +5301,8 @@
  2515. &builtin_unhide,
  2516. &builtin_uppermem,
  2517. &builtin_vbeprobe,
  2518. +#ifdef SUPPORT_GRAPHICS
  2519. + &builtin_viewport,
  2520. +#endif
  2521. 0
  2522. };
  2523. diff -Naur grub-0.97.orig/stage2/char_io.c grub-0.97/stage2/char_io.c
  2524. --- grub-0.97.orig/stage2/char_io.c 2005-02-01 12:51:23.000000000 -0800
  2525. +++ grub-0.97/stage2/char_io.c 2006-07-03 23:59:27.000000000 -0700
  2526. @@ -29,12 +29,17 @@
  2527. # include <serial.h>
  2528. #endif
  2529. +#ifdef SUPPORT_GRAPHICS
  2530. +# include <graphics.h>
  2531. +#endif
  2532. +
  2533. #ifndef STAGE1_5
  2534. struct term_entry term_table[] =
  2535. {
  2536. {
  2537. "console",
  2538. 0,
  2539. + 24,
  2540. console_putchar,
  2541. console_checkkey,
  2542. console_getkey,
  2543. @@ -43,13 +48,16 @@
  2544. console_cls,
  2545. console_setcolorstate,
  2546. console_setcolor,
  2547. - console_setcursor
  2548. + console_setcursor,
  2549. + 0,
  2550. + 0
  2551. },
  2552. #ifdef SUPPORT_SERIAL
  2553. {
  2554. "serial",
  2555. /* A serial device must be initialized. */
  2556. TERM_NEED_INIT,
  2557. + 24,
  2558. serial_putchar,
  2559. serial_checkkey,
  2560. serial_getkey,
  2561. @@ -58,6 +66,8 @@
  2562. serial_cls,
  2563. serial_setcolorstate,
  2564. 0,
  2565. + 0,
  2566. + 0,
  2567. 0
  2568. },
  2569. #endif /* SUPPORT_SERIAL */
  2570. @@ -65,6 +75,7 @@
  2571. {
  2572. "hercules",
  2573. 0,
  2574. + 24,
  2575. hercules_putchar,
  2576. console_checkkey,
  2577. console_getkey,
  2578. @@ -73,11 +84,30 @@
  2579. hercules_cls,
  2580. hercules_setcolorstate,
  2581. hercules_setcolor,
  2582. - hercules_setcursor
  2583. + hercules_setcursor,
  2584. + 0,
  2585. + 0
  2586. },
  2587. #endif /* SUPPORT_HERCULES */
  2588. +#ifdef SUPPORT_GRAPHICS
  2589. + { "graphics",
  2590. + TERM_NEED_INIT, /* flags */
  2591. + 30, /* number of lines */
  2592. + graphics_putchar, /* putchar */
  2593. + console_checkkey, /* checkkey */
  2594. + console_getkey, /* getkey */
  2595. + graphics_getxy, /* getxy */
  2596. + graphics_gotoxy, /* gotoxy */
  2597. + graphics_cls, /* cls */
  2598. + graphics_setcolorstate, /* setcolorstate */
  2599. + graphics_setcolor, /* setcolor */
  2600. + graphics_setcursor, /* nocursor */
  2601. + graphics_init, /* initialize */
  2602. + graphics_end /* shutdown */
  2603. + },
  2604. +#endif /* SUPPORT_GRAPHICS */
  2605. /* This must be the last entry. */
  2606. - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
  2607. + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
  2608. };
  2609. /* This must be console. */
  2610. @@ -305,9 +335,10 @@
  2611. /* XXX: These should be defined in shared.h, but I leave these here,
  2612. until this code is freezed. */
  2613. -#define CMDLINE_WIDTH 78
  2614. #define CMDLINE_MARGIN 10
  2615. -
  2616. +
  2617. + /* command-line limits */
  2618. + int cmdline_width = 78, col_start = 0;
  2619. int xpos, lpos, c, section;
  2620. /* The length of PROMPT. */
  2621. int plen;
  2622. @@ -338,7 +369,7 @@
  2623. /* If the cursor is in the first section, display the first section
  2624. instead of the second. */
  2625. - if (section == 1 && plen + lpos < CMDLINE_WIDTH)
  2626. + if (section == 1 && plen + lpos < cmdline_width)
  2627. cl_refresh (1, 0);
  2628. else if (xpos - count < 1)
  2629. cl_refresh (1, 0);
  2630. @@ -354,7 +385,7 @@
  2631. grub_putchar ('\b');
  2632. }
  2633. else
  2634. - gotoxy (xpos, getxy () & 0xFF);
  2635. + gotoxy (xpos + col_start, getxy () & 0xFF);
  2636. }
  2637. }
  2638. @@ -364,7 +395,7 @@
  2639. lpos += count;
  2640. /* If the cursor goes outside, scroll the screen to the right. */
  2641. - if (xpos + count >= CMDLINE_WIDTH)
  2642. + if (xpos + count >= cmdline_width)
  2643. cl_refresh (1, 0);
  2644. else
  2645. {
  2646. @@ -383,7 +414,7 @@
  2647. }
  2648. }
  2649. else
  2650. - gotoxy (xpos, getxy () & 0xFF);
  2651. + gotoxy (xpos + col_start, getxy () & 0xFF);
  2652. }
  2653. }
  2654. @@ -398,14 +429,14 @@
  2655. if (full)
  2656. {
  2657. /* Recompute the section number. */
  2658. - if (lpos + plen < CMDLINE_WIDTH)
  2659. + if (lpos + plen < cmdline_width)
  2660. section = 0;
  2661. else
  2662. - section = ((lpos + plen - CMDLINE_WIDTH)
  2663. - / (CMDLINE_WIDTH - 1 - CMDLINE_MARGIN) + 1);
  2664. + section = ((lpos + plen - cmdline_width)
  2665. + / (cmdline_width - 1 - CMDLINE_MARGIN) + 1);
  2666. /* From the start to the end. */
  2667. - len = CMDLINE_WIDTH;
  2668. + len = cmdline_width;
  2669. pos = 0;
  2670. grub_putchar ('\r');
  2671. @@ -445,8 +476,8 @@
  2672. if (! full)
  2673. offset = xpos - 1;
  2674. - start = ((section - 1) * (CMDLINE_WIDTH - 1 - CMDLINE_MARGIN)
  2675. - + CMDLINE_WIDTH - plen - CMDLINE_MARGIN);
  2676. + start = ((section - 1) * (cmdline_width - 1 - CMDLINE_MARGIN)
  2677. + + cmdline_width - plen - CMDLINE_MARGIN);
  2678. xpos = lpos + 1 - start;
  2679. start += offset;
  2680. }
  2681. @@ -471,7 +502,7 @@
  2682. /* If the cursor is at the last position, put `>' or a space,
  2683. depending on if there are more characters in BUF. */
  2684. - if (pos == CMDLINE_WIDTH)
  2685. + if (pos == cmdline_width)
  2686. {
  2687. if (start + len < llen)
  2688. grub_putchar ('>');
  2689. @@ -488,7 +519,7 @@
  2690. grub_putchar ('\b');
  2691. }
  2692. else
  2693. - gotoxy (xpos, getxy () & 0xFF);
  2694. + gotoxy (xpos + col_start, getxy () & 0xFF);
  2695. }
  2696. /* Initialize the command-line. */
  2697. @@ -518,10 +549,10 @@
  2698. llen += l;
  2699. lpos += l;
  2700. - if (xpos + l >= CMDLINE_WIDTH)
  2701. + if (xpos + l >= cmdline_width)
  2702. cl_refresh (1, 0);
  2703. - else if (xpos + l + llen - lpos > CMDLINE_WIDTH)
  2704. - cl_refresh (0, CMDLINE_WIDTH - xpos);
  2705. + else if (xpos + l + llen - lpos > cmdline_width)
  2706. + cl_refresh (0, cmdline_width - xpos);
  2707. else
  2708. cl_refresh (0, l + llen - lpos);
  2709. }
  2710. @@ -533,12 +564,22 @@
  2711. grub_memmove (buf + lpos, buf + lpos + count, llen - count + 1);
  2712. llen -= count;
  2713. - if (xpos + llen + count - lpos > CMDLINE_WIDTH)
  2714. - cl_refresh (0, CMDLINE_WIDTH - xpos);
  2715. + if (xpos + llen + count - lpos > cmdline_width)
  2716. + cl_refresh (0, cmdline_width - xpos);
  2717. else
  2718. cl_refresh (0, llen + count - lpos);
  2719. }
  2720. + max_lines = current_term->max_lines;
  2721. +#ifdef SUPPORT_GRAPHICS
  2722. + if (grub_memcmp (current_term->name, "graphics", sizeof ("graphics") - 1) == 0)
  2723. + {
  2724. + cmdline_width = (view_x1 - view_x0) - 2;
  2725. + col_start = view_x0;
  2726. + max_lines = view_y1 - view_y0;
  2727. + }
  2728. +#endif
  2729. +
  2730. plen = grub_strlen (prompt);
  2731. llen = grub_strlen (cmdline);
  2732. @@ -1006,6 +1047,48 @@
  2733. }
  2734. #endif /* ! STAGE1_5 */
  2735. +#ifndef STAGE1_5
  2736. +/* Internal pager. */
  2737. +int
  2738. +do_more (void)
  2739. +{
  2740. + if (count_lines >= 0)
  2741. + {
  2742. + count_lines++;
  2743. + if (count_lines >= max_lines - 2)
  2744. + {
  2745. + int tmp;
  2746. +
  2747. + /* It's important to disable the feature temporarily, because
  2748. + the following grub_printf call will print newlines. */
  2749. + count_lines = -1;
  2750. +
  2751. + grub_printf("\n");
  2752. + if (current_term->setcolorstate)
  2753. + current_term->setcolorstate (COLOR_STATE_HIGHLIGHT);
  2754. +
  2755. + grub_printf ("[Hit return to continue]");
  2756. +
  2757. + if (current_term->setcolorstate)
  2758. + current_term->setcolorstate (COLOR_STATE_NORMAL);
  2759. +
  2760. +
  2761. + do
  2762. + {
  2763. + tmp = ASCII_CHAR (getkey ());
  2764. + }
  2765. + while (tmp != '\n' && tmp != '\r');
  2766. + grub_printf ("\r \r");
  2767. +
  2768. + /* Restart to count lines. */
  2769. + count_lines = 0;
  2770. + return 1;
  2771. + }
  2772. + }
  2773. + return 0;
  2774. +}
  2775. +#endif
  2776. +
  2777. /* Display an ASCII character. */
  2778. void
  2779. grub_putchar (int c)
  2780. @@ -1034,38 +1117,11 @@
  2781. if (c == '\n')
  2782. {
  2783. + int flag;
  2784. /* Internal `more'-like feature. */
  2785. - if (count_lines >= 0)
  2786. - {
  2787. - count_lines++;
  2788. - if (count_lines >= max_lines - 2)
  2789. - {
  2790. - int tmp;
  2791. -
  2792. - /* It's important to disable the feature temporarily, because
  2793. - the following grub_printf call will print newlines. */
  2794. - count_lines = -1;
  2795. -
  2796. - if (current_term->setcolorstate)
  2797. - current_term->setcolorstate (COLOR_STATE_HIGHLIGHT);
  2798. -
  2799. - grub_printf ("\n[Hit return to continue]");
  2800. -
  2801. - if (current_term->setcolorstate)
  2802. - current_term->setcolorstate (COLOR_STATE_NORMAL);
  2803. -
  2804. - do
  2805. - {
  2806. - tmp = ASCII_CHAR (getkey ());
  2807. - }
  2808. - while (tmp != '\n' && tmp != '\r');
  2809. - grub_printf ("\r \r");
  2810. -
  2811. - /* Restart to count lines. */
  2812. - count_lines = 0;
  2813. - return;
  2814. - }
  2815. - }
  2816. + flag = do_more ();
  2817. + if (flag)
  2818. + return;
  2819. }
  2820. current_term->putchar (c);
  2821. @@ -1090,7 +1146,7 @@
  2822. cls (void)
  2823. {
  2824. /* If the terminal is dumb, there is no way to clean the terminal. */
  2825. - if (current_term->flags & TERM_DUMB)
  2826. + if (current_term->flags & TERM_DUMB)
  2827. grub_putchar ('\n');
  2828. else
  2829. current_term->cls ();
  2830. @@ -1175,13 +1231,13 @@
  2831. #endif /* ! STAGE1_5 */
  2832. int
  2833. -memcheck (int addr, int len)
  2834. +memcheck (unsigned long int addr, unsigned long int len)
  2835. {
  2836. #ifdef GRUB_UTIL
  2837. - auto int start_addr (void);
  2838. - auto int end_addr (void);
  2839. + auto unsigned long int start_addr (void);
  2840. + auto int unsigned long end_addr (void);
  2841. - auto int start_addr (void)
  2842. + auto unsigned long int start_addr (void)
  2843. {
  2844. int ret;
  2845. # if defined(HAVE_START_SYMBOL)
  2846. @@ -1192,7 +1248,7 @@
  2847. return ret;
  2848. }
  2849. - auto int end_addr (void)
  2850. + auto unsigned long int end_addr (void)
  2851. {
  2852. int ret;
  2853. # if defined(HAVE_END_SYMBOL)
  2854. @@ -1217,6 +1273,16 @@
  2855. return ! errnum;
  2856. }
  2857. +void
  2858. +grub_memcpy(void *dest, const void *src, int len)
  2859. +{
  2860. + int i;
  2861. + register char *d = (char*)dest, *s = (char*)src;
  2862. +
  2863. + for (i = 0; i < len; i++)
  2864. + d[i] = s[i];
  2865. +}
  2866. +
  2867. void *
  2868. grub_memmove (void *to, const void *from, int len)
  2869. {
  2870. diff -Naur grub-0.97.orig/stage2/cmdline.c grub-0.97/stage2/cmdline.c
  2871. --- grub-0.97.orig/stage2/cmdline.c 2004-08-16 16:23:01.000000000 -0700
  2872. +++ grub-0.97/stage2/cmdline.c 2006-07-03 23:58:41.000000000 -0700
  2873. @@ -50,10 +50,11 @@
  2874. void
  2875. print_cmdline_message (int forever)
  2876. {
  2877. - printf (" [ Minimal BASH-like line editing is supported. For the first word, TAB\n"
  2878. - " lists possible command completions. Anywhere else TAB lists the possible\n"
  2879. - " completions of a device/filename.%s ]\n",
  2880. - (forever ? "" : " ESC at any time exits."));
  2881. + grub_printf(" [ Minimal BASH-like line editing is supported. For\n"
  2882. + " the first word, TAB lists possible command\n"
  2883. + " completions. Anywhere else TAB lists the possible\n"
  2884. + " completions of a device/filename.%s ]\n",
  2885. + (forever ? "" : " ESC at any time\n exits."));
  2886. }
  2887. /* Find the builtin whose command name is COMMAND and return the
  2888. diff -Naur grub-0.97.orig/stage2/freebsd.h grub-0.97/stage2/freebsd.h
  2889. --- grub-0.97.orig/stage2/freebsd.h 2003-07-09 04:45:52.000000000 -0700
  2890. +++ grub-0.97/stage2/freebsd.h 2006-07-03 23:59:36.000000000 -0700
  2891. @@ -1,7 +1,7 @@
  2892. /*
  2893. * GRUB -- GRand Unified Bootloader
  2894. - * Copyright (C) 2001 Free Software Foundation, Inc.
  2895. + * Copyright (C) 2001, 2004 Free Software Foundation, Inc.
  2896. *
  2897. * This program is free software; you can redistribute it and/or modify
  2898. * it under the terms of the GNU General Public License as published by
  2899. @@ -35,6 +35,10 @@
  2900. #define RB_CDROM 0x2000 /* use cdrom as root */
  2901. #define RB_GDB 0x8000 /* use GDB remote debugger instead of DDB */
  2902. #define RB_MUTE 0x10000 /* Come up with the console muted */
  2903. +#define RB_SELFTEST 0x20000 /* don't complete the boot; do selftest */
  2904. +#define RB_RESERVED1 0x40000 /* reserved for internal use of boot blocks */
  2905. +#define RB_RESERVED2 0x80000 /* reserved for internal use of boot blocks */
  2906. +#define RB_PAUSE 0x100000 /* pause after each output line during probe */
  2907. #define RB_MULTIPLE 0x20000000 /* Use multiple consoles */
  2908. #define RB_BOOTINFO 0x80000000 /* have `struct bootinfo *' arg */
  2909. @@ -70,6 +74,9 @@
  2910. #define N_BIOS_GEOM 8
  2911. +typedef unsigned char u8_t;
  2912. +typedef unsigned int u32_t;
  2913. +
  2914. /*
  2915. * A zero bootinfo field often means that there is no info available.
  2916. * Flags are used to indicate the validity of fields where zero is a
  2917. @@ -77,19 +84,33 @@
  2918. */
  2919. struct bootinfo
  2920. {
  2921. - unsigned int bi_version;
  2922. - unsigned char *bi_kernelname;
  2923. - struct nfs_diskless *bi_nfs_diskless;
  2924. + u32_t bi_version;
  2925. + u8_t *bi_kernelname;
  2926. + u32_t bi_nfs_diskless;
  2927. /* End of fields that are always present. */
  2928. #define bi_endcommon bi_n_bios_used
  2929. - unsigned int bi_n_bios_used;
  2930. - unsigned long bi_bios_geom[N_BIOS_GEOM];
  2931. - unsigned int bi_size;
  2932. - unsigned char bi_memsizes_valid;
  2933. - unsigned char bi_bios_dev;
  2934. - unsigned char bi_pad[2];
  2935. - unsigned long bi_basemem;
  2936. - unsigned long bi_extmem;
  2937. - unsigned long bi_symtab;
  2938. - unsigned long bi_esymtab;
  2939. + u32_t bi_n_bios_used;
  2940. + u32_t bi_bios_geom[N_BIOS_GEOM];
  2941. + u32_t bi_size;
  2942. + u8_t bi_memsizes_valid;
  2943. + u8_t bi_bios_dev;
  2944. + u8_t bi_pad[2];
  2945. + u32_t bi_basemem;
  2946. + u32_t bi_extmem;
  2947. + u32_t bi_symtab;
  2948. + u32_t bi_esymtab;
  2949. + /* Items below only from advanced bootloader */
  2950. + u32_t bi_kernend;
  2951. + u32_t bi_envp;
  2952. + u32_t bi_modulep;
  2953. };
  2954. +
  2955. +#define MODINFO_END 0x0000 /* End of list */
  2956. +#define MODINFO_NAME 0x0001 /* Name of module (string) */
  2957. +#define MODINFO_TYPE 0x0002 /* Type of module (string) */
  2958. +#define MODINFO_ADDR 0x0003 /* Loaded address */
  2959. +#define MODINFO_SIZE 0x0004 /* Size of module */
  2960. +#define MODINFO_EMPTY 0x0005 /* Has been deleted */
  2961. +#define MODINFO_ARGS 0x0006 /* Parameters string */
  2962. +#define MODINFO_METADATA 0x8000 /* Module-specfic */
  2963. +
  2964. diff -Naur grub-0.97.orig/stage2/graphics.c grub-0.97/stage2/graphics.c
  2965. --- grub-0.97.orig/stage2/graphics.c 1969-12-31 16:00:00.000000000 -0800
  2966. +++ grub-0.97/stage2/graphics.c 2006-07-03 23:58:41.000000000 -0700
  2967. @@ -0,0 +1,585 @@
  2968. +/*
  2969. + * graphics.c - graphics mode support for GRUB
  2970. + * Implemented as a terminal type by Jeremy Katz <[email protected]> based
  2971. + * on a patch by Paulo César Pereira de Andrade <[email protected]>
  2972. + * Options and enhancements made by Herton Ronaldo Krzesinski
  2973. + * <[email protected]>
  2974. + *
  2975. + * GRUB -- GRand Unified Bootloader
  2976. + * Copyright (C) 2001,2002 Red Hat, Inc.
  2977. + * Portions copyright (C) 2000 Conectiva, Inc.
  2978. + *
  2979. + * This program is free software; you can redistribute it and/or modify
  2980. + * it under the terms of the GNU General Public License as published by
  2981. + * the Free Software Foundation; either version 2 of the License, or
  2982. + * (at your option) any later version.
  2983. + *
  2984. + * This program is distributed in the hope that it will be useful,
  2985. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  2986. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2987. + * GNU General Public License for more details.
  2988. + *
  2989. + * You should have received a copy of the GNU General Public License
  2990. + * along with this program; if not, write to the Free Software
  2991. + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  2992. + */
  2993. +
  2994. +#ifdef SUPPORT_GRAPHICS
  2995. +
  2996. +#include <term.h>
  2997. +#include <shared.h>
  2998. +#include <graphics.h>
  2999. +
  3000. +int saved_videomode;
  3001. +unsigned char *font8x16;
  3002. +
  3003. +int graphics_inited = 0;
  3004. +static char splashimage[256];
  3005. +
  3006. +int shade = 1, no_cursor = 0;
  3007. +
  3008. +#define VSHADOW VSHADOW1
  3009. +unsigned char VSHADOW1[38400];
  3010. +unsigned char VSHADOW2[38400];
  3011. +unsigned char VSHADOW4[38400];
  3012. +unsigned char VSHADOW8[38400];
  3013. +
  3014. +/* define the default viewable area */
  3015. +int view_x0 = 0;
  3016. +int view_y0 = 0;
  3017. +int view_x1 = 80;
  3018. +int view_y1 = 30;
  3019. +
  3020. +/* text buffer has to be kept around so that we can write things as we
  3021. + * scroll and the like */
  3022. +unsigned short text[80 * 30];
  3023. +
  3024. +/* graphics options */
  3025. +int foreground = (63 << 16) | (63 << 8) | (63), background = 0, window_border = 0;
  3026. +
  3027. +/* current position */
  3028. +static int fontx = 0;
  3029. +static int fonty = 0;
  3030. +
  3031. +/* global state so that we don't try to recursively scroll or cursor */
  3032. +static int no_scroll = 0;
  3033. +
  3034. +/* color state */
  3035. +static int graphics_standard_color = A_NORMAL;
  3036. +static int graphics_normal_color = A_NORMAL;
  3037. +static int graphics_highlight_color = A_REVERSE;
  3038. +static int graphics_current_color = A_NORMAL;
  3039. +static color_state graphics_color_state = COLOR_STATE_STANDARD;
  3040. +
  3041. +static inline void outb(unsigned short port, unsigned char val)
  3042. +{
  3043. + __asm __volatile ("outb %0,%1"::"a" (val), "d" (port));
  3044. +}
  3045. +
  3046. +static void MapMask(int value) {
  3047. + outb(0x3c4, 2);
  3048. + outb(0x3c5, value);
  3049. +}
  3050. +
  3051. +/* bit mask register */
  3052. +static void BitMask(int value) {
  3053. + outb(0x3ce, 8);
  3054. + outb(0x3cf, value);
  3055. +}
  3056. +
  3057. +/* move the graphics cursor location to col, row */
  3058. +static void graphics_setxy(int col, int row) {
  3059. + if (col >= view_x0 && col < view_x1) {
  3060. + fontx = col;
  3061. + cursorX = col << 3;
  3062. + }
  3063. + if (row >= view_y0 && row < view_y1) {
  3064. + fonty = row;
  3065. + cursorY = row << 4;
  3066. + }
  3067. +}
  3068. +
  3069. +/* scroll the screen */
  3070. +static void graphics_scroll() {
  3071. + int i, j, k;
  3072. +
  3073. + /* we don't want to scroll recursively... that would be bad */
  3074. + if (no_scroll)
  3075. + return;
  3076. + no_scroll = 1;
  3077. +
  3078. + /* disable pager temporarily */
  3079. + k = count_lines;
  3080. + count_lines = -1;
  3081. +
  3082. + /* move everything up a line */
  3083. + for (j = view_y0 + 1; j < view_y1; j++) {
  3084. + graphics_gotoxy(view_x0, j - 1);
  3085. + for (i = view_x0; i < view_x1; i++) {
  3086. + graphics_putchar(text[j * 80 + i]);
  3087. + }
  3088. + }
  3089. +
  3090. + /* last line should be blank */
  3091. + graphics_gotoxy(view_x0, view_y1 - 1);
  3092. + for (i = view_x0; i < view_x1; i++)
  3093. + graphics_putchar(' ');
  3094. + graphics_setxy(view_x0, view_y1 - 1);
  3095. +
  3096. + count_lines = k;
  3097. +
  3098. + no_scroll = 0;
  3099. +}
  3100. +
  3101. +/* Set the splash image */
  3102. +void graphics_set_splash(char *splashfile) {
  3103. + grub_strcpy(splashimage, splashfile);
  3104. +}
  3105. +
  3106. +/* Get the current splash image */
  3107. +char *graphics_get_splash(void) {
  3108. + return splashimage;
  3109. +}
  3110. +
  3111. +/*
  3112. + * Initialize a vga16 graphics display with the palette based off of
  3113. + * the image in splashimage. If the image doesn't exist, leave graphics
  3114. + * mode. The mode initiated is 12h. From "Ralf Brown's Interrupt List":
  3115. + * text/ text pixel pixel colors disply scrn system
  3116. + * grph resol box resolution pages addr
  3117. + * 12h G 80x30 8x16 640x480 16/256K . A000 VGA,ATI VIP
  3118. + * G 80x30 8x16 640x480 16/64 . A000 ATI EGA Wonder
  3119. + * G . . 640x480 16 . . UltraVision+256K EGA
  3120. + */
  3121. +int graphics_init()
  3122. +{
  3123. + if (!graphics_inited) {
  3124. + saved_videomode = set_videomode(0x12);
  3125. + if (get_videomode() != 0x12) {
  3126. + set_videomode(saved_videomode);
  3127. + return 0;
  3128. + }
  3129. + graphics_inited = 1;
  3130. + }
  3131. + else
  3132. + return 1;
  3133. +
  3134. + font8x16 = (unsigned char*)graphics_get_font();
  3135. +
  3136. + /* make sure that the highlight color is set correctly */
  3137. + graphics_highlight_color = ((graphics_normal_color >> 4) |
  3138. + ((graphics_normal_color & 0xf) << 4));
  3139. +
  3140. + graphics_cls();
  3141. +
  3142. + if (!read_image(splashimage)) {
  3143. + grub_printf("Failed to read splash image (%s)\n", splashimage);
  3144. + grub_printf("Press any key to continue...");
  3145. + getkey();
  3146. + set_videomode(saved_videomode);
  3147. + graphics_inited = 0;
  3148. + return 0;
  3149. + }
  3150. +
  3151. + set_int1c_handler();
  3152. +
  3153. + return 1;
  3154. +}
  3155. +
  3156. +/* Leave graphics mode */
  3157. +void graphics_end(void)
  3158. +{
  3159. + if (graphics_inited) {
  3160. + unset_int1c_handler();
  3161. + set_videomode(saved_videomode);
  3162. + graphics_inited = 0;
  3163. + no_cursor = 0;
  3164. + }
  3165. +}
  3166. +
  3167. +/* Print ch on the screen. Handle any needed scrolling or the like */
  3168. +void graphics_putchar(int ch) {
  3169. + ch &= 0xff;
  3170. +
  3171. + graphics_cursor(0);
  3172. +
  3173. + if (ch == '\n') {
  3174. + if (fonty + 1 < view_y1)
  3175. + graphics_setxy(fontx, fonty + 1);
  3176. + else
  3177. + graphics_scroll();
  3178. + graphics_cursor(1);
  3179. + return;
  3180. + } else if (ch == '\r') {
  3181. + graphics_setxy(view_x0, fonty);
  3182. + graphics_cursor(1);
  3183. + return;
  3184. + }
  3185. +
  3186. + graphics_cursor(0);
  3187. +
  3188. + text[fonty * 80 + fontx] = ch;
  3189. + text[fonty * 80 + fontx] &= 0x00ff;
  3190. + if (graphics_current_color & 0xf0)
  3191. + text[fonty * 80 + fontx] |= 0x100;
  3192. +
  3193. + graphics_cursor(0);
  3194. +
  3195. + if ((fontx + 1) >= view_x1) {
  3196. + graphics_setxy(view_x0, fonty);
  3197. + if (fonty + 1 < view_y1)
  3198. + graphics_setxy(view_x0, fonty + 1);
  3199. + else
  3200. + graphics_scroll();
  3201. + graphics_cursor(1);
  3202. + do_more ();
  3203. + graphics_cursor(0);
  3204. + } else {
  3205. + graphics_setxy(fontx + 1, fonty);
  3206. + }
  3207. +
  3208. + graphics_cursor(1);
  3209. +}
  3210. +
  3211. +/* get the current location of the cursor */
  3212. +int graphics_getxy(void) {
  3213. + return (fontx << 8) | fonty;
  3214. +}
  3215. +
  3216. +void graphics_gotoxy(int x, int y) {
  3217. + graphics_cursor(0);
  3218. +
  3219. + graphics_setxy(x, y);
  3220. +
  3221. + graphics_cursor(1);
  3222. +}
  3223. +
  3224. +void graphics_cls(void) {
  3225. + int i;
  3226. + unsigned char *mem, *s1, *s2, *s4, *s8;
  3227. +
  3228. + graphics_cursor(0);
  3229. + graphics_gotoxy(view_x0, view_y0);
  3230. +
  3231. + mem = (unsigned char*)VIDEOMEM;
  3232. + s1 = (unsigned char*)VSHADOW1;
  3233. + s2 = (unsigned char*)VSHADOW2;
  3234. + s4 = (unsigned char*)VSHADOW4;
  3235. + s8 = (unsigned char*)VSHADOW8;
  3236. +
  3237. + for (i = 0; i < 80 * 30; i++)
  3238. + text[i] = ' ';
  3239. + graphics_cursor(1);
  3240. +
  3241. + BitMask(0xff);
  3242. +
  3243. + /* plane 1 */
  3244. + MapMask(1);
  3245. + grub_memcpy(mem, s1, 38400);
  3246. +
  3247. + /* plane 2 */
  3248. + MapMask(2);
  3249. + grub_memcpy(mem, s2, 38400);
  3250. +
  3251. + /* plane 3 */
  3252. + MapMask(4);
  3253. + grub_memcpy(mem, s4, 38400);
  3254. +
  3255. + /* plane 4 */
  3256. + MapMask(8);
  3257. + grub_memcpy(mem, s8, 38400);
  3258. +
  3259. + MapMask(15);
  3260. +
  3261. + if (no_cursor) {
  3262. + no_cursor = 0;
  3263. + set_int1c_handler();
  3264. + }
  3265. +}
  3266. +
  3267. +void graphics_setcolorstate (color_state state) {
  3268. + switch (state) {
  3269. + case COLOR_STATE_STANDARD:
  3270. + graphics_current_color = graphics_standard_color;
  3271. + break;
  3272. + case COLOR_STATE_NORMAL:
  3273. + graphics_current_color = graphics_normal_color;
  3274. + break;
  3275. + case COLOR_STATE_HIGHLIGHT:
  3276. + graphics_current_color = graphics_highlight_color;
  3277. + break;
  3278. + default:
  3279. + graphics_current_color = graphics_standard_color;
  3280. + break;
  3281. + }
  3282. +
  3283. + graphics_color_state = state;
  3284. +}
  3285. +
  3286. +void graphics_setcolor (int normal_color, int highlight_color) {
  3287. + graphics_normal_color = normal_color;
  3288. + graphics_highlight_color = highlight_color;
  3289. +
  3290. + graphics_setcolorstate (graphics_color_state);
  3291. +}
  3292. +
  3293. +int graphics_setcursor (int on) {
  3294. + if (!no_cursor && !on) {
  3295. + no_cursor = 1;
  3296. + unset_int1c_handler();
  3297. + graphics_cursor(0);
  3298. + }
  3299. + else if(no_cursor && on) {
  3300. + no_cursor = 0;
  3301. + set_int1c_handler();
  3302. + graphics_cursor(1);
  3303. + }
  3304. + return 0;
  3305. +}
  3306. +
  3307. +/* Read in the splashscreen image and set the palette up appropriately.
  3308. + * Format of splashscreen is an xpm (can be gzipped) with 16 colors and
  3309. + * 640x480. */
  3310. +int read_image(char *s)
  3311. +{
  3312. + char buf[32], pal[16], c;
  3313. + unsigned char base, mask, *s1, *s2, *s4, *s8;
  3314. + unsigned i, len, idx, colors, x, y, width, height;
  3315. +
  3316. + if (!grub_open(s))
  3317. + return 0;
  3318. +
  3319. + /* read header */
  3320. + if (!grub_read((char*)&buf, 10) || grub_memcmp(buf, "/* XPM */\n", 10)) {
  3321. + grub_close();
  3322. + return 0;
  3323. + }
  3324. +
  3325. + /* parse info */
  3326. + while (grub_read(&c, 1)) {
  3327. + if (c == '"')
  3328. + break;
  3329. + }
  3330. +
  3331. + while (grub_read(&c, 1) && (c == ' ' || c == '\t'))
  3332. + ;
  3333. +
  3334. + i = 0;
  3335. + width = c - '0';
  3336. + while (grub_read(&c, 1)) {
  3337. + if (c >= '0' && c <= '9')
  3338. + width = width * 10 + c - '0';
  3339. + else
  3340. + break;
  3341. + }
  3342. + while (grub_read(&c, 1) && (c == ' ' || c == '\t'))
  3343. + ;
  3344. +
  3345. + height = c - '0';
  3346. + while (grub_read(&c, 1)) {
  3347. + if (c >= '0' && c <= '9')
  3348. + height = height * 10 + c - '0';
  3349. + else
  3350. + break;
  3351. + }
  3352. + while (grub_read(&c, 1) && (c == ' ' || c == '\t'))
  3353. + ;
  3354. +
  3355. + colors = c - '0';
  3356. + while (grub_read(&c, 1)) {
  3357. + if (c >= '0' && c <= '9')
  3358. + colors = colors * 10 + c - '0';
  3359. + else
  3360. + break;
  3361. + }
  3362. +
  3363. + base = 0;
  3364. + while (grub_read(&c, 1) && c != '"')
  3365. + ;
  3366. +
  3367. + /* palette */
  3368. + for (i = 0, idx = 1; i < colors; i++) {
  3369. + len = 0;
  3370. +
  3371. + while (grub_read(&c, 1) && c != '"')
  3372. + ;
  3373. + grub_read(&c, 1); /* char */
  3374. + base = c;
  3375. + grub_read(buf, 4); /* \t c # */
  3376. +
  3377. + while (grub_read(&c, 1) && c != '"') {
  3378. + if (len < sizeof(buf))
  3379. + buf[len++] = c;
  3380. + }
  3381. +
  3382. + if (len == 6 && idx < 15) {
  3383. + int r = ((hex(buf[0]) << 4) | hex(buf[1])) >> 2;
  3384. + int g = ((hex(buf[2]) << 4) | hex(buf[3])) >> 2;
  3385. + int b = ((hex(buf[4]) << 4) | hex(buf[5])) >> 2;
  3386. +
  3387. + pal[idx] = base;
  3388. + graphics_set_palette(idx, r, g, b);
  3389. + ++idx;
  3390. + }
  3391. + }
  3392. +
  3393. + x = y = len = 0;
  3394. +
  3395. + s1 = (unsigned char*)VSHADOW1;
  3396. + s2 = (unsigned char*)VSHADOW2;
  3397. + s4 = (unsigned char*)VSHADOW4;
  3398. + s8 = (unsigned char*)VSHADOW8;
  3399. +
  3400. + for (i = 0; i < 38400; i++)
  3401. + s1[i] = s2[i] = s4[i] = s8[i] = 0;
  3402. +
  3403. + /* parse xpm data */
  3404. + while (y < height) {
  3405. + while (1) {
  3406. + if (!grub_read(&c, 1)) {
  3407. + grub_close();
  3408. + return 0;
  3409. + }
  3410. + if (c == '"')
  3411. + break;
  3412. + }
  3413. +
  3414. + while (grub_read(&c, 1) && c != '"') {
  3415. + for (i = 1; i < 15; i++)
  3416. + if (pal[i] == c) {
  3417. + c = i;
  3418. + break;
  3419. + }
  3420. +
  3421. + mask = 0x80 >> (x & 7);
  3422. + if (c & 1)
  3423. + s1[len + (x >> 3)] |= mask;
  3424. + if (c & 2)
  3425. + s2[len + (x >> 3)] |= mask;
  3426. + if (c & 4)
  3427. + s4[len + (x >> 3)] |= mask;
  3428. + if (c & 8)
  3429. + s8[len + (x >> 3)] |= mask;
  3430. +
  3431. + if (++x >= 640) {
  3432. + x = 0;
  3433. +
  3434. + if (y < 480)
  3435. + len += 80;
  3436. + ++y;
  3437. + }
  3438. + }
  3439. + }
  3440. +
  3441. + grub_close();
  3442. +
  3443. + graphics_set_palette(0, (background >> 16), (background >> 8) & 63,
  3444. + background & 63);
  3445. + graphics_set_palette(15, (foreground >> 16), (foreground >> 8) & 63,
  3446. + foreground & 63);
  3447. + graphics_set_palette(0x11, (window_border >> 16), (window_border >> 8) & 63,
  3448. + window_border & 63);
  3449. +
  3450. + return 1;
  3451. +}
  3452. +
  3453. +/* Convert a character which is a hex digit to the appropriate integer */
  3454. +int hex(int v)
  3455. +{
  3456. + if (v >= 'A' && v <= 'F')
  3457. + return (v - 'A' + 10);
  3458. + if (v >= 'a' && v <= 'f')
  3459. + return (v - 'a' + 10);
  3460. + return (v - '0');
  3461. +}
  3462. +
  3463. +void graphics_cursor(int set) {
  3464. + unsigned char *pat, *mem, *ptr, chr[16 << 2];
  3465. + int i, ch, invert, offset;
  3466. +
  3467. + if (set && (no_cursor || no_scroll))
  3468. + return;
  3469. +
  3470. + offset = cursorY * 80 + fontx;
  3471. + ch = text[fonty * 80 + fontx] & 0xff;
  3472. + invert = (text[fonty * 80 + fontx] & 0xff00) != 0;
  3473. + pat = font8x16 + (ch << 4);
  3474. +
  3475. + mem = (unsigned char*)VIDEOMEM + offset;
  3476. +
  3477. + if (!set) {
  3478. + for (i = 0; i < 16; i++) {
  3479. + unsigned char mask = pat[i];
  3480. +
  3481. + if (!invert) {
  3482. + chr[i ] = ((unsigned char*)VSHADOW1)[offset];
  3483. + chr[16 + i] = ((unsigned char*)VSHADOW2)[offset];
  3484. + chr[32 + i] = ((unsigned char*)VSHADOW4)[offset];
  3485. + chr[48 + i] = ((unsigned char*)VSHADOW8)[offset];
  3486. +
  3487. + if (shade) {
  3488. + if (ch == DISP_VERT || ch == DISP_LL ||
  3489. + ch == DISP_UR || ch == DISP_LR) {
  3490. + unsigned char pmask = ~(pat[i] >> 1);
  3491. +
  3492. + chr[i ] &= pmask;
  3493. + chr[16 + i] &= pmask;
  3494. + chr[32 + i] &= pmask;
  3495. + chr[48 + i] &= pmask;
  3496. + }
  3497. + if (i > 0 && ch != DISP_VERT) {
  3498. + unsigned char pmask = ~(pat[i - 1] >> 1);
  3499. +
  3500. + chr[i ] &= pmask;
  3501. + chr[16 + i] &= pmask;
  3502. + chr[32 + i] &= pmask;
  3503. + chr[48 + i] &= pmask;
  3504. + if (ch == DISP_HORIZ || ch == DISP_UR || ch == DISP_LR) {
  3505. + pmask = ~pat[i - 1];
  3506. +
  3507. + chr[i ] &= pmask;
  3508. + chr[16 + i] &= pmask;
  3509. + chr[32 + i] &= pmask;
  3510. + chr[48 + i] &= pmask;
  3511. + }
  3512. + }
  3513. + }
  3514. + chr[i ] |= mask;
  3515. + chr[16 + i] |= mask;
  3516. + chr[32 + i] |= mask;
  3517. + chr[48 + i] |= mask;
  3518. +
  3519. + offset += 80;
  3520. + }
  3521. + else {
  3522. + chr[i ] = mask;
  3523. + chr[16 + i] = mask;
  3524. + chr[32 + i] = mask;
  3525. + chr[48 + i] = mask;
  3526. + }
  3527. + }
  3528. + }
  3529. + else {
  3530. + MapMask(15);
  3531. + ptr = mem;
  3532. + for (i = 0; i < 16; i++, ptr += 80) {
  3533. + cursorBuf[i] = pat[i];
  3534. + *ptr = ~pat[i];
  3535. + }
  3536. + return;
  3537. + }
  3538. +
  3539. + offset = 0;
  3540. + for (i = 1; i < 16; i <<= 1, offset += 16) {
  3541. + int j;
  3542. +
  3543. + MapMask(i);
  3544. + ptr = mem;
  3545. + for (j = 0; j < 16; j++, ptr += 80)
  3546. + *ptr = chr[j + offset];
  3547. + }
  3548. +
  3549. + MapMask(15);
  3550. +}
  3551. +
  3552. +#endif /* SUPPORT_GRAPHICS */
  3553. diff -Naur grub-0.97.orig/stage2/graphics.h grub-0.97/stage2/graphics.h
  3554. --- grub-0.97.orig/stage2/graphics.h 1969-12-31 16:00:00.000000000 -0800
  3555. +++ grub-0.97/stage2/graphics.h 2006-07-03 23:58:41.000000000 -0700
  3556. @@ -0,0 +1,44 @@
  3557. +/* graphics.h - graphics console interface */
  3558. +/*
  3559. + * GRUB -- GRand Unified Bootloader
  3560. + * Copyright (C) 2002 Free Software Foundation, Inc.
  3561. + *
  3562. + * This program is free software; you can redistribute it and/or modify
  3563. + * it under the terms of the GNU General Public License as published by
  3564. + * the Free Software Foundation; either version 2 of the License, or
  3565. + * (at your option) any later version.
  3566. + *
  3567. + * This program is distributed in the hope that it will be useful,
  3568. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  3569. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  3570. + * GNU General Public License for more details.
  3571. + *
  3572. + * You should have received a copy of the GNU General Public License
  3573. + * along with this program; if not, write to the Free Software
  3574. + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  3575. + */
  3576. +
  3577. +#ifndef GRAPHICS_H
  3578. +#define GRAPHICS_H
  3579. +
  3580. +/* magic constant */
  3581. +#define VIDEOMEM 0xA0000
  3582. +
  3583. +/* function prototypes */
  3584. +char *graphics_get_splash(void);
  3585. +
  3586. +int read_image(char *s);
  3587. +void graphics_cursor(int set);
  3588. +
  3589. +/* function prototypes for asm functions */
  3590. +void * graphics_get_font();
  3591. +void graphics_set_palette(int idx, int red, int green, int blue);
  3592. +void set_int1c_handler();
  3593. +void unset_int1c_handler();
  3594. +
  3595. +extern short cursorX, cursorY;
  3596. +extern char cursorBuf[16];
  3597. +extern int shade;
  3598. +extern int view_x0, view_y0, view_x1, view_y1;
  3599. +
  3600. +#endif /* GRAPHICS_H */
  3601. diff -Naur grub-0.97.orig/stage2/Makefile.am grub-0.97/stage2/Makefile.am
  3602. --- grub-0.97.orig/stage2/Makefile.am 2005-02-02 12:37:35.000000000 -0800
  3603. +++ grub-0.97/stage2/Makefile.am 2006-07-03 23:58:41.000000000 -0700
  3604. @@ -7,7 +7,7 @@
  3605. fat.h filesys.h freebsd.h fs.h hercules.h i386-elf.h \
  3606. imgact_aout.h iso9660.h jfs.h mb_header.h mb_info.h md5.h \
  3607. nbi.h pc_slice.h serial.h shared.h smp-imps.h term.h \
  3608. - terminfo.h tparm.h nbi.h ufs2.h vstafs.h xfs.h
  3609. + terminfo.h tparm.h nbi.h ufs2.h vstafs.h xfs.h graphics.h
  3610. EXTRA_DIST = setjmp.S apm.S $(noinst_SCRIPTS)
  3611. # For <stage1.h>.
  3612. @@ -19,7 +19,7 @@
  3613. disk_io.c fsys_ext2fs.c fsys_fat.c fsys_ffs.c fsys_iso9660.c \
  3614. fsys_jfs.c fsys_minix.c fsys_reiserfs.c fsys_ufs2.c \
  3615. fsys_vstafs.c fsys_xfs.c gunzip.c md5.c serial.c stage2.c \
  3616. - terminfo.c tparm.c
  3617. + terminfo.c tparm.c graphics.c
  3618. libgrub_a_CFLAGS = $(GRUB_CFLAGS) -I$(top_srcdir)/lib \
  3619. -DGRUB_UTIL=1 -DFSYS_EXT2FS=1 -DFSYS_FAT=1 -DFSYS_FFS=1 \
  3620. -DFSYS_ISO9660=1 -DFSYS_JFS=1 -DFSYS_MINIX=1 -DFSYS_REISERFS=1 \
  3621. @@ -79,8 +79,14 @@
  3622. HERCULES_FLAGS =
  3623. endif
  3624. +if GRAPHICS_SUPPORT
  3625. +GRAPHICS_FLAGS = -DSUPPORT_GRAPHICS=1
  3626. +else
  3627. +GRAPHICS_FLAGS =
  3628. +endif
  3629. +
  3630. STAGE2_COMPILE = $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3631. - $(NETBOOT_FLAGS) $(SERIAL_FLAGS) $(HERCULES_FLAGS)
  3632. + $(NETBOOT_FLAGS) $(SERIAL_FLAGS) $(HERCULES_FLAGS) $(GRAPHICS_FLAGS)
  3633. STAGE1_5_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,2000
  3634. STAGE1_5_COMPILE = $(STAGE2_COMPILE) -DNO_DECOMPRESSION=1 -DSTAGE1_5=1
  3635. @@ -90,7 +96,8 @@
  3636. cmdline.c common.c console.c disk_io.c fsys_ext2fs.c \
  3637. fsys_fat.c fsys_ffs.c fsys_iso9660.c fsys_jfs.c fsys_minix.c \
  3638. fsys_reiserfs.c fsys_ufs2.c fsys_vstafs.c fsys_xfs.c gunzip.c \
  3639. - hercules.c md5.c serial.c smp-imps.c stage2.c terminfo.c tparm.c
  3640. + hercules.c md5.c serial.c smp-imps.c stage2.c terminfo.c tparm.c \
  3641. + graphics.c
  3642. pre_stage2_exec_CFLAGS = $(STAGE2_COMPILE) $(FSYS_CFLAGS)
  3643. pre_stage2_exec_CCASFLAGS = $(STAGE2_COMPILE) $(FSYS_CFLAGS)
  3644. pre_stage2_exec_LDFLAGS = $(PRE_STAGE2_LINK)
  3645. diff -Naur grub-0.97.orig/stage2/shared.h grub-0.97/stage2/shared.h
  3646. --- grub-0.97.orig/stage2/shared.h 2004-06-19 09:40:09.000000000 -0700
  3647. +++ grub-0.97/stage2/shared.h 2006-07-04 00:01:50.000000000 -0700
  3648. @@ -499,7 +499,11 @@
  3649. unsigned char linear_reserved_field_position;
  3650. unsigned long max_pixel_clock;
  3651. - unsigned char reserved3[189];
  3652. + /* Reserved field to make structure to be 256 bytes long, VESA BIOS
  3653. + Extension 3.0 Specification says to reserve 189 bytes here but
  3654. + that doesn't make structure to be 256 bytes. So additional one is
  3655. + added here. */
  3656. + unsigned char reserved3[189 + 1];
  3657. } __attribute__ ((packed));
  3658. @@ -792,6 +796,11 @@
  3659. /* Set the cursor position. */
  3660. void gotoxy (int x, int y);
  3661. +/* Internal pager
  3662. + Returns 1 = if pager was used
  3663. + 0 = if pager wasn't used */
  3664. +int do_more (void);
  3665. +
  3666. /* Displays an ASCII character. IBM displays will translate some
  3667. characters to special graphical ones (see the DISP_* constants). */
  3668. void grub_putchar (int c);
  3669. @@ -871,6 +880,7 @@
  3670. int grub_tolower (int c);
  3671. int grub_isspace (int c);
  3672. int grub_strncat (char *s1, const char *s2, int n);
  3673. +void grub_memcpy(void *dest, const void *src, int len);
  3674. void *grub_memmove (void *to, const void *from, int len);
  3675. void *grub_memset (void *start, int c, int len);
  3676. int grub_strncat (char *s1, const char *s2, int n);
  3677. @@ -911,7 +921,7 @@
  3678. int nul_terminate (char *str);
  3679. int get_based_digit (int c, int base);
  3680. int safe_parse_maxint (char **str_ptr, int *myint_ptr);
  3681. -int memcheck (int start, int len);
  3682. +int memcheck (unsigned long int start, unsigned long int len);
  3683. void grub_putstr (const char *str);
  3684. #ifndef NO_DECOMPRESSION
  3685. diff -Naur grub-0.97.orig/stage2/stage2.c grub-0.97/stage2/stage2.c
  3686. --- grub-0.97.orig/stage2/stage2.c 2005-03-19 09:51:57.000000000 -0800
  3687. +++ grub-0.97/stage2/stage2.c 2006-07-04 00:01:50.000000000 -0700
  3688. @@ -20,6 +20,12 @@
  3689. #include <shared.h>
  3690. #include <term.h>
  3691. +#ifdef SUPPORT_GRAPHICS
  3692. +# include <graphics.h>
  3693. +#endif
  3694. +
  3695. +int col_start, col_end, row_start, box_size;
  3696. +
  3697. grub_jmp_buf restart_env;
  3698. #if defined(PRESET_MENU_STRING) || defined(SUPPORT_DISKLESS)
  3699. @@ -105,13 +111,13 @@
  3700. if (highlight && current_term->setcolorstate)
  3701. current_term->setcolorstate (COLOR_STATE_HIGHLIGHT);
  3702. - gotoxy (2, y);
  3703. + gotoxy (2 + col_start, y);
  3704. grub_putchar (' ');
  3705. - for (x = 3; x < 75; x++)
  3706. + for (x = 3 + col_start; x < (col_end - 5); x++)
  3707. {
  3708. - if (*entry && x <= 72)
  3709. + if (*entry && x <= (col_end - 8))
  3710. {
  3711. - if (x == 72)
  3712. + if (x == (col_end - 8))
  3713. grub_putchar (DISP_RIGHT);
  3714. else
  3715. grub_putchar (*entry++);
  3716. @@ -119,7 +125,7 @@
  3717. else
  3718. grub_putchar (' ');
  3719. }
  3720. - gotoxy (74, y);
  3721. + gotoxy ((col_end - 6), y);
  3722. if (current_term->setcolorstate)
  3723. current_term->setcolorstate (COLOR_STATE_STANDARD);
  3724. @@ -131,7 +137,7 @@
  3725. {
  3726. int i;
  3727. - gotoxy (77, y + 1);
  3728. + gotoxy ((col_end - 3), y + 1);
  3729. if (first)
  3730. grub_putchar (DISP_UP);
  3731. @@ -151,14 +157,14 @@
  3732. menu_entries++;
  3733. }
  3734. - gotoxy (77, y + size);
  3735. + gotoxy ((col_end - 3), y + size);
  3736. if (*menu_entries)
  3737. grub_putchar (DISP_DOWN);
  3738. else
  3739. grub_putchar (' ');
  3740. - gotoxy (74, y + entryno + 1);
  3741. + gotoxy ((col_end - 6), y + entryno + 1);
  3742. }
  3743. static void
  3744. @@ -196,30 +202,30 @@
  3745. if (current_term->setcolorstate)
  3746. current_term->setcolorstate (COLOR_STATE_NORMAL);
  3747. - gotoxy (1, y);
  3748. + gotoxy (1 + col_start, y);
  3749. grub_putchar (DISP_UL);
  3750. - for (i = 0; i < 73; i++)
  3751. + for (i = col_start; i < (col_end - 7); i++)
  3752. grub_putchar (DISP_HORIZ);
  3753. grub_putchar (DISP_UR);
  3754. i = 1;
  3755. while (1)
  3756. {
  3757. - gotoxy (1, y + i);
  3758. + gotoxy (1 + col_start, y + i);
  3759. if (i > size)
  3760. break;
  3761. grub_putchar (DISP_VERT);
  3762. - gotoxy (75, y + i);
  3763. + gotoxy ((col_end - 5), y + i);
  3764. grub_putchar (DISP_VERT);
  3765. i++;
  3766. }
  3767. grub_putchar (DISP_LL);
  3768. - for (i = 0; i < 73; i++)
  3769. + for (i = col_start; i < (col_end - 7); i++)
  3770. grub_putchar (DISP_HORIZ);
  3771. grub_putchar (DISP_LR);
  3772. @@ -233,6 +239,7 @@
  3773. {
  3774. int c, time1, time2 = -1, first_entry = 0;
  3775. char *cur_entry = 0;
  3776. + struct term_entry *prev_term = NULL;
  3777. /*
  3778. * Main loop for menu UI.
  3779. @@ -250,6 +257,22 @@
  3780. }
  3781. }
  3782. + col_start = 0;
  3783. + col_end = 80;
  3784. + row_start = 0;
  3785. + box_size = 12;
  3786. + /* if we're using viewport we need to make sure to setup
  3787. + coordinates correctly. */
  3788. +#ifdef SUPPORT_GRAPHICS
  3789. + if (grub_memcmp (current_term->name, "graphics", sizeof ("graphics") - 1) == 0)
  3790. + {
  3791. + col_start = view_x0;
  3792. + col_end = view_x1;
  3793. + row_start = view_y0;
  3794. + box_size = (view_y1 - view_y0) - 13;
  3795. + }
  3796. +#endif
  3797. +
  3798. /* If the timeout was expired or wasn't set, force to show the menu
  3799. interface. */
  3800. if (grub_timeout < 0)
  3801. @@ -302,36 +325,36 @@
  3802. if (current_term->flags & TERM_DUMB)
  3803. print_entries_raw (num_entries, first_entry, menu_entries);
  3804. else
  3805. - print_border (3, 12);
  3806. + print_border (3 + row_start, box_size);
  3807. grub_printf ("\n\
  3808. - Use the %c and %c keys to select which entry is highlighted.\n",
  3809. + Use the %c and %c keys to select which entry is highlighted.\n",
  3810. DISP_UP, DISP_DOWN);
  3811. if (! auth && password)
  3812. {
  3813. printf ("\
  3814. - Press enter to boot the selected OS or \'p\' to enter a\n\
  3815. - password to unlock the next set of features.");
  3816. + Press enter to boot the selected OS or \'p\' to enter a\n\
  3817. + password to unlock the next set of features.");
  3818. }
  3819. else
  3820. {
  3821. if (config_entries)
  3822. printf ("\
  3823. - Press enter to boot the selected OS, \'e\' to edit the\n\
  3824. - commands before booting, or \'c\' for a command-line.");
  3825. + Press enter to boot the selected OS, \'e\' to edit the\n\
  3826. + commands before booting, or \'c\' for a command-line.");
  3827. else
  3828. printf ("\
  3829. - Press \'b\' to boot, \'e\' to edit the selected command in the\n\
  3830. - boot sequence, \'c\' for a command-line, \'o\' to open a new line\n\
  3831. - after (\'O\' for before) the selected line, \'d\' to remove the\n\
  3832. - selected line, or escape to go back to the main menu.");
  3833. + Press \'b\' to boot, \'e\' to edit the selected command in the\n\
  3834. + boot sequence, \'c\' for a command-line, \'o\' to open a new line\n\
  3835. + after (\'O\' for before) the selected line, \'d\' to remove the\n\
  3836. + selected line, or escape to go back to the main menu.");
  3837. }
  3838. if (current_term->flags & TERM_DUMB)
  3839. grub_printf ("\n\nThe selected entry is %d ", entryno);
  3840. else
  3841. - print_entries (3, 12, first_entry, entryno, menu_entries);
  3842. + print_entries (3 + row_start, box_size, first_entry, entryno, menu_entries);
  3843. }
  3844. /* XX using RT clock now, need to initialize value */
  3845. @@ -358,10 +381,10 @@
  3846. entryno, grub_timeout);
  3847. else
  3848. {
  3849. - gotoxy (3, 22);
  3850. - grub_printf ("The highlighted entry will be booted automatically in %d seconds. ",
  3851. + gotoxy (3 + col_start, 10 + box_size + row_start);
  3852. + grub_printf (" The highlighted entry will be booted automatically in %d seconds. ",
  3853. grub_timeout);
  3854. - gotoxy (74, 4 + entryno);
  3855. + gotoxy ((col_end - 6), 4 + entryno + row_start);
  3856. }
  3857. grub_timeout--;
  3858. @@ -387,12 +410,12 @@
  3859. if (current_term->flags & TERM_DUMB)
  3860. grub_putchar ('\r');
  3861. else
  3862. - gotoxy (3, 22);
  3863. + gotoxy (3 + col_start, 10 + box_size + row_start);
  3864. printf (" ");
  3865. grub_timeout = -1;
  3866. fallback_entryno = -1;
  3867. if (! (current_term->flags & TERM_DUMB))
  3868. - gotoxy (74, 4 + entryno);
  3869. + gotoxy ((col_end - 6), 4 + entryno + row_start);
  3870. }
  3871. /* We told them above (at least in SUPPORT_SERIAL) to use
  3872. @@ -408,12 +431,12 @@
  3873. {
  3874. if (entryno > 0)
  3875. {
  3876. - print_entry (4 + entryno, 0,
  3877. + print_entry (4 + entryno + row_start, 0,
  3878. get_entry (menu_entries,
  3879. first_entry + entryno,
  3880. 0));
  3881. entryno--;
  3882. - print_entry (4 + entryno, 1,
  3883. + print_entry (4 + entryno + row_start, 1,
  3884. get_entry (menu_entries,
  3885. first_entry + entryno,
  3886. 0));
  3887. @@ -421,7 +444,7 @@
  3888. else if (first_entry > 0)
  3889. {
  3890. first_entry--;
  3891. - print_entries (3, 12, first_entry, entryno,
  3892. + print_entries (3 + row_start, box_size, first_entry, entryno,
  3893. menu_entries);
  3894. }
  3895. }
  3896. @@ -433,29 +456,29 @@
  3897. entryno++;
  3898. else
  3899. {
  3900. - if (entryno < 11)
  3901. + if (entryno < (box_size - 1))
  3902. {
  3903. - print_entry (4 + entryno, 0,
  3904. + print_entry (4 + entryno + row_start, 0,
  3905. get_entry (menu_entries,
  3906. first_entry + entryno,
  3907. 0));
  3908. entryno++;
  3909. - print_entry (4 + entryno, 1,
  3910. + print_entry (4 + entryno + row_start, 1,
  3911. get_entry (menu_entries,
  3912. first_entry + entryno,
  3913. 0));
  3914. }
  3915. - else if (num_entries > 12 + first_entry)
  3916. + else if (num_entries > box_size + first_entry)
  3917. {
  3918. first_entry++;
  3919. - print_entries (3, 12, first_entry, entryno, menu_entries);
  3920. + print_entries (3 + row_start, box_size, first_entry, entryno, menu_entries);
  3921. }
  3922. }
  3923. }
  3924. else if (c == 7)
  3925. {
  3926. /* Page Up */
  3927. - first_entry -= 12;
  3928. + first_entry -= box_size;
  3929. if (first_entry < 0)
  3930. {
  3931. entryno += first_entry;
  3932. @@ -463,20 +486,20 @@
  3933. if (entryno < 0)
  3934. entryno = 0;
  3935. }
  3936. - print_entries (3, 12, first_entry, entryno, menu_entries);
  3937. + print_entries (3 + row_start, box_size, first_entry, entryno, menu_entries);
  3938. }
  3939. else if (c == 3)
  3940. {
  3941. /* Page Down */
  3942. - first_entry += 12;
  3943. + first_entry += box_size;
  3944. if (first_entry + entryno + 1 >= num_entries)
  3945. {
  3946. - first_entry = num_entries - 12;
  3947. + first_entry = num_entries - box_size;
  3948. if (first_entry < 0)
  3949. first_entry = 0;
  3950. entryno = num_entries - first_entry - 1;
  3951. }
  3952. - print_entries (3, 12, first_entry, entryno, menu_entries);
  3953. + print_entries (3 + row_start, box_size, first_entry, entryno, menu_entries);
  3954. }
  3955. if (config_entries)
  3956. @@ -489,7 +512,7 @@
  3957. if ((c == 'd') || (c == 'o') || (c == 'O'))
  3958. {
  3959. if (! (current_term->flags & TERM_DUMB))
  3960. - print_entry (4 + entryno, 0,
  3961. + print_entry (4 + entryno + row_start, 0,
  3962. get_entry (menu_entries,
  3963. first_entry + entryno,
  3964. 0));
  3965. @@ -537,7 +560,7 @@
  3966. if (entryno >= num_entries)
  3967. entryno--;
  3968. - if (first_entry && num_entries < 12 + first_entry)
  3969. + if (first_entry && num_entries < box_size + first_entry)
  3970. first_entry--;
  3971. }
  3972. @@ -549,7 +572,7 @@
  3973. grub_printf ("\n");
  3974. }
  3975. else
  3976. - print_entries (3, 12, first_entry, entryno, menu_entries);
  3977. + print_entries (3 + row_start, box_size, first_entry, entryno, menu_entries);
  3978. }
  3979. cur_entry = menu_entries;
  3980. @@ -570,7 +593,7 @@
  3981. if (current_term->flags & TERM_DUMB)
  3982. grub_printf ("\r ");
  3983. else
  3984. - gotoxy (1, 21);
  3985. + gotoxy (1 + col_start, 9 + box_size + row_start);
  3986. /* Wipe out the previously entered password */
  3987. grub_memset (entered, 0, sizeof (entered));
  3988. @@ -651,7 +674,10 @@
  3989. *(new_heap++) = 0;
  3990. if (config_entries)
  3991. - run_menu (heap, NULL, new_num_entries, new_heap, 0);
  3992. + {
  3993. + current_entryno = first_entry + entryno;
  3994. + run_menu (heap, NULL, new_num_entries, new_heap, 0);
  3995. + }
  3996. else
  3997. {
  3998. cls ();
  3999. @@ -714,6 +740,15 @@
  4000. cls ();
  4001. setcursor (1);
  4002. + /* if our terminal needed initialization, we should shut it down
  4003. + * before booting the kernel, but we want to save what it was so
  4004. + * we can come back if needed */
  4005. + prev_term = current_term;
  4006. + if (current_term->shutdown)
  4007. + {
  4008. + current_term->shutdown();
  4009. + current_term = term_table; /* assumption: console is first */
  4010. + }
  4011. while (1)
  4012. {
  4013. @@ -727,7 +762,8 @@
  4014. cur_entry = get_entry (config_entries, first_entry + entryno, 1);
  4015. /* Set CURRENT_ENTRYNO for the command "savedefault". */
  4016. - current_entryno = first_entry + entryno;
  4017. + if (config_entries)
  4018. + current_entryno = first_entry + entryno;
  4019. if (run_script (cur_entry, heap))
  4020. {
  4021. @@ -748,6 +784,13 @@
  4022. break;
  4023. }
  4024. + /* if we get back here, we should go back to what our term was before */
  4025. + current_term = prev_term;
  4026. + if (current_term->startup)
  4027. + /* if our terminal fails to initialize, fall back to console since
  4028. + * it should always work */
  4029. + if (current_term->startup() == 0)
  4030. + current_term = term_table; /* we know that console is first */
  4031. show_menu = 1;
  4032. goto restart;
  4033. }
  4034. @@ -891,8 +934,18 @@
  4035. len = grub_read (buf, sizeof (buf));
  4036. if (len > 0)
  4037. {
  4038. + char *tmp;
  4039. + char *def;
  4040. buf[sizeof (buf) - 1] = 0;
  4041. - safe_parse_maxint (&p, &saved_entryno);
  4042. +
  4043. + if((tmp = grub_strstr(p, ":")) != NULL)
  4044. + {
  4045. + *tmp++;
  4046. + grub_memcpy(&def, &tmp, sizeof(p));
  4047. + }else
  4048. + grub_memcpy(&def, &p, sizeof(p));
  4049. +
  4050. + safe_parse_maxint (&def, &saved_entryno);
  4051. }
  4052. grub_close ();
  4053. @@ -1050,6 +1103,16 @@
  4054. while (is_preset);
  4055. }
  4056. + /* go ahead and make sure the terminal is setup */
  4057. + if (current_term->startup)
  4058. + {
  4059. + /* If initialization fails, go back to default terminal */
  4060. + if (current_term->startup() == 0)
  4061. + {
  4062. + current_term = term_table;
  4063. + }
  4064. + }
  4065. +
  4066. if (! num_entries)
  4067. {
  4068. /* If no acceptable config file, goto command-line, starting
  4069. diff -Naur grub-0.97.orig/stage2/term.h grub-0.97/stage2/term.h
  4070. --- grub-0.97.orig/stage2/term.h 2003-07-09 04:45:53.000000000 -0700
  4071. +++ grub-0.97/stage2/term.h 2006-07-03 23:58:41.000000000 -0700
  4072. @@ -60,6 +60,8 @@
  4073. const char *name;
  4074. /* The feature flags defined above. */
  4075. unsigned long flags;
  4076. + /* Default for maximum number of lines if not specified */
  4077. + unsigned short max_lines;
  4078. /* Put a character. */
  4079. void (*putchar) (int c);
  4080. /* Check if any input character is available. */
  4081. @@ -79,6 +81,10 @@
  4082. void (*setcolor) (int normal_color, int highlight_color);
  4083. /* Turn on/off the cursor. */
  4084. int (*setcursor) (int on);
  4085. + /* function to start a terminal */
  4086. + int (*startup) (void);
  4087. + /* function to use to shutdown a terminal */
  4088. + void (*shutdown) (void);
  4089. };
  4090. /* This lists up available terminals. */
  4091. @@ -124,4 +130,24 @@
  4092. int hercules_setcursor (int on);
  4093. #endif
  4094. +#ifdef SUPPORT_GRAPHICS
  4095. +extern int foreground, background, window_border, graphics_inited, saved_videomode;
  4096. +
  4097. +void graphics_set_splash(char *splashfile);
  4098. +int set_videomode(int mode);
  4099. +int get_videomode(void);
  4100. +void graphics_putchar (int c);
  4101. +int graphics_getxy(void);
  4102. +void graphics_gotoxy(int x, int y);
  4103. +void graphics_cls(void);
  4104. +void graphics_setcolorstate (color_state state);
  4105. +void graphics_setcolor (int normal_color, int highlight_color);
  4106. +int graphics_setcursor (int on);
  4107. +int graphics_init(void);
  4108. +void graphics_end(void);
  4109. +
  4110. +int hex(int v);
  4111. +void graphics_set_palette(int idx, int red, int green, int blue);
  4112. +#endif /* SUPPORT_GRAPHICS */
  4113. +
  4114. #endif /* ! GRUB_TERM_HEADER */
  4115. diff -Naur grub-0.97.orig/THANKS grub-0.97/THANKS
  4116. --- grub-0.97.orig/THANKS 2005-05-07 19:17:43.000000000 -0700
  4117. +++ grub-0.97/THANKS 2006-07-04 00:01:50.000000000 -0700
  4118. @@ -121,3 +121,4 @@
  4119. Yedidyah Bar-David <[email protected]>
  4120. Yury V. Umanets <[email protected]>
  4121. Yuri Zaporogets <[email protected]>
  4122. +Vitaly Fertman <[email protected]>
  4123. diff -Naur grub-0.97.orig/util/grub-install.in grub-0.97/util/grub-install.in
  4124. --- grub-0.97.orig/util/grub-install.in 2004-07-24 11:57:31.000000000 -0700
  4125. +++ grub-0.97/util/grub-install.in 2006-07-04 00:01:50.000000000 -0700
  4126. @@ -81,6 +81,50 @@
  4127. EOF
  4128. }
  4129. +# Usage: getraid_mdadm mddevice
  4130. +# Routine to find a physical device from an md device
  4131. +# If found, the first grub BIOS device (from device.map) is returned
  4132. +# If no BIOS drives match the RAID devices, the first device returned
  4133. +# from mdadm -D is returned
  4134. +getraid_mdadm() {
  4135. + device=$1
  4136. + mdadm=$(mdadm -D "$device") || {
  4137. + echo "$PROG: mdadm -D $device failed" >&2
  4138. + exit 1
  4139. + }
  4140. + eval "$(
  4141. + echo "$mdadm" | awk '
  4142. + $1 == "Number" && $2 == "Major" { start = 1; next }
  4143. + $1 == "UUID" { print "uuid=" $3; start = 0; next }
  4144. + !start { next }
  4145. + $2 == 0 && $3 == 0 { next }
  4146. + { devices = devices "\n" $NF }
  4147. + END { print "devices='\''" devices "'\''" }
  4148. + '
  4149. + )"
  4150. +
  4151. + # Convert RAID devices list into a list of disks
  4152. + tmp_disks=`echo "$devices" | sed -e 's%\([sh]d[a-z]\)[0-9]*$%\1%' \
  4153. + -e 's%\(d[0-9]*\)p[0-9]*$%\1%' \
  4154. + -e 's%\(fd[0-9]*\)$%\1%' \
  4155. + -e 's%/part[0-9]*$%/disc%' \
  4156. + -e 's%\(c[0-7]d[0-9]*\).*$%\1%' \
  4157. + -e '/^$/d' |
  4158. + sed -n '1h;2,$H;${g;s/\n/|/g;p}'`
  4159. +
  4160. + # Find first BIOS disk that's a member of the RAID array
  4161. + # Default to first RAID member if no tmp_disks are BIOS devices
  4162. + set -- `egrep $tmp_disks $device_map | \
  4163. + sort | \
  4164. + sed -n 1p `
  4165. + device=${2:-${tmp_disks%%|*}}
  4166. +
  4167. + # Return first partition on BIOS disk that's part of the RAID
  4168. + echo "$devices" | \
  4169. + sed -n "\:${device}:p" | \
  4170. + sed -n 1p
  4171. +}
  4172. +
  4173. # Usage: convert os_device
  4174. # Convert an OS device to the corresponding GRUB drive.
  4175. # This part is OS-specific.
  4176. @@ -96,6 +140,10 @@
  4177. # Break the device name into the disk part and the partition part.
  4178. case "$host_os" in
  4179. linux*)
  4180. + # Find an actual physical device if we're passed a RAID device
  4181. + case $1 in
  4182. + /dev/md*) set -- `getraid_mdadm $1`
  4183. + esac
  4184. tmp_disk=`echo "$1" | sed -e 's%\([sh]d[a-z]\)[0-9]*$%\1%' \
  4185. -e 's%\(d[0-9]*\)p[0-9]*$%\1%' \
  4186. -e 's%\(fd[0-9]*\)$%\1%' \
  4187. @@ -112,8 +160,8 @@
  4188. tmp_disk=`echo "$1" | sed 's%\([sh]d[0-9]*\).*%\1%'`
  4189. tmp_part=`echo "$1" | sed "s%$tmp_disk%%"` ;;
  4190. freebsd* | kfreebsd*-gnu)
  4191. - tmp_disk=`echo "$1" | sed 's%r\{0,1\}\([saw]d[0-9]*\).*$%r\1%' \
  4192. - | sed 's%r\{0,1\}\(da[0-9]*\).*$%r\1%'`
  4193. + tmp_disk=`echo "$1" | sed 's%r\{0,1\}\([saw]d[0-9]*\).*$%\1%' \
  4194. + | sed 's%r\{0,1\}\(da[0-9]*\).*$%\1%'`
  4195. tmp_part=`echo "$1" \
  4196. | sed "s%.*/r\{0,1\}[saw]d[0-9]\(s[0-9]*[a-h]\)%\1%" \
  4197. | sed "s%.*/r\{0,1\}da[0-9]\(s[0-9]*[a-h]\)%\1%"`
  4198. @@ -131,7 +179,7 @@
  4199. # Get the drive name.
  4200. tmp_drive=`grep -v '^#' $device_map | grep "$tmp_disk *$" \
  4201. - | sed 's%.*\(([hf]d[0-9][a-g0-9,]*)\).*%\1%'`
  4202. + | sed 's%.*\(([hf]d[0-9][a-z0-9,]*)\).*%\1%'`
  4203. # If not found, print an error message and exit.
  4204. if test "x$tmp_drive" = x; then
  4205. @@ -148,13 +196,13 @@
  4206. gnu*)
  4207. if echo $tmp_part | grep "^s" >/dev/null; then
  4208. tmp_pc_slice=`echo $tmp_part \
  4209. - | sed "s%s\([0-9]*\)[a-g]*$%\1%"`
  4210. + | sed "s%s\([0-9]*\)[a-z]*$%\1%"`
  4211. tmp_drive=`echo "$tmp_drive" \
  4212. | sed "s%)%,\`expr "$tmp_pc_slice" - 1\`)%"`
  4213. fi
  4214. - if echo $tmp_part | grep "[a-g]$" >/dev/null; then
  4215. + if echo $tmp_part | grep "[a-z]$" >/dev/null; then
  4216. tmp_bsd_partition=`echo "$tmp_part" \
  4217. - | sed "s%[^a-g]*\([a-g]\)$%\1%"`
  4218. + | sed "s%[^a-z]*\([a-z]\)$%\1%"`
  4219. tmp_drive=`echo "$tmp_drive" \
  4220. | sed "s%)%,$tmp_bsd_partition)%"`
  4221. fi
  4222. @@ -336,6 +384,10 @@
  4223. # Create a safe temporary file.
  4224. test -n "$mklog" && log_file=`$mklog`
  4225. + # Before all invocations of the grub shell, call sync to make sure
  4226. + # the raw device is in sync with any bufferring in filesystems.
  4227. + sync
  4228. +
  4229. $grub_shell --batch $no_floppy --device-map=$device_map <<EOF >$log_file
  4230. quit
  4231. EOF
  4232. @@ -450,6 +502,24 @@
  4233. # Create a safe temporary file.
  4234. test -n "$mklog" && log_file=`$mklog`
  4235. +# Sync to prevent GRUB from not finding stage files (notably, on XFS)
  4236. +sync
  4237. +
  4238. +# XFS needs special magic
  4239. +xfs_frozen=false
  4240. +if which xfs_freeze > /dev/null ; then
  4241. + cat << EOF
  4242. +Due to a bug in xfs_freeze, the following command might produce a segmentation
  4243. +fault when ${grubdir} is not in an XFS filesystem. This error is harmless and
  4244. +can be ignored.
  4245. +EOF
  4246. + if xfs_freeze -f ${grubdir} ; then xfs_frozen=true ; fi
  4247. +fi
  4248. +
  4249. +# Before all invocations of the grub shell, call sync to make sure
  4250. +# the raw device is in sync with any bufferring in filesystems.
  4251. +sync
  4252. +
  4253. # Now perform the installation.
  4254. $grub_shell --batch $no_floppy --device-map=$device_map <<EOF >$log_file
  4255. root $root_drive
  4256. @@ -457,6 +527,10 @@
  4257. quit
  4258. EOF
  4259. +if ${xfs_frozen} ; then
  4260. + xfs_freeze -u ${grubdir}
  4261. +fi
  4262. +
  4263. if grep "Error [0-9]*: " $log_file >/dev/null || test $debug = yes; then
  4264. cat $log_file 1>&2
  4265. exit 1