010-fixes-1.patch 130 KB

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