1
0

amlopcr.c 115 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949
  1. /*++
  2. Copyright (c) 2012 Minoca Corp. All Rights Reserved
  3. Module Name:
  4. amlopcr.c
  5. Abstract:
  6. This module implements ACPI AML low level opcode support, specifically to
  7. create AML statements.
  8. Author:
  9. Evan Green 13-Nov-2012
  10. Environment:
  11. Kernel
  12. --*/
  13. //
  14. // ------------------------------------------------------------------- Includes
  15. //
  16. #include <minoca/kernel/driver.h>
  17. #include "acpiobj.h"
  18. #include "amlos.h"
  19. #include "amlops.h"
  20. #include "namespce.h"
  21. #include "oprgn.h"
  22. //
  23. // ---------------------------------------------------------------- Definitions
  24. //
  25. //
  26. // Define the opcodes for a dual-name and multi-name string.
  27. //
  28. #define ACPI_NULL_NAME_CHARACTER 0
  29. #define ACPI_DUAL_NAME_PREFIX_CHARACTER 0x2E
  30. #define ACPI_MULTI_NAME_PREFIX_CHARACTER 0x2F
  31. #define ACPI_ARGUMENT_0_OPCODE 0x68
  32. #define ACPI_LOCAL_0_OPCODE 0x60
  33. #define PACKAGE_LENGTH_FOLLOW_BYTE_SHIFT 6
  34. #define PACKAGE_LENGTH_FOLLOW_BYTE_MASK 0x03
  35. //
  36. // Define bitfield masks for the Field List flags.
  37. //
  38. #define FIELD_LIST_FLAG_ACCESS_MASK 0xF
  39. #define FIELD_LIST_FLAG_LOCK_MASK 0x10
  40. #define FIELD_LIST_FLAG_UPDATE_RULE_SHIFT 5
  41. #define FIELD_LIST_FLAG_UPDATE_RULE_MASK \
  42. (0x3 << FIELD_LIST_FLAG_UPDATE_RULE_SHIFT)
  43. //
  44. // Define reserved bytes that indicate a new byte offset or new attributes.
  45. //
  46. #define FIELD_LIST_RESERVED_FIELD 0x00
  47. #define FIELD_CHANGE_ATTRIBUTES 0x01
  48. //
  49. // Define the constant data prefixes.
  50. //
  51. #define BYTE_PREFIX 0x0A
  52. #define WORD_PREFIX 0x0B
  53. #define DOUBLE_WORD_PREFIX 0x0C
  54. #define STRING_PREFIX 0x0D
  55. #define QUAD_WORD_PREFIX 0x0E
  56. //
  57. // ------------------------------------------------------ Data Type Definitions
  58. //
  59. //
  60. // ----------------------------------------------- Internal Function Prototypes
  61. //
  62. BOOL
  63. AcpipIsValidFirstNameCharacter (
  64. UCHAR Character
  65. );
  66. //
  67. // -------------------------------------------------------------------- Globals
  68. //
  69. //
  70. // ------------------------------------------------------------------ Functions
  71. //
  72. KSTATUS
  73. AcpipCreateAcquireStatement (
  74. PAML_EXECUTION_CONTEXT Context,
  75. PAML_STATEMENT NextStatement
  76. )
  77. /*++
  78. Routine Description:
  79. This routine creates an Acquire (mutex) statement.
  80. Arguments:
  81. Context - Supplies a pointer to an initialized AML execution context. The
  82. next statement will be created based on the current execution offset.
  83. The current offset of the context will be incremented beyond the portion
  84. of this statement that was successfully parsed.
  85. NextStatement - Supplies a pointer where the next statement will be
  86. returned.
  87. Return Value:
  88. STATUS_SUCCESS always.
  89. --*/
  90. {
  91. NextStatement->Type = AmlStatementAcquire;
  92. Context->CurrentOffset += 1;
  93. NextStatement->ArgumentsNeeded = 1;
  94. NextStatement->ArgumentsAcquired = 0;
  95. return STATUS_SUCCESS;
  96. }
  97. KSTATUS
  98. AcpipCreateAliasStatement (
  99. PAML_EXECUTION_CONTEXT Context,
  100. PAML_STATEMENT NextStatement
  101. )
  102. /*++
  103. Routine Description:
  104. This routine creates a statement for opcode 6, an alias statement.
  105. Arguments:
  106. Context - Supplies a pointer to an initialized AML execution context. The
  107. next statement will be created based on the current execution offset.
  108. The current offset of the context will be incremented beyond the portion
  109. of this statement that was successfully parsed.
  110. NextStatement - Supplies a pointer where the next statement will be
  111. returned. The caller is responsible for freeing this memory.
  112. Return Value:
  113. STATUS_SUCCESS on success.
  114. Other error codes if the namespace strings were invalid.
  115. --*/
  116. {
  117. KSTATUS Status;
  118. NextStatement->Type = AmlStatementAlias;
  119. Context->CurrentOffset += 1;
  120. NextStatement->ArgumentsNeeded = 2;
  121. NextStatement->ArgumentsAcquired = 2;
  122. NextStatement->Argument[0] = AcpipParseNameString(Context);
  123. if (NextStatement->Argument[0] == NULL) {
  124. Status = STATUS_MALFORMED_DATA_STREAM;
  125. goto CreateAliasStatementEnd;
  126. }
  127. NextStatement->Argument[1] = AcpipParseNameString(Context);
  128. if (NextStatement->Argument[1] == NULL) {
  129. Status = STATUS_MALFORMED_DATA_STREAM;
  130. goto CreateAliasStatementEnd;
  131. }
  132. Status = STATUS_SUCCESS;
  133. CreateAliasStatementEnd:
  134. if (!KSUCCESS(Status)) {
  135. if (NextStatement->Argument[0] != NULL) {
  136. AcpipObjectReleaseReference(NextStatement->Argument[0]);
  137. }
  138. }
  139. return Status;
  140. }
  141. KSTATUS
  142. AcpipCreateAddStatement (
  143. PAML_EXECUTION_CONTEXT Context,
  144. PAML_STATEMENT NextStatement
  145. )
  146. /*++
  147. Routine Description:
  148. This routine creates a statement for an Add statement.
  149. Arguments:
  150. Context - Supplies a pointer to an initialized AML execution context. The
  151. next statement will be created based on the current execution offset.
  152. The current offset of the context will be incremented beyond the portion
  153. of this statement that was successfully parsed.
  154. NextStatement - Supplies a pointer where the next statement will be
  155. returned.
  156. Return Value:
  157. STATUS_SUCCESS on success.
  158. Other error codes on failure.
  159. --*/
  160. {
  161. KSTATUS Status;
  162. NextStatement->Type = AmlStatementAdd;
  163. Context->CurrentOffset += 1;
  164. NextStatement->ArgumentsNeeded = 3;
  165. NextStatement->ArgumentsAcquired = 0;
  166. Status = STATUS_SUCCESS;
  167. return Status;
  168. }
  169. KSTATUS
  170. AcpipCreateAndStatement (
  171. PAML_EXECUTION_CONTEXT Context,
  172. PAML_STATEMENT NextStatement
  173. )
  174. /*++
  175. Routine Description:
  176. This routine creates a statement for opcode 6, an alias statement.
  177. Arguments:
  178. Context - Supplies a pointer to an initialized AML execution context. The
  179. next statement will be created based on the current execution offset.
  180. The current offset of the context will be incremented beyond the portion
  181. of this statement that was successfully parsed.
  182. NextStatement - Supplies a pointer where the next statement will be
  183. returned. The caller is responsible for freeing this memory.
  184. Return Value:
  185. STATUS_SUCCESS on success.
  186. Other error codes on failure.
  187. --*/
  188. {
  189. KSTATUS Status;
  190. NextStatement->Type = AmlStatementAnd;
  191. Context->CurrentOffset += 1;
  192. NextStatement->ArgumentsNeeded = 3;
  193. NextStatement->ArgumentsAcquired = 0;
  194. Status = STATUS_SUCCESS;
  195. return Status;
  196. }
  197. KSTATUS
  198. AcpipCreateArgumentStatement (
  199. PAML_EXECUTION_CONTEXT Context,
  200. PAML_STATEMENT NextStatement
  201. )
  202. /*++
  203. Routine Description:
  204. This routine creates a statement for opcodes 0x68 - 0x6E, ArgX statements.
  205. Arguments:
  206. Context - Supplies a pointer to an initialized AML execution context. The
  207. next statement will be created based on the current execution offset.
  208. The current offset of the context will be incremented beyond the portion
  209. of this statement that was successfully parsed.
  210. NextStatement - Supplies a pointer where the next statement will be
  211. returned. The caller is responsible for freeing this memory.
  212. Return Value:
  213. STATUS_SUCCESS always.
  214. --*/
  215. {
  216. ULONG ArgumentNumber;
  217. UCHAR Instruction;
  218. PUCHAR InstructionPointer;
  219. NextStatement->Type = AmlStatementArgument;
  220. InstructionPointer = (PUCHAR)(Context->AmlCode + Context->CurrentOffset);
  221. Instruction = *InstructionPointer;
  222. ArgumentNumber = Instruction - ACPI_ARGUMENT_0_OPCODE;
  223. Context->CurrentOffset += 1;
  224. //
  225. // Store which argument number it is in the additional data space.
  226. //
  227. NextStatement->AdditionalData = ArgumentNumber;
  228. return STATUS_SUCCESS;
  229. }
  230. KSTATUS
  231. AcpipCreateBankFieldStatement (
  232. PAML_EXECUTION_CONTEXT Context,
  233. PAML_STATEMENT NextStatement
  234. )
  235. /*++
  236. Routine Description:
  237. This routine creates a BankField (in an Operation Region) statement.
  238. Arguments:
  239. Context - Supplies a pointer to an initialized AML execution context. The
  240. next statement will be created based on the current execution offset.
  241. The current offset of the context will be incremented beyond the portion
  242. of this statement that was successfully parsed.
  243. NextStatement - Supplies a pointer where the next statement will be
  244. returned.
  245. Return Value:
  246. Status code.
  247. --*/
  248. {
  249. NextStatement->Type = AmlStatementBankField;
  250. Context->CurrentOffset += 1;
  251. //
  252. // Parse the package length to get the end offset.
  253. //
  254. NextStatement->AdditionalData = Context->CurrentOffset;
  255. NextStatement->AdditionalData += AcpipParsePackageLength(Context);
  256. if (NextStatement->AdditionalData == Context->CurrentOffset) {
  257. return STATUS_UNSUCCESSFUL;
  258. }
  259. if (NextStatement->AdditionalData > Context->AmlCodeSize) {
  260. return STATUS_MALFORMED_DATA_STREAM;
  261. }
  262. //
  263. // Parse the name string.
  264. //
  265. NextStatement->Argument[0] = AcpipParseNameString(Context);
  266. if (NextStatement->Argument[0] == NULL) {
  267. return STATUS_UNSUCCESSFUL;
  268. }
  269. //
  270. // Parse the bank name string.
  271. //
  272. NextStatement->Argument[1] = AcpipParseNameString(Context);
  273. if (NextStatement->Argument[1] == NULL) {
  274. return STATUS_UNSUCCESSFUL;
  275. }
  276. //
  277. // Leave the current offset pointing at the third argument, a TermArg
  278. // that must reduce to an Integer.
  279. //
  280. NextStatement->ArgumentsNeeded = 3;
  281. NextStatement->ArgumentsAcquired = 2;
  282. return STATUS_SUCCESS;
  283. }
  284. KSTATUS
  285. AcpipCreateBreakStatement (
  286. PAML_EXECUTION_CONTEXT Context,
  287. PAML_STATEMENT NextStatement
  288. )
  289. /*++
  290. Routine Description:
  291. This routine creates a statement for a Break statement (like a break inside
  292. of a while loop, not break like stop).
  293. Arguments:
  294. Context - Supplies a pointer to an initialized AML execution context. The
  295. next statement will be created based on the current execution offset.
  296. The current offset of the context will be incremented beyond the portion
  297. of this statement that was successfully parsed.
  298. NextStatement - Supplies a pointer where the next statement will be
  299. returned.
  300. Return Value:
  301. STATUS_SUCCESS always.
  302. --*/
  303. {
  304. NextStatement->Type = AmlStatementBreak;
  305. Context->CurrentOffset += 1;
  306. NextStatement->ArgumentsNeeded = 0;
  307. NextStatement->ArgumentsAcquired = 0;
  308. return STATUS_SUCCESS;
  309. }
  310. KSTATUS
  311. AcpipCreateBreakPointStatement (
  312. PAML_EXECUTION_CONTEXT Context,
  313. PAML_STATEMENT NextStatement
  314. )
  315. /*++
  316. Routine Description:
  317. This routine creates a breakpoint statement.
  318. Arguments:
  319. Context - Supplies a pointer to an initialized AML execution context. The
  320. next statement will be created based on the current execution offset.
  321. The current offset of the context will be incremented beyond the portion
  322. of this statement that was successfully parsed.
  323. NextStatement - Supplies a pointer where the next statement will be
  324. returned. The caller is responsible for freeing this memory.
  325. Return Value:
  326. STATUS_SUCCESS always.
  327. --*/
  328. {
  329. NextStatement->Type = AmlStatementBreakPoint;
  330. Context->CurrentOffset += 1;
  331. NextStatement->ArgumentsNeeded = 0;
  332. NextStatement->ArgumentsAcquired = 0;
  333. return STATUS_SUCCESS;
  334. }
  335. KSTATUS
  336. AcpipCreateBufferStatement (
  337. PAML_EXECUTION_CONTEXT Context,
  338. PAML_STATEMENT NextStatement
  339. )
  340. /*++
  341. Routine Description:
  342. This routine creates a buffer declaration statement.
  343. Arguments:
  344. Context - Supplies a pointer to an initialized AML execution context. The
  345. next statement will be created based on the current execution offset.
  346. The current offset of the context will be incremented beyond the portion
  347. of this statement that was successfully parsed.
  348. NextStatement - Supplies a pointer where the next statement will be
  349. returned.
  350. Return Value:
  351. Status code.
  352. --*/
  353. {
  354. NextStatement->Type = AmlStatementBuffer;
  355. Context->CurrentOffset += 1;
  356. NextStatement->ArgumentsNeeded = 1;
  357. NextStatement->ArgumentsAcquired = 0;
  358. //
  359. // Get the package length, compute the end offset, and store that in the
  360. // additional data.
  361. //
  362. NextStatement->AdditionalData = Context->CurrentOffset;
  363. NextStatement->AdditionalData += AcpipParsePackageLength(Context);
  364. if (NextStatement->AdditionalData == Context->CurrentOffset) {
  365. return STATUS_UNSUCCESSFUL;
  366. }
  367. //
  368. // Watch for integer overflow.
  369. //
  370. if ((NextStatement->AdditionalData > Context->AmlCodeSize) ||
  371. (NextStatement->AdditionalData < Context->CurrentOffset)) {
  372. return STATUS_INVALID_PARAMETER;
  373. }
  374. return STATUS_SUCCESS;
  375. }
  376. KSTATUS
  377. AcpipCreateConcatenateResourceTemplatesStatement (
  378. PAML_EXECUTION_CONTEXT Context,
  379. PAML_STATEMENT NextStatement
  380. )
  381. /*++
  382. Routine Description:
  383. This routine creates a "Concatenate Resource Templates" statement.
  384. Arguments:
  385. Context - Supplies a pointer to an initialized AML execution context. The
  386. next statement will be created based on the current execution offset.
  387. The current offset of the context will be incremented beyond the portion
  388. of this statement that was successfully parsed.
  389. NextStatement - Supplies a pointer where the next statement will be
  390. returned.
  391. Return Value:
  392. Status code.
  393. --*/
  394. {
  395. NextStatement->Type = AmlStatementConcatenateResourceTemplates;
  396. Context->CurrentOffset += 1;
  397. NextStatement->ArgumentsNeeded = 3;
  398. NextStatement->ArgumentsAcquired = 0;
  399. return STATUS_SUCCESS;
  400. }
  401. KSTATUS
  402. AcpipCreateConcatenateStatement (
  403. PAML_EXECUTION_CONTEXT Context,
  404. PAML_STATEMENT NextStatement
  405. )
  406. /*++
  407. Routine Description:
  408. This routine creates a concatenation statement.
  409. Arguments:
  410. Context - Supplies a pointer to an initialized AML execution context. The
  411. next statement will be created based on the current execution offset.
  412. The current offset of the context will be incremented beyond the portion
  413. of this statement that was successfully parsed.
  414. NextStatement - Supplies a pointer where the next statement will be
  415. returned.
  416. Return Value:
  417. Status code.
  418. --*/
  419. {
  420. NextStatement->Type = AmlStatementConcatenate;
  421. Context->CurrentOffset += 1;
  422. NextStatement->ArgumentsNeeded = 3;
  423. NextStatement->ArgumentsAcquired = 0;
  424. return STATUS_SUCCESS;
  425. }
  426. KSTATUS
  427. AcpipCreateConditionalReferenceOfStatement (
  428. PAML_EXECUTION_CONTEXT Context,
  429. PAML_STATEMENT NextStatement
  430. )
  431. /*++
  432. Routine Description:
  433. This routine creates a "Conditional Reference Of" statement.
  434. Arguments:
  435. Context - Supplies a pointer to an initialized AML execution context. The
  436. next statement will be created based on the current execution offset.
  437. The current offset of the context will be incremented beyond the portion
  438. of this statement that was successfully parsed.
  439. NextStatement - Supplies a pointer where the next statement will be
  440. returned.
  441. Return Value:
  442. STATUS_SUCCESS always.
  443. --*/
  444. {
  445. NextStatement->Type = AmlStatementConditionalReferenceOf;
  446. Context->CurrentOffset += 1;
  447. NextStatement->ArgumentsNeeded = 2;
  448. NextStatement->ArgumentsAcquired = 0;
  449. return STATUS_SUCCESS;
  450. }
  451. KSTATUS
  452. AcpipCreateContinueStatement (
  453. PAML_EXECUTION_CONTEXT Context,
  454. PAML_STATEMENT NextStatement
  455. )
  456. /*++
  457. Routine Description:
  458. This routine creates a statement for a while loop Continue statement.
  459. Arguments:
  460. Context - Supplies a pointer to an initialized AML execution context. The
  461. next statement will be created based on the current execution offset.
  462. The current offset of the context will be incremented beyond the portion
  463. of this statement that was successfully parsed.
  464. NextStatement - Supplies a pointer where the next statement will be
  465. returned.
  466. Return Value:
  467. STATUS_SUCCESS always.
  468. --*/
  469. {
  470. NextStatement->Type = AmlStatementContinue;
  471. Context->CurrentOffset += 1;
  472. NextStatement->ArgumentsNeeded = 0;
  473. NextStatement->ArgumentsAcquired = 0;
  474. return STATUS_SUCCESS;
  475. }
  476. KSTATUS
  477. AcpipCreateCopyObjectStatement (
  478. PAML_EXECUTION_CONTEXT Context,
  479. PAML_STATEMENT NextStatement
  480. )
  481. /*++
  482. Routine Description:
  483. This routine creates a "Copy Object" statement.
  484. Arguments:
  485. Context - Supplies a pointer to an initialized AML execution context. The
  486. next statement will be created based on the current execution offset.
  487. The current offset of the context will be incremented beyond the portion
  488. of this statement that was successfully parsed.
  489. NextStatement - Supplies a pointer where the next statement will be
  490. returned.
  491. Return Value:
  492. Status code.
  493. --*/
  494. {
  495. NextStatement->Type = AmlStatementCopyObject;
  496. Context->CurrentOffset += 1;
  497. NextStatement->ArgumentsNeeded = 2;
  498. NextStatement->ArgumentsAcquired = 0;
  499. return STATUS_SUCCESS;
  500. }
  501. KSTATUS
  502. AcpipCreateCreateBitFieldStatement (
  503. PAML_EXECUTION_CONTEXT Context,
  504. PAML_STATEMENT NextStatement
  505. )
  506. /*++
  507. Routine Description:
  508. This routine creates a CreateBitField statement.
  509. Arguments:
  510. Context - Supplies a pointer to an initialized AML execution context. The
  511. next statement will be created based on the current execution offset.
  512. The current offset of the context will be incremented beyond the portion
  513. of this statement that was successfully parsed.
  514. NextStatement - Supplies a pointer where the next statement will be
  515. returned. The caller is responsible for freeing this memory.
  516. Return Value:
  517. STATUS_SUCCESS always.
  518. --*/
  519. {
  520. KSTATUS Status;
  521. NextStatement->Type = AmlStatementCreateBufferFieldFixed;
  522. Context->CurrentOffset += 1;
  523. NextStatement->ArgumentsNeeded = 3;
  524. NextStatement->ArgumentsAcquired = 0;
  525. //
  526. // Store the size of the field in additional data.
  527. //
  528. NextStatement->AdditionalData = 1;
  529. Status = STATUS_SUCCESS;
  530. return Status;
  531. }
  532. KSTATUS
  533. AcpipCreateCreateByteFieldStatement (
  534. PAML_EXECUTION_CONTEXT Context,
  535. PAML_STATEMENT NextStatement
  536. )
  537. /*++
  538. Routine Description:
  539. This routine creates a CreateByteField statement.
  540. Arguments:
  541. Context - Supplies a pointer to an initialized AML execution context. The
  542. next statement will be created based on the current execution offset.
  543. The current offset of the context will be incremented beyond the portion
  544. of this statement that was successfully parsed.
  545. NextStatement - Supplies a pointer where the next statement will be
  546. returned. The caller is responsible for freeing this memory.
  547. Return Value:
  548. STATUS_SUCCESS always.
  549. --*/
  550. {
  551. KSTATUS Status;
  552. NextStatement->Type = AmlStatementCreateBufferFieldFixed;
  553. Context->CurrentOffset += 1;
  554. NextStatement->ArgumentsNeeded = 3;
  555. NextStatement->ArgumentsAcquired = 0;
  556. //
  557. // Store the size of the field in additional data.
  558. //
  559. NextStatement->AdditionalData = BITS_PER_BYTE;
  560. Status = STATUS_SUCCESS;
  561. return Status;
  562. }
  563. KSTATUS
  564. AcpipCreateCreateDoubleWordFieldStatement (
  565. PAML_EXECUTION_CONTEXT Context,
  566. PAML_STATEMENT NextStatement
  567. )
  568. /*++
  569. Routine Description:
  570. This routine creates a CreateDWordField statement.
  571. Arguments:
  572. Context - Supplies a pointer to an initialized AML execution context. The
  573. next statement will be created based on the current execution offset.
  574. The current offset of the context will be incremented beyond the portion
  575. of this statement that was successfully parsed.
  576. NextStatement - Supplies a pointer where the next statement will be
  577. returned. The caller is responsible for freeing this memory.
  578. Return Value:
  579. STATUS_SUCCESS always.
  580. --*/
  581. {
  582. KSTATUS Status;
  583. NextStatement->Type = AmlStatementCreateBufferFieldFixed;
  584. Context->CurrentOffset += 1;
  585. NextStatement->ArgumentsNeeded = 3;
  586. NextStatement->ArgumentsAcquired = 0;
  587. //
  588. // Store the size of the field in additional data.
  589. //
  590. NextStatement->AdditionalData = sizeof(ULONG) * BITS_PER_BYTE;
  591. Status = STATUS_SUCCESS;
  592. return Status;
  593. }
  594. KSTATUS
  595. AcpipCreateCreateFieldStatement (
  596. PAML_EXECUTION_CONTEXT Context,
  597. PAML_STATEMENT NextStatement
  598. )
  599. /*++
  600. Routine Description:
  601. This routine creates a CreateField (of a buffer) statement.
  602. Arguments:
  603. Context - Supplies a pointer to an initialized AML execution context. The
  604. next statement will be created based on the current execution offset.
  605. The current offset of the context will be incremented beyond the portion
  606. of this statement that was successfully parsed.
  607. NextStatement - Supplies a pointer where the next statement will be
  608. returned. The caller is responsible for freeing this memory.
  609. Return Value:
  610. STATUS_SUCCESS always.
  611. --*/
  612. {
  613. KSTATUS Status;
  614. NextStatement->Type = AmlStatementCreateBufferField;
  615. Context->CurrentOffset += 1;
  616. NextStatement->ArgumentsNeeded = 4;
  617. NextStatement->ArgumentsAcquired = 0;
  618. Status = STATUS_SUCCESS;
  619. return Status;
  620. }
  621. KSTATUS
  622. AcpipCreateCreateQuadWordFieldStatement (
  623. PAML_EXECUTION_CONTEXT Context,
  624. PAML_STATEMENT NextStatement
  625. )
  626. /*++
  627. Routine Description:
  628. This routine creates a CreateQWordField statement.
  629. Arguments:
  630. Context - Supplies a pointer to an initialized AML execution context. The
  631. next statement will be created based on the current execution offset.
  632. The current offset of the context will be incremented beyond the portion
  633. of this statement that was successfully parsed.
  634. NextStatement - Supplies a pointer where the next statement will be
  635. returned. The caller is responsible for freeing this memory.
  636. Return Value:
  637. STATUS_SUCCESS always.
  638. --*/
  639. {
  640. KSTATUS Status;
  641. NextStatement->Type = AmlStatementCreateBufferFieldFixed;
  642. Context->CurrentOffset += 1;
  643. NextStatement->ArgumentsNeeded = 3;
  644. NextStatement->ArgumentsAcquired = 0;
  645. //
  646. // Store the size of the field in additional data.
  647. //
  648. NextStatement->AdditionalData = sizeof(ULONGLONG) * BITS_PER_BYTE;
  649. Status = STATUS_SUCCESS;
  650. return Status;
  651. }
  652. KSTATUS
  653. AcpipCreateCreateWordFieldStatement (
  654. PAML_EXECUTION_CONTEXT Context,
  655. PAML_STATEMENT NextStatement
  656. )
  657. /*++
  658. Routine Description:
  659. This routine creates a CreateWordField statement.
  660. Arguments:
  661. Context - Supplies a pointer to an initialized AML execution context. The
  662. next statement will be created based on the current execution offset.
  663. The current offset of the context will be incremented beyond the portion
  664. of this statement that was successfully parsed.
  665. NextStatement - Supplies a pointer where the next statement will be
  666. returned. The caller is responsible for freeing this memory.
  667. Return Value:
  668. STATUS_SUCCESS always.
  669. --*/
  670. {
  671. KSTATUS Status;
  672. NextStatement->Type = AmlStatementCreateBufferFieldFixed;
  673. Context->CurrentOffset += 1;
  674. NextStatement->ArgumentsNeeded = 3;
  675. NextStatement->ArgumentsAcquired = 0;
  676. //
  677. // Store the size of the field in additional data.
  678. //
  679. NextStatement->AdditionalData = sizeof(USHORT) * BITS_PER_BYTE;
  680. Status = STATUS_SUCCESS;
  681. return Status;
  682. }
  683. KSTATUS
  684. AcpipCreateDataStatement (
  685. PAML_EXECUTION_CONTEXT Context,
  686. PAML_STATEMENT NextStatement
  687. )
  688. /*++
  689. Routine Description:
  690. This routine creates a statement for ByteData, WordData, DWordData,
  691. QWordData, and StringData.
  692. Arguments:
  693. Context - Supplies a pointer to an initialized AML execution context. The
  694. next statement will be created based on the current execution offset.
  695. The current offset of the context will be incremented beyond the portion
  696. of this statement that was successfully parsed.
  697. NextStatement - Supplies a pointer where the next statement will be
  698. returned.
  699. Return Value:
  700. Status code.
  701. --*/
  702. {
  703. PUCHAR InstructionPointer;
  704. UCHAR Prefix;
  705. NextStatement->Type = AmlStatementData;
  706. NextStatement->ArgumentsNeeded = 0;
  707. NextStatement->ArgumentsAcquired = 0;
  708. InstructionPointer = (PUCHAR)Context->AmlCode + Context->CurrentOffset;
  709. Prefix = *InstructionPointer;
  710. Context->CurrentOffset += 1;
  711. InstructionPointer += 1;
  712. //
  713. // Store the offset in additional data, and the size of the data in
  714. // additional data 2. Strings are encoded as zero in size.
  715. //
  716. NextStatement->AdditionalData = Context->CurrentOffset;
  717. switch (Prefix) {
  718. case BYTE_PREFIX:
  719. Context->CurrentOffset += sizeof(UCHAR);
  720. NextStatement->AdditionalData2 = sizeof(UCHAR);
  721. break;
  722. case WORD_PREFIX:
  723. Context->CurrentOffset += sizeof(USHORT);
  724. NextStatement->AdditionalData2 = sizeof(USHORT);
  725. break;
  726. case DOUBLE_WORD_PREFIX:
  727. Context->CurrentOffset += sizeof(ULONG);
  728. NextStatement->AdditionalData2 = sizeof(ULONG);
  729. break;
  730. case STRING_PREFIX:
  731. NextStatement->AdditionalData2 = 0;
  732. while ((Context->CurrentOffset < Context->AmlCodeSize) &&
  733. (*InstructionPointer != '\0')) {
  734. Context->CurrentOffset += 1;
  735. InstructionPointer += 1;
  736. }
  737. //
  738. // Move past the null terminator.
  739. //
  740. Context->CurrentOffset += 1;
  741. break;
  742. case QUAD_WORD_PREFIX:
  743. Context->CurrentOffset += sizeof(ULONGLONG);
  744. NextStatement->AdditionalData2 = sizeof(ULONGLONG);
  745. break;
  746. default:
  747. ASSERT(FALSE);
  748. return STATUS_NOT_SUPPORTED;
  749. }
  750. //
  751. // Bounds checking.
  752. //
  753. if (Context->CurrentOffset > Context->AmlCodeSize) {
  754. return STATUS_END_OF_FILE;
  755. }
  756. return STATUS_SUCCESS;
  757. }
  758. KSTATUS
  759. AcpipCreateDataTableRegionStatement (
  760. PAML_EXECUTION_CONTEXT Context,
  761. PAML_STATEMENT NextStatement
  762. )
  763. /*++
  764. Routine Description:
  765. This routine creates a Data Table Region statement.
  766. Arguments:
  767. Context - Supplies a pointer to an initialized AML execution context. The
  768. next statement will be created based on the current execution offset.
  769. The current offset of the context will be incremented beyond the portion
  770. of this statement that was successfully parsed.
  771. NextStatement - Supplies a pointer where the next statement will be
  772. returned.
  773. Return Value:
  774. STATUS_SUCCESS always.
  775. --*/
  776. {
  777. NextStatement->Type = AmlStatementDataTableRegion;
  778. //
  779. // TODO: Implement AML DataTableRegion opcode.
  780. //
  781. ASSERT(FALSE);
  782. return STATUS_NOT_IMPLEMENTED;
  783. }
  784. KSTATUS
  785. AcpipCreateDebugStatement (
  786. PAML_EXECUTION_CONTEXT Context,
  787. PAML_STATEMENT NextStatement
  788. )
  789. /*++
  790. Routine Description:
  791. This routine creates a Debug object statement.
  792. Arguments:
  793. Context - Supplies a pointer to an initialized AML execution context. The
  794. next statement will be created based on the current execution offset.
  795. The current offset of the context will be incremented beyond the portion
  796. of this statement that was successfully parsed.
  797. NextStatement - Supplies a pointer where the next statement will be
  798. returned.
  799. Return Value:
  800. STATUS_SUCCESS always.
  801. --*/
  802. {
  803. NextStatement->Type = AmlStatementDebug;
  804. Context->CurrentOffset += 1;
  805. NextStatement->ArgumentsNeeded = 0;
  806. NextStatement->ArgumentsAcquired = 0;
  807. return STATUS_SUCCESS;
  808. }
  809. KSTATUS
  810. AcpipCreateDecrementStatement (
  811. PAML_EXECUTION_CONTEXT Context,
  812. PAML_STATEMENT NextStatement
  813. )
  814. /*++
  815. Routine Description:
  816. This routine creates a Decrement object statement.
  817. Arguments:
  818. Context - Supplies a pointer to an initialized AML execution context. The
  819. next statement will be created based on the current execution offset.
  820. The current offset of the context will be incremented beyond the portion
  821. of this statement that was successfully parsed.
  822. NextStatement - Supplies a pointer where the next statement will be
  823. returned.
  824. Return Value:
  825. STATUS_SUCCESS always.
  826. --*/
  827. {
  828. NextStatement->Type = AmlStatementDecrement;
  829. Context->CurrentOffset += 1;
  830. NextStatement->ArgumentsNeeded = 1;
  831. NextStatement->ArgumentsAcquired = 0;
  832. return STATUS_SUCCESS;
  833. }
  834. KSTATUS
  835. AcpipCreateDereferenceOfStatement (
  836. PAML_EXECUTION_CONTEXT Context,
  837. PAML_STATEMENT NextStatement
  838. )
  839. /*++
  840. Routine Description:
  841. This routine creates a "Dereference Of" statement.
  842. Arguments:
  843. Context - Supplies a pointer to an initialized AML execution context. The
  844. next statement will be created based on the current execution offset.
  845. The current offset of the context will be incremented beyond the portion
  846. of this statement that was successfully parsed.
  847. NextStatement - Supplies a pointer where the next statement will be
  848. returned.
  849. Return Value:
  850. STATUS_SUCCESS always.
  851. --*/
  852. {
  853. NextStatement->Type = AmlStatementDereferenceOf;
  854. Context->CurrentOffset += 1;
  855. NextStatement->ArgumentsNeeded = 1;
  856. NextStatement->ArgumentsAcquired = 0;
  857. return STATUS_SUCCESS;
  858. }
  859. KSTATUS
  860. AcpipCreateDeviceStatement (
  861. PAML_EXECUTION_CONTEXT Context,
  862. PAML_STATEMENT NextStatement
  863. )
  864. /*++
  865. Routine Description:
  866. This routine creates a Device statement.
  867. Arguments:
  868. Context - Supplies a pointer to an initialized AML execution context. The
  869. next statement will be created based on the current execution offset.
  870. The current offset of the context will be incremented beyond the portion
  871. of this statement that was successfully parsed.
  872. NextStatement - Supplies a pointer where the next statement will be
  873. returned.
  874. Return Value:
  875. Status code.
  876. --*/
  877. {
  878. NextStatement->Type = AmlStatementDevice;
  879. Context->CurrentOffset += 1;
  880. NextStatement->ArgumentsNeeded = 1;
  881. NextStatement->ArgumentsAcquired = 1;
  882. //
  883. // Parse the package length. Store the end offset in the additional data
  884. // field.
  885. //
  886. NextStatement->AdditionalData = Context->CurrentOffset;
  887. NextStatement->AdditionalData += AcpipParsePackageLength(Context);
  888. if (NextStatement->AdditionalData == Context->CurrentOffset) {
  889. return STATUS_UNSUCCESSFUL;
  890. }
  891. //
  892. // Parse the name string, and store as argument 0.
  893. //
  894. NextStatement->Argument[0] = AcpipParseNameString(Context);
  895. return STATUS_SUCCESS;
  896. }
  897. KSTATUS
  898. AcpipCreateDivideStatement (
  899. PAML_EXECUTION_CONTEXT Context,
  900. PAML_STATEMENT NextStatement
  901. )
  902. /*++
  903. Routine Description:
  904. This routine creates a Divide statement.
  905. Arguments:
  906. Context - Supplies a pointer to an initialized AML execution context. The
  907. next statement will be created based on the current execution offset.
  908. The current offset of the context will be incremented beyond the portion
  909. of this statement that was successfully parsed.
  910. NextStatement - Supplies a pointer where the next statement will be
  911. returned.
  912. Return Value:
  913. STATUS_SUCCESS always.
  914. --*/
  915. {
  916. NextStatement->Type = AmlStatementDivide;
  917. Context->CurrentOffset += 1;
  918. NextStatement->ArgumentsNeeded = 4;
  919. NextStatement->ArgumentsAcquired = 0;
  920. return STATUS_SUCCESS;
  921. }
  922. KSTATUS
  923. AcpipCreateElseStatement (
  924. PAML_EXECUTION_CONTEXT Context,
  925. PAML_STATEMENT NextStatement
  926. )
  927. /*++
  928. Routine Description:
  929. This routine creates an Else statement.
  930. Arguments:
  931. Context - Supplies a pointer to an initialized AML execution context. The
  932. next statement will be created based on the current execution offset.
  933. The current offset of the context will be incremented beyond the portion
  934. of this statement that was successfully parsed.
  935. NextStatement - Supplies a pointer where the next statement will be
  936. returned.
  937. Return Value:
  938. Status code.
  939. --*/
  940. {
  941. NextStatement->Type = AmlStatementElse;
  942. Context->CurrentOffset += 1;
  943. //
  944. // Grab the package length, use it to calculate the end offset, and store
  945. // that in additional data.
  946. //
  947. NextStatement->AdditionalData = Context->CurrentOffset;
  948. NextStatement->AdditionalData += AcpipParsePackageLength(Context);
  949. if (NextStatement->AdditionalData == Context->CurrentOffset) {
  950. return STATUS_UNSUCCESSFUL;
  951. }
  952. NextStatement->ArgumentsNeeded = 0;
  953. NextStatement->ArgumentsAcquired = 0;
  954. return STATUS_SUCCESS;
  955. }
  956. KSTATUS
  957. AcpipCreateEventStatement (
  958. PAML_EXECUTION_CONTEXT Context,
  959. PAML_STATEMENT NextStatement
  960. )
  961. /*++
  962. Routine Description:
  963. This routine creates an Event statement.
  964. Arguments:
  965. Context - Supplies a pointer to an initialized AML execution context. The
  966. next statement will be created based on the current execution offset.
  967. The current offset of the context will be incremented beyond the portion
  968. of this statement that was successfully parsed.
  969. NextStatement - Supplies a pointer where the next statement will be
  970. returned.
  971. Return Value:
  972. Status code.
  973. --*/
  974. {
  975. NextStatement->Type = AmlStatementEvent;
  976. Context->CurrentOffset += 1;
  977. NextStatement->ArgumentsNeeded = 1;
  978. NextStatement->ArgumentsAcquired = 1;
  979. //
  980. // Parse the name string.
  981. //
  982. NextStatement->Argument[0] = AcpipParseNameString(Context);
  983. if (NextStatement->Argument[0] == NULL) {
  984. return STATUS_UNSUCCESSFUL;
  985. }
  986. return STATUS_SUCCESS;
  987. }
  988. KSTATUS
  989. AcpipCreateFatalStatement (
  990. PAML_EXECUTION_CONTEXT Context,
  991. PAML_STATEMENT NextStatement
  992. )
  993. /*++
  994. Routine Description:
  995. This routine creates a Fatal statement.
  996. Arguments:
  997. Context - Supplies a pointer to an initialized AML execution context. The
  998. next statement will be created based on the current execution offset.
  999. The current offset of the context will be incremented beyond the portion
  1000. of this statement that was successfully parsed.
  1001. NextStatement - Supplies a pointer where the next statement will be
  1002. returned.
  1003. Return Value:
  1004. STATUS_SUCCESS always.
  1005. --*/
  1006. {
  1007. NextStatement->Type = AmlStatementFatal;
  1008. Context->CurrentOffset += 1;
  1009. //
  1010. // Remember the offset, as the first two arguments (a byte and a DWORD) are
  1011. // stored here.
  1012. //
  1013. NextStatement->AdditionalData = Context->CurrentOffset;
  1014. NextStatement->ArgumentsNeeded = 1;
  1015. NextStatement->ArgumentsAcquired = 0;
  1016. return STATUS_SUCCESS;
  1017. }
  1018. KSTATUS
  1019. AcpipCreateFieldStatement (
  1020. PAML_EXECUTION_CONTEXT Context,
  1021. PAML_STATEMENT NextStatement
  1022. )
  1023. /*++
  1024. Routine Description:
  1025. This routine creates a Field (in an Operation Region) statement.
  1026. Arguments:
  1027. Context - Supplies a pointer to an initialized AML execution context. The
  1028. next statement will be created based on the current execution offset.
  1029. The current offset of the context will be incremented beyond the portion
  1030. of this statement that was successfully parsed.
  1031. NextStatement - Supplies a pointer where the next statement will be
  1032. returned.
  1033. Return Value:
  1034. Status code.
  1035. --*/
  1036. {
  1037. PUCHAR InstructionPointer;
  1038. NextStatement->Type = AmlStatementField;
  1039. Context->CurrentOffset += 1;
  1040. //
  1041. // Parse the package length to get the end offset.
  1042. //
  1043. NextStatement->AdditionalData = Context->CurrentOffset;
  1044. NextStatement->AdditionalData += AcpipParsePackageLength(Context);
  1045. if (NextStatement->AdditionalData == Context->CurrentOffset) {
  1046. return STATUS_UNSUCCESSFUL;
  1047. }
  1048. if (NextStatement->AdditionalData > Context->AmlCodeSize) {
  1049. return STATUS_MALFORMED_DATA_STREAM;
  1050. }
  1051. //
  1052. // Parse the name string.
  1053. //
  1054. NextStatement->Argument[0] = AcpipParseNameString(Context);
  1055. if (NextStatement->Argument[0] == NULL) {
  1056. return STATUS_UNSUCCESSFUL;
  1057. }
  1058. //
  1059. // Parse the starting flags and store them in additional data 2.
  1060. //
  1061. InstructionPointer = (PUCHAR)Context->AmlCode + Context->CurrentOffset;
  1062. NextStatement->AdditionalData2 = *InstructionPointer;
  1063. Context->CurrentOffset += 1;
  1064. //
  1065. // Leave the current offset pointing at the start of the field list.
  1066. //
  1067. NextStatement->ArgumentsNeeded = 1;
  1068. NextStatement->ArgumentsAcquired = 1;
  1069. return STATUS_SUCCESS;
  1070. }
  1071. KSTATUS
  1072. AcpipCreateFindSetLeftBitStatement (
  1073. PAML_EXECUTION_CONTEXT Context,
  1074. PAML_STATEMENT NextStatement
  1075. )
  1076. /*++
  1077. Routine Description:
  1078. This routine creates a "Find Set Left Bit" statement.
  1079. Arguments:
  1080. Context - Supplies a pointer to an initialized AML execution context. The
  1081. next statement will be created based on the current execution offset.
  1082. The current offset of the context will be incremented beyond the portion
  1083. of this statement that was successfully parsed.
  1084. NextStatement - Supplies a pointer where the next statement will be
  1085. returned.
  1086. Return Value:
  1087. STATUS_SUCCESS always.
  1088. --*/
  1089. {
  1090. NextStatement->Type = AmlStatementFindSetLeftBit;
  1091. Context->CurrentOffset += 1;
  1092. NextStatement->ArgumentsNeeded = 2;
  1093. NextStatement->ArgumentsAcquired = 0;
  1094. return STATUS_SUCCESS;
  1095. }
  1096. KSTATUS
  1097. AcpipCreateFindSetRightBitStatement (
  1098. PAML_EXECUTION_CONTEXT Context,
  1099. PAML_STATEMENT NextStatement
  1100. )
  1101. /*++
  1102. Routine Description:
  1103. This routine creates a "Find Set Right Bit" statement.
  1104. Arguments:
  1105. Context - Supplies a pointer to an initialized AML execution context. The
  1106. next statement will be created based on the current execution offset.
  1107. The current offset of the context will be incremented beyond the portion
  1108. of this statement that was successfully parsed.
  1109. NextStatement - Supplies a pointer where the next statement will be
  1110. returned.
  1111. Return Value:
  1112. STATUS_SUCCESS always.
  1113. --*/
  1114. {
  1115. NextStatement->Type = AmlStatementFindSetRightBit;
  1116. Context->CurrentOffset += 1;
  1117. NextStatement->ArgumentsNeeded = 2;
  1118. NextStatement->ArgumentsAcquired = 0;
  1119. return STATUS_SUCCESS;
  1120. }
  1121. KSTATUS
  1122. AcpipCreateFromBcdStatement (
  1123. PAML_EXECUTION_CONTEXT Context,
  1124. PAML_STATEMENT NextStatement
  1125. )
  1126. /*++
  1127. Routine Description:
  1128. This routine creates a "Find BCD" statement.
  1129. Arguments:
  1130. Context - Supplies a pointer to an initialized AML execution context. The
  1131. next statement will be created based on the current execution offset.
  1132. The current offset of the context will be incremented beyond the portion
  1133. of this statement that was successfully parsed.
  1134. NextStatement - Supplies a pointer where the next statement will be
  1135. returned.
  1136. Return Value:
  1137. STATUS_SUCCESS always.
  1138. --*/
  1139. {
  1140. NextStatement->Type = AmlStatementFromBcd;
  1141. Context->CurrentOffset += 1;
  1142. NextStatement->ArgumentsNeeded = 2;
  1143. NextStatement->ArgumentsAcquired = 0;
  1144. return STATUS_SUCCESS;
  1145. }
  1146. KSTATUS
  1147. AcpipCreateIfStatement (
  1148. PAML_EXECUTION_CONTEXT Context,
  1149. PAML_STATEMENT NextStatement
  1150. )
  1151. /*++
  1152. Routine Description:
  1153. This routine creates an If statement.
  1154. Arguments:
  1155. Context - Supplies a pointer to an initialized AML execution context. The
  1156. next statement will be created based on the current execution offset.
  1157. The current offset of the context will be incremented beyond the portion
  1158. of this statement that was successfully parsed.
  1159. NextStatement - Supplies a pointer where the next statement will be
  1160. returned.
  1161. Return Value:
  1162. Status code.
  1163. --*/
  1164. {
  1165. NextStatement->Type = AmlStatementIf;
  1166. Context->CurrentOffset += 1;
  1167. //
  1168. // Grab the package length, use it to calculate the end offset, and store
  1169. // that in additional data.
  1170. //
  1171. NextStatement->AdditionalData = Context->CurrentOffset;
  1172. NextStatement->AdditionalData += AcpipParsePackageLength(Context);
  1173. if (NextStatement->AdditionalData == Context->CurrentOffset) {
  1174. return STATUS_UNSUCCESSFUL;
  1175. }
  1176. NextStatement->ArgumentsNeeded = 1;
  1177. NextStatement->ArgumentsAcquired = 0;
  1178. return STATUS_SUCCESS;
  1179. }
  1180. KSTATUS
  1181. AcpipCreateIncrementStatement (
  1182. PAML_EXECUTION_CONTEXT Context,
  1183. PAML_STATEMENT NextStatement
  1184. )
  1185. /*++
  1186. Routine Description:
  1187. This routine creates a Increment object statement.
  1188. Arguments:
  1189. Context - Supplies a pointer to an initialized AML execution context. The
  1190. next statement will be created based on the current execution offset.
  1191. The current offset of the context will be incremented beyond the portion
  1192. of this statement that was successfully parsed.
  1193. NextStatement - Supplies a pointer where the next statement will be
  1194. returned.
  1195. Return Value:
  1196. STATUS_SUCCESS always.
  1197. --*/
  1198. {
  1199. NextStatement->Type = AmlStatementIncrement;
  1200. Context->CurrentOffset += 1;
  1201. NextStatement->ArgumentsNeeded = 1;
  1202. NextStatement->ArgumentsAcquired = 0;
  1203. return STATUS_SUCCESS;
  1204. }
  1205. KSTATUS
  1206. AcpipCreateIndexFieldStatement (
  1207. PAML_EXECUTION_CONTEXT Context,
  1208. PAML_STATEMENT NextStatement
  1209. )
  1210. /*++
  1211. Routine Description:
  1212. This routine creates a IndexField (in an Operation Region) statement.
  1213. Arguments:
  1214. Context - Supplies a pointer to an initialized AML execution context. The
  1215. next statement will be created based on the current execution offset.
  1216. The current offset of the context will be incremented beyond the portion
  1217. of this statement that was successfully parsed.
  1218. NextStatement - Supplies a pointer where the next statement will be
  1219. returned.
  1220. Return Value:
  1221. Status code.
  1222. --*/
  1223. {
  1224. PUCHAR InstructionPointer;
  1225. NextStatement->Type = AmlStatementIndexField;
  1226. Context->CurrentOffset += 1;
  1227. //
  1228. // Parse the package length to get the end offset.
  1229. //
  1230. NextStatement->AdditionalData = Context->CurrentOffset;
  1231. NextStatement->AdditionalData += AcpipParsePackageLength(Context);
  1232. if (NextStatement->AdditionalData == Context->CurrentOffset) {
  1233. return STATUS_UNSUCCESSFUL;
  1234. }
  1235. if (NextStatement->AdditionalData > Context->AmlCodeSize) {
  1236. return STATUS_MALFORMED_DATA_STREAM;
  1237. }
  1238. //
  1239. // Parse the name string of the Index register name.
  1240. //
  1241. NextStatement->Argument[0] = AcpipParseNameString(Context);
  1242. if (NextStatement->Argument[0] == NULL) {
  1243. return STATUS_UNSUCCESSFUL;
  1244. }
  1245. //
  1246. // Parse the Data register name.
  1247. //
  1248. NextStatement->Argument[1] = AcpipParseNameString(Context);
  1249. if (NextStatement->Argument[1] == NULL) {
  1250. return STATUS_UNSUCCESSFUL;
  1251. }
  1252. //
  1253. // Parse the starting flags and store them in additional data 2.
  1254. //
  1255. InstructionPointer = (PUCHAR)Context->AmlCode + Context->CurrentOffset;
  1256. NextStatement->AdditionalData2 = *InstructionPointer;
  1257. Context->CurrentOffset += 1;
  1258. NextStatement->ArgumentsNeeded = 2;
  1259. NextStatement->ArgumentsAcquired = 2;
  1260. return STATUS_SUCCESS;
  1261. }
  1262. KSTATUS
  1263. AcpipCreateIndexStatement (
  1264. PAML_EXECUTION_CONTEXT Context,
  1265. PAML_STATEMENT NextStatement
  1266. )
  1267. /*++
  1268. Routine Description:
  1269. This routine creates an Index statement.
  1270. Arguments:
  1271. Context - Supplies a pointer to an initialized AML execution context. The
  1272. next statement will be created based on the current execution offset.
  1273. The current offset of the context will be incremented beyond the portion
  1274. of this statement that was successfully parsed.
  1275. NextStatement - Supplies a pointer where the next statement will be
  1276. returned. The caller is responsible for freeing this memory.
  1277. Return Value:
  1278. STATUS_SUCCESS always.
  1279. --*/
  1280. {
  1281. NextStatement->Type = AmlStatementIndex;
  1282. Context->CurrentOffset += 1;
  1283. NextStatement->ArgumentsNeeded = 3;
  1284. NextStatement->ArgumentsAcquired = 0;
  1285. return STATUS_SUCCESS;
  1286. }
  1287. KSTATUS
  1288. AcpipCreateInvalidOpcodeStatement (
  1289. PAML_EXECUTION_CONTEXT Context,
  1290. PAML_STATEMENT NextStatement
  1291. )
  1292. /*++
  1293. Routine Description:
  1294. This routine is a placeholder function executed when an invalid opcode of
  1295. AML code is parsed.
  1296. Arguments:
  1297. Context - Supplies a pointer to an initialized AML execution context. The
  1298. next statement will be created based on the current execution offset.
  1299. The current offset of the context will be incremented beyond the portion
  1300. of this statement that was successfully parsed.
  1301. NextStatement - Supplies a pointer where the next statement will be
  1302. returned. The caller is responsible for freeing this memory.
  1303. Return Value:
  1304. STATUS_INVALID_OPCODE always.
  1305. --*/
  1306. {
  1307. ASSERT(FALSE);
  1308. return STATUS_INVALID_OPCODE;
  1309. }
  1310. KSTATUS
  1311. AcpipCreateLoadStatement (
  1312. PAML_EXECUTION_CONTEXT Context,
  1313. PAML_STATEMENT NextStatement
  1314. )
  1315. /*++
  1316. Routine Description:
  1317. This routine creates a Load (definition block) statement.
  1318. Arguments:
  1319. Context - Supplies a pointer to an initialized AML execution context. The
  1320. next statement will be created based on the current execution offset.
  1321. The current offset of the context will be incremented beyond the portion
  1322. of this statement that was successfully parsed.
  1323. NextStatement - Supplies a pointer where the next statement will be
  1324. returned. The caller is responsible for freeing this memory.
  1325. Return Value:
  1326. STATUS_SUCCESS always.
  1327. --*/
  1328. {
  1329. NextStatement->Type = AmlStatementLoad;
  1330. Context->CurrentOffset += 1;
  1331. NextStatement->ArgumentsNeeded = 2;
  1332. NextStatement->ArgumentsAcquired = 0;
  1333. return STATUS_SUCCESS;
  1334. }
  1335. KSTATUS
  1336. AcpipCreateLoadTableStatement (
  1337. PAML_EXECUTION_CONTEXT Context,
  1338. PAML_STATEMENT NextStatement
  1339. )
  1340. /*++
  1341. Routine Description:
  1342. This routine creates a LoadTable statement.
  1343. Arguments:
  1344. Context - Supplies a pointer to an initialized AML execution context. The
  1345. next statement will be created based on the current execution offset.
  1346. The current offset of the context will be incremented beyond the portion
  1347. of this statement that was successfully parsed.
  1348. NextStatement - Supplies a pointer where the next statement will be
  1349. returned. The caller is responsible for freeing this memory.
  1350. Return Value:
  1351. STATUS_SUCCESS always.
  1352. --*/
  1353. {
  1354. NextStatement->Type = AmlStatementLoadTable;
  1355. //
  1356. // TODO: Implement AML Load Table opcode.
  1357. //
  1358. ASSERT(FALSE);
  1359. return STATUS_NOT_IMPLEMENTED;
  1360. }
  1361. KSTATUS
  1362. AcpipCreateLocalStatement (
  1363. PAML_EXECUTION_CONTEXT Context,
  1364. PAML_STATEMENT NextStatement
  1365. )
  1366. /*++
  1367. Routine Description:
  1368. This routine creates a statement for opcodes 0x60 - 0x67, LocalX statements.
  1369. Arguments:
  1370. Context - Supplies a pointer to an initialized AML execution context. The
  1371. next statement will be created based on the current execution offset.
  1372. The current offset of the context will be incremented beyond the portion
  1373. of this statement that was successfully parsed.
  1374. NextStatement - Supplies a pointer where the next statement will be
  1375. returned. The caller is responsible for freeing this memory.
  1376. Return Value:
  1377. STATUS_SUCCESS always.
  1378. --*/
  1379. {
  1380. UCHAR Instruction;
  1381. PUCHAR InstructionPointer;
  1382. ULONG LocalNumber;
  1383. NextStatement->Type = AmlStatementLocal;
  1384. InstructionPointer = (PUCHAR)(Context->AmlCode + Context->CurrentOffset);
  1385. Instruction = *InstructionPointer;
  1386. LocalNumber = Instruction - ACPI_LOCAL_0_OPCODE;
  1387. //
  1388. // Store which argument number it is in the additional data space.
  1389. //
  1390. NextStatement->AdditionalData = LocalNumber;
  1391. Context->CurrentOffset += 1;
  1392. return STATUS_SUCCESS;
  1393. }
  1394. KSTATUS
  1395. AcpipCreateLogicalAndStatement (
  1396. PAML_EXECUTION_CONTEXT Context,
  1397. PAML_STATEMENT NextStatement
  1398. )
  1399. /*++
  1400. Routine Description:
  1401. This routine creates a Logical And statement.
  1402. Arguments:
  1403. Context - Supplies a pointer to an initialized AML execution context. The
  1404. next statement will be created based on the current execution offset.
  1405. The current offset of the context will be incremented beyond the portion
  1406. of this statement that was successfully parsed.
  1407. NextStatement - Supplies a pointer where the next statement will be
  1408. returned.
  1409. Return Value:
  1410. STATUS_SUCCESS always.
  1411. --*/
  1412. {
  1413. NextStatement->Type = AmlStatementLogicalAnd;
  1414. Context->CurrentOffset += 1;
  1415. NextStatement->ArgumentsNeeded = 2;
  1416. NextStatement->ArgumentsAcquired = 0;
  1417. return STATUS_SUCCESS;
  1418. }
  1419. KSTATUS
  1420. AcpipCreateLogicalEqualStatement (
  1421. PAML_EXECUTION_CONTEXT Context,
  1422. PAML_STATEMENT NextStatement
  1423. )
  1424. /*++
  1425. Routine Description:
  1426. This routine creates a Logical Equal statement.
  1427. Arguments:
  1428. Context - Supplies a pointer to an initialized AML execution context. The
  1429. next statement will be created based on the current execution offset.
  1430. The current offset of the context will be incremented beyond the portion
  1431. of this statement that was successfully parsed.
  1432. NextStatement - Supplies a pointer where the next statement will be
  1433. returned.
  1434. Return Value:
  1435. STATUS_SUCCESS always.
  1436. --*/
  1437. {
  1438. NextStatement->Type = AmlStatementLogicalEqual;
  1439. Context->CurrentOffset += 1;
  1440. NextStatement->ArgumentsNeeded = 2;
  1441. NextStatement->ArgumentsAcquired = 0;
  1442. return STATUS_SUCCESS;
  1443. }
  1444. KSTATUS
  1445. AcpipCreateLogicalGreaterStatement (
  1446. PAML_EXECUTION_CONTEXT Context,
  1447. PAML_STATEMENT NextStatement
  1448. )
  1449. /*++
  1450. Routine Description:
  1451. This routine creates a Logical Greater statement.
  1452. Arguments:
  1453. Context - Supplies a pointer to an initialized AML execution context. The
  1454. next statement will be created based on the current execution offset.
  1455. The current offset of the context will be incremented beyond the portion
  1456. of this statement that was successfully parsed.
  1457. NextStatement - Supplies a pointer where the next statement will be
  1458. returned.
  1459. Return Value:
  1460. STATUS_SUCCESS always.
  1461. --*/
  1462. {
  1463. NextStatement->Type = AmlStatementLogicalGreater;
  1464. Context->CurrentOffset += 1;
  1465. NextStatement->ArgumentsNeeded = 2;
  1466. NextStatement->ArgumentsAcquired = 0;
  1467. return STATUS_SUCCESS;
  1468. }
  1469. KSTATUS
  1470. AcpipCreateLogicalLessStatement (
  1471. PAML_EXECUTION_CONTEXT Context,
  1472. PAML_STATEMENT NextStatement
  1473. )
  1474. /*++
  1475. Routine Description:
  1476. This routine creates a Logical Less statement.
  1477. Arguments:
  1478. Context - Supplies a pointer to an initialized AML execution context. The
  1479. next statement will be created based on the current execution offset.
  1480. The current offset of the context will be incremented beyond the portion
  1481. of this statement that was successfully parsed.
  1482. NextStatement - Supplies a pointer where the next statement will be
  1483. returned.
  1484. Return Value:
  1485. STATUS_SUCCESS always.
  1486. --*/
  1487. {
  1488. NextStatement->Type = AmlStatementLogicalLess;
  1489. Context->CurrentOffset += 1;
  1490. NextStatement->ArgumentsNeeded = 2;
  1491. NextStatement->ArgumentsAcquired = 0;
  1492. return STATUS_SUCCESS;
  1493. }
  1494. KSTATUS
  1495. AcpipCreateLogicalNotStatement (
  1496. PAML_EXECUTION_CONTEXT Context,
  1497. PAML_STATEMENT NextStatement
  1498. )
  1499. /*++
  1500. Routine Description:
  1501. This routine creates a Logical Not statement.
  1502. Arguments:
  1503. Context - Supplies a pointer to an initialized AML execution context. The
  1504. next statement will be created based on the current execution offset.
  1505. The current offset of the context will be incremented beyond the portion
  1506. of this statement that was successfully parsed.
  1507. NextStatement - Supplies a pointer where the next statement will be
  1508. returned.
  1509. Return Value:
  1510. STATUS_SUCCESS always.
  1511. --*/
  1512. {
  1513. NextStatement->Type = AmlStatementLogicalNot;
  1514. Context->CurrentOffset += 1;
  1515. NextStatement->ArgumentsNeeded = 1;
  1516. NextStatement->ArgumentsAcquired = 0;
  1517. return STATUS_SUCCESS;
  1518. }
  1519. KSTATUS
  1520. AcpipCreateLogicalOrStatement (
  1521. PAML_EXECUTION_CONTEXT Context,
  1522. PAML_STATEMENT NextStatement
  1523. )
  1524. /*++
  1525. Routine Description:
  1526. This routine creates a Logical Or statement.
  1527. Arguments:
  1528. Context - Supplies a pointer to an initialized AML execution context. The
  1529. next statement will be created based on the current execution offset.
  1530. The current offset of the context will be incremented beyond the portion
  1531. of this statement that was successfully parsed.
  1532. NextStatement - Supplies a pointer where the next statement will be
  1533. returned.
  1534. Return Value:
  1535. STATUS_SUCCESS always.
  1536. --*/
  1537. {
  1538. NextStatement->Type = AmlStatementLogicalOr;
  1539. Context->CurrentOffset += 1;
  1540. NextStatement->ArgumentsNeeded = 2;
  1541. NextStatement->ArgumentsAcquired = 0;
  1542. return STATUS_SUCCESS;
  1543. }
  1544. KSTATUS
  1545. AcpipCreateMatchStatement (
  1546. PAML_EXECUTION_CONTEXT Context,
  1547. PAML_STATEMENT NextStatement
  1548. )
  1549. /*++
  1550. Routine Description:
  1551. This routine creates a Match statement.
  1552. Arguments:
  1553. Context - Supplies a pointer to an initialized AML execution context. The
  1554. next statement will be created based on the current execution offset.
  1555. The current offset of the context will be incremented beyond the portion
  1556. of this statement that was successfully parsed.
  1557. NextStatement - Supplies a pointer where the next statement will be
  1558. returned. The caller is responsible for freeing this memory.
  1559. Return Value:
  1560. STATUS_SUCCESS always.
  1561. --*/
  1562. {
  1563. NextStatement->Type = AmlStatementMatch;
  1564. Context->CurrentOffset += 1;
  1565. NextStatement->ArgumentsNeeded = 4;
  1566. NextStatement->ArgumentsAcquired = 0;
  1567. NextStatement->AdditionalData = 0;
  1568. return STATUS_SUCCESS;
  1569. }
  1570. KSTATUS
  1571. AcpipCreateMethodStatement (
  1572. PAML_EXECUTION_CONTEXT Context,
  1573. PAML_STATEMENT NextStatement
  1574. )
  1575. /*++
  1576. Routine Description:
  1577. This routine creates a Method statement.
  1578. Arguments:
  1579. Context - Supplies a pointer to an initialized AML execution context. The
  1580. next statement will be created based on the current execution offset.
  1581. The current offset of the context will be incremented beyond the portion
  1582. of this statement that was successfully parsed.
  1583. NextStatement - Supplies a pointer where the next statement will be
  1584. returned. The caller is responsible for freeing this memory.
  1585. Return Value:
  1586. Status code.
  1587. --*/
  1588. {
  1589. PUCHAR InstructionPointer;
  1590. NextStatement->Type = AmlStatementMethod;
  1591. Context->CurrentOffset += 1;
  1592. NextStatement->ArgumentsNeeded = 1;
  1593. NextStatement->ArgumentsAcquired = 1;
  1594. //
  1595. // Parse the package length to get the end offset.
  1596. //
  1597. NextStatement->AdditionalData = Context->CurrentOffset;
  1598. NextStatement->AdditionalData += AcpipParsePackageLength(Context);
  1599. if (NextStatement->AdditionalData == Context->CurrentOffset) {
  1600. return STATUS_UNSUCCESSFUL;
  1601. }
  1602. //
  1603. // Parse the NameString for the method name.
  1604. //
  1605. NextStatement->Argument[0] = AcpipParseNameString(Context);
  1606. if (NextStatement->Argument[0] == NULL) {
  1607. return STATUS_UNSUCCESSFUL;
  1608. }
  1609. //
  1610. // Store the method flags into additional data 2. This leaves the
  1611. // current offset pointing at the first term in the TermList.
  1612. //
  1613. InstructionPointer = (PUCHAR)Context->AmlCode + Context->CurrentOffset;
  1614. NextStatement->AdditionalData2 = *InstructionPointer;
  1615. Context->CurrentOffset += 1;
  1616. return STATUS_SUCCESS;
  1617. }
  1618. KSTATUS
  1619. AcpipCreateMidStatement (
  1620. PAML_EXECUTION_CONTEXT Context,
  1621. PAML_STATEMENT NextStatement
  1622. )
  1623. /*++
  1624. Routine Description:
  1625. This routine creates a Mid statement.
  1626. Arguments:
  1627. Context - Supplies a pointer to an initialized AML execution context. The
  1628. next statement will be created based on the current execution offset.
  1629. The current offset of the context will be incremented beyond the portion
  1630. of this statement that was successfully parsed.
  1631. NextStatement - Supplies a pointer where the next statement will be
  1632. returned. The caller is responsible for freeing this memory.
  1633. Return Value:
  1634. STATUS_SUCCESS always.
  1635. --*/
  1636. {
  1637. KSTATUS Status;
  1638. NextStatement->Type = AmlStatementMid;
  1639. Context->CurrentOffset += 1;
  1640. NextStatement->ArgumentsNeeded = 4;
  1641. NextStatement->ArgumentsAcquired = 0;
  1642. Status = STATUS_SUCCESS;
  1643. return Status;
  1644. }
  1645. KSTATUS
  1646. AcpipCreateModStatement (
  1647. PAML_EXECUTION_CONTEXT Context,
  1648. PAML_STATEMENT NextStatement
  1649. )
  1650. /*++
  1651. Routine Description:
  1652. This routine creates a statement for an Mod statement.
  1653. Arguments:
  1654. Context - Supplies a pointer to an initialized AML execution context. The
  1655. next statement will be created based on the current execution offset.
  1656. The current offset of the context will be incremented beyond the portion
  1657. of this statement that was successfully parsed.
  1658. NextStatement - Supplies a pointer where the next statement will be
  1659. returned.
  1660. Return Value:
  1661. STATUS_SUCCESS on success.
  1662. Other error codes on failure.
  1663. --*/
  1664. {
  1665. KSTATUS Status;
  1666. NextStatement->Type = AmlStatementMod;
  1667. Context->CurrentOffset += 1;
  1668. NextStatement->ArgumentsNeeded = 3;
  1669. NextStatement->ArgumentsAcquired = 0;
  1670. Status = STATUS_SUCCESS;
  1671. return Status;
  1672. }
  1673. KSTATUS
  1674. AcpipCreateMultiplyStatement (
  1675. PAML_EXECUTION_CONTEXT Context,
  1676. PAML_STATEMENT NextStatement
  1677. )
  1678. /*++
  1679. Routine Description:
  1680. This routine creates a statement for a Multiply statement.
  1681. Arguments:
  1682. Context - Supplies a pointer to an initialized AML execution context. The
  1683. next statement will be created based on the current execution offset.
  1684. The current offset of the context will be incremented beyond the portion
  1685. of this statement that was successfully parsed.
  1686. NextStatement - Supplies a pointer where the next statement will be
  1687. returned.
  1688. Return Value:
  1689. STATUS_SUCCESS always.
  1690. --*/
  1691. {
  1692. KSTATUS Status;
  1693. NextStatement->Type = AmlStatementMultiply;
  1694. Context->CurrentOffset += 1;
  1695. NextStatement->ArgumentsNeeded = 3;
  1696. NextStatement->ArgumentsAcquired = 0;
  1697. Status = STATUS_SUCCESS;
  1698. return Status;
  1699. }
  1700. KSTATUS
  1701. AcpipCreateMutexStatement (
  1702. PAML_EXECUTION_CONTEXT Context,
  1703. PAML_STATEMENT NextStatement
  1704. )
  1705. /*++
  1706. Routine Description:
  1707. This routine creates a statement for a Mutex (create) statement.
  1708. Arguments:
  1709. Context - Supplies a pointer to an initialized AML execution context. The
  1710. next statement will be created based on the current execution offset.
  1711. The current offset of the context will be incremented beyond the portion
  1712. of this statement that was successfully parsed.
  1713. NextStatement - Supplies a pointer where the next statement will be
  1714. returned.
  1715. Return Value:
  1716. Status code.
  1717. --*/
  1718. {
  1719. PUCHAR InstructionPointer;
  1720. NextStatement->Type = AmlStatementMutex;
  1721. Context->CurrentOffset += 1;
  1722. NextStatement->ArgumentsNeeded = 1;
  1723. NextStatement->ArgumentsAcquired = 1;
  1724. //
  1725. // Get the name string of the mutex.
  1726. //
  1727. NextStatement->Argument[0] = AcpipParseNameString(Context);
  1728. if (NextStatement->Argument[0] == NULL) {
  1729. return STATUS_UNSUCCESSFUL;
  1730. }
  1731. //
  1732. // Store the sync flags in additional data.
  1733. //
  1734. InstructionPointer = (PUCHAR)Context->AmlCode + Context->CurrentOffset;
  1735. NextStatement->AdditionalData = *InstructionPointer;
  1736. Context->CurrentOffset += 1;
  1737. return STATUS_SUCCESS;
  1738. }
  1739. KSTATUS
  1740. AcpipCreateNameStatement (
  1741. PAML_EXECUTION_CONTEXT Context,
  1742. PAML_STATEMENT NextStatement
  1743. )
  1744. /*++
  1745. Routine Description:
  1746. This routine creates a statement for a Name statement.
  1747. Arguments:
  1748. Context - Supplies a pointer to an initialized AML execution context. The
  1749. next statement will be created based on the current execution offset.
  1750. The current offset of the context will be incremented beyond the portion
  1751. of this statement that was successfully parsed.
  1752. NextStatement - Supplies a pointer where the next statement will be
  1753. returned.
  1754. Return Value:
  1755. STATUS_SUCCESS on success.
  1756. Other error codes on failure.
  1757. --*/
  1758. {
  1759. KSTATUS Status;
  1760. NextStatement->Type = AmlStatementName;
  1761. Context->CurrentOffset += 1;
  1762. NextStatement->ArgumentsNeeded = 2;
  1763. NextStatement->ArgumentsAcquired = 1;
  1764. NextStatement->Argument[0] = AcpipParseNameString(Context);
  1765. if (NextStatement->Argument[0] == NULL) {
  1766. Status = STATUS_UNSUCCESSFUL;
  1767. goto CreateNameStatementEnd;
  1768. }
  1769. Status = STATUS_SUCCESS;
  1770. CreateNameStatementEnd:
  1771. return Status;
  1772. }
  1773. KSTATUS
  1774. AcpipCreateNameStringStatement (
  1775. PAML_EXECUTION_CONTEXT Context,
  1776. PAML_STATEMENT NextStatement
  1777. )
  1778. /*++
  1779. Routine Description:
  1780. This routine creates a statement for a NameString statement.
  1781. Arguments:
  1782. Context - Supplies a pointer to an initialized AML execution context. The
  1783. next statement will be created based on the current execution offset.
  1784. The current offset of the context will be incremented beyond the portion
  1785. of this statement that was successfully parsed.
  1786. NextStatement - Supplies a pointer where the next statement will be
  1787. returned.
  1788. Return Value:
  1789. STATUS_SUCCESS on success.
  1790. Other error codes on failure.
  1791. --*/
  1792. {
  1793. KSTATUS Status;
  1794. NextStatement->Type = AmlStatementNameString;
  1795. NextStatement->ArgumentsNeeded = 1;
  1796. NextStatement->ArgumentsAcquired = 1;
  1797. NextStatement->Argument[0] = AcpipParseNameString(Context);
  1798. if (NextStatement->Argument[0] == NULL) {
  1799. Status = STATUS_UNSUCCESSFUL;
  1800. goto CreateNameStringStatementEnd;
  1801. }
  1802. Status = STATUS_SUCCESS;
  1803. CreateNameStringStatementEnd:
  1804. return Status;
  1805. }
  1806. KSTATUS
  1807. AcpipCreateNandStatement (
  1808. PAML_EXECUTION_CONTEXT Context,
  1809. PAML_STATEMENT NextStatement
  1810. )
  1811. /*++
  1812. Routine Description:
  1813. This routine creates a statement for a Nand statement.
  1814. Arguments:
  1815. Context - Supplies a pointer to an initialized AML execution context. The
  1816. next statement will be created based on the current execution offset.
  1817. The current offset of the context will be incremented beyond the portion
  1818. of this statement that was successfully parsed.
  1819. NextStatement - Supplies a pointer where the next statement will be
  1820. returned.
  1821. Return Value:
  1822. STATUS_SUCCESS always.
  1823. --*/
  1824. {
  1825. KSTATUS Status;
  1826. NextStatement->Type = AmlStatementNand;
  1827. Context->CurrentOffset += 1;
  1828. NextStatement->ArgumentsNeeded = 3;
  1829. NextStatement->ArgumentsAcquired = 0;
  1830. Status = STATUS_SUCCESS;
  1831. return Status;
  1832. }
  1833. KSTATUS
  1834. AcpipCreateNoOpStatement (
  1835. PAML_EXECUTION_CONTEXT Context,
  1836. PAML_STATEMENT NextStatement
  1837. )
  1838. /*++
  1839. Routine Description:
  1840. This routine creates a statement for a No-Op statement.
  1841. Arguments:
  1842. Context - Supplies a pointer to an initialized AML execution context. The
  1843. next statement will be created based on the current execution offset.
  1844. The current offset of the context will be incremented beyond the portion
  1845. of this statement that was successfully parsed.
  1846. NextStatement - Supplies a pointer where the next statement will be
  1847. returned.
  1848. Return Value:
  1849. STATUS_SUCCESS always.
  1850. --*/
  1851. {
  1852. NextStatement->Type = AmlStatementNoOp;
  1853. Context->CurrentOffset += 1;
  1854. NextStatement->ArgumentsNeeded = 0;
  1855. NextStatement->ArgumentsAcquired = 0;
  1856. return STATUS_SUCCESS;
  1857. }
  1858. KSTATUS
  1859. AcpipCreateNorStatement (
  1860. PAML_EXECUTION_CONTEXT Context,
  1861. PAML_STATEMENT NextStatement
  1862. )
  1863. /*++
  1864. Routine Description:
  1865. This routine creates a statement for a Nor statement.
  1866. Arguments:
  1867. Context - Supplies a pointer to an initialized AML execution context. The
  1868. next statement will be created based on the current execution offset.
  1869. The current offset of the context will be incremented beyond the portion
  1870. of this statement that was successfully parsed.
  1871. NextStatement - Supplies a pointer where the next statement will be
  1872. returned.
  1873. Return Value:
  1874. STATUS_SUCCESS always.
  1875. --*/
  1876. {
  1877. KSTATUS Status;
  1878. NextStatement->Type = AmlStatementNor;
  1879. Context->CurrentOffset += 1;
  1880. NextStatement->ArgumentsNeeded = 3;
  1881. NextStatement->ArgumentsAcquired = 0;
  1882. Status = STATUS_SUCCESS;
  1883. return Status;
  1884. }
  1885. KSTATUS
  1886. AcpipCreateNotifyStatement (
  1887. PAML_EXECUTION_CONTEXT Context,
  1888. PAML_STATEMENT NextStatement
  1889. )
  1890. /*++
  1891. Routine Description:
  1892. This routine creates a Notify statement.
  1893. Arguments:
  1894. Context - Supplies a pointer to an initialized AML execution context. The
  1895. next statement will be created based on the current execution offset.
  1896. The current offset of the context will be incremented beyond the portion
  1897. of this statement that was successfully parsed.
  1898. NextStatement - Supplies a pointer where the next statement will be
  1899. returned.
  1900. Return Value:
  1901. STATUS_SUCCESS always.
  1902. --*/
  1903. {
  1904. NextStatement->Type = AmlStatementNotify;
  1905. Context->CurrentOffset += 1;
  1906. NextStatement->ArgumentsNeeded = 2;
  1907. NextStatement->ArgumentsAcquired = 0;
  1908. return STATUS_SUCCESS;
  1909. }
  1910. KSTATUS
  1911. AcpipCreateNotStatement (
  1912. PAML_EXECUTION_CONTEXT Context,
  1913. PAML_STATEMENT NextStatement
  1914. )
  1915. /*++
  1916. Routine Description:
  1917. This routine creates a bitwise Not statement.
  1918. Arguments:
  1919. Context - Supplies a pointer to an initialized AML execution context. The
  1920. next statement will be created based on the current execution offset.
  1921. The current offset of the context will be incremented beyond the portion
  1922. of this statement that was successfully parsed.
  1923. NextStatement - Supplies a pointer where the next statement will be
  1924. returned.
  1925. Return Value:
  1926. STATUS_SUCCESS always.
  1927. --*/
  1928. {
  1929. NextStatement->Type = AmlStatementNot;
  1930. Context->CurrentOffset += 1;
  1931. NextStatement->ArgumentsNeeded = 2;
  1932. NextStatement->ArgumentsAcquired = 0;
  1933. return STATUS_SUCCESS;
  1934. }
  1935. KSTATUS
  1936. AcpipCreateObjectTypeStatement (
  1937. PAML_EXECUTION_CONTEXT Context,
  1938. PAML_STATEMENT NextStatement
  1939. )
  1940. /*++
  1941. Routine Description:
  1942. This routine creates an Object Type statement.
  1943. Arguments:
  1944. Context - Supplies a pointer to an initialized AML execution context. The
  1945. next statement will be created based on the current execution offset.
  1946. The current offset of the context will be incremented beyond the portion
  1947. of this statement that was successfully parsed.
  1948. NextStatement - Supplies a pointer where the next statement will be
  1949. returned.
  1950. Return Value:
  1951. STATUS_SUCCESS always.
  1952. --*/
  1953. {
  1954. NextStatement->Type = AmlStatementObjectType;
  1955. Context->CurrentOffset += 1;
  1956. NextStatement->ArgumentsNeeded = 1;
  1957. NextStatement->ArgumentsAcquired = 0;
  1958. return STATUS_SUCCESS;
  1959. }
  1960. KSTATUS
  1961. AcpipCreateOrStatement (
  1962. PAML_EXECUTION_CONTEXT Context,
  1963. PAML_STATEMENT NextStatement
  1964. )
  1965. /*++
  1966. Routine Description:
  1967. This routine creates a statement for an Or statement.
  1968. Arguments:
  1969. Context - Supplies a pointer to an initialized AML execution context. The
  1970. next statement will be created based on the current execution offset.
  1971. The current offset of the context will be incremented beyond the portion
  1972. of this statement that was successfully parsed.
  1973. NextStatement - Supplies a pointer where the next statement will be
  1974. returned.
  1975. Return Value:
  1976. STATUS_SUCCESS always.
  1977. --*/
  1978. {
  1979. KSTATUS Status;
  1980. NextStatement->Type = AmlStatementOr;
  1981. Context->CurrentOffset += 1;
  1982. NextStatement->ArgumentsNeeded = 3;
  1983. NextStatement->ArgumentsAcquired = 0;
  1984. Status = STATUS_SUCCESS;
  1985. return Status;
  1986. }
  1987. KSTATUS
  1988. AcpipCreateOnesStatement (
  1989. PAML_EXECUTION_CONTEXT Context,
  1990. PAML_STATEMENT NextStatement
  1991. )
  1992. /*++
  1993. Routine Description:
  1994. This routine creates a Ones statement, which is a constant of all Fs.
  1995. Arguments:
  1996. Context - Supplies a pointer to an initialized AML execution context. The
  1997. next statement will be created based on the current execution offset.
  1998. The current offset of the context will be incremented beyond the portion
  1999. of this statement that was successfully parsed.
  2000. NextStatement - Supplies a pointer where the next statement will be
  2001. returned. The caller is responsible for freeing this memory.
  2002. Return Value:
  2003. STATUS_SUCCESS always.
  2004. --*/
  2005. {
  2006. NextStatement->Type = AmlStatementOnes;
  2007. NextStatement->ArgumentsNeeded = 0;
  2008. NextStatement->ArgumentsAcquired = 0;
  2009. Context->CurrentOffset += 1;
  2010. return STATUS_SUCCESS;
  2011. }
  2012. KSTATUS
  2013. AcpipCreateOneStatement (
  2014. PAML_EXECUTION_CONTEXT Context,
  2015. PAML_STATEMENT NextStatement
  2016. )
  2017. /*++
  2018. Routine Description:
  2019. This routine creates a statement for opcode 1, a constant 1.
  2020. Arguments:
  2021. Context - Supplies a pointer to an initialized AML execution context. The
  2022. next statement will be created based on the current execution offset.
  2023. The current offset of the context will be incremented beyond the portion
  2024. of this statement that was successfully parsed.
  2025. NextStatement - Supplies a pointer where the next statement will be
  2026. returned. The caller is responsible for freeing this memory.
  2027. Return Value:
  2028. STATUS_SUCCESS always.
  2029. --*/
  2030. {
  2031. NextStatement->Type = AmlStatementOne;
  2032. NextStatement->ArgumentsNeeded = 0;
  2033. NextStatement->ArgumentsAcquired = 0;
  2034. Context->CurrentOffset += 1;
  2035. return STATUS_SUCCESS;
  2036. }
  2037. KSTATUS
  2038. AcpipCreateOperationRegionStatement (
  2039. PAML_EXECUTION_CONTEXT Context,
  2040. PAML_STATEMENT NextStatement
  2041. )
  2042. /*++
  2043. Routine Description:
  2044. This routine creates an Operation Region statement.
  2045. Arguments:
  2046. Context - Supplies a pointer to an initialized AML execution context. The
  2047. next statement will be created based on the current execution offset.
  2048. The current offset of the context will be incremented beyond the portion
  2049. of this statement that was successfully parsed.
  2050. NextStatement - Supplies a pointer where the next statement will be
  2051. returned. The caller is responsible for freeing this memory.
  2052. Return Value:
  2053. Status code.
  2054. --*/
  2055. {
  2056. PUCHAR InstructionPointer;
  2057. NextStatement->Type = AmlStatementOperationRegion;
  2058. //
  2059. // Operation regions define a NameString, RegionOffset, and RegionLength.
  2060. // Immediately after the NameString is a byte constant or the region space,
  2061. // which is not counted as one of the three arguments.
  2062. //
  2063. NextStatement->ArgumentsNeeded = 3;
  2064. NextStatement->ArgumentsAcquired = 1;
  2065. //
  2066. // Parse the name string now.
  2067. //
  2068. Context->CurrentOffset += 1;
  2069. NextStatement->Argument[0] = AcpipParseNameString(Context);
  2070. if (NextStatement->Argument[0] == NULL) {
  2071. return STATUS_UNSUCCESSFUL;
  2072. }
  2073. //
  2074. // Store the byte for the address space in the additional data field.
  2075. //
  2076. InstructionPointer = (PUCHAR)Context->AmlCode + Context->CurrentOffset;
  2077. NextStatement->AdditionalData = *InstructionPointer;
  2078. Context->CurrentOffset += 1;
  2079. return STATUS_SUCCESS;
  2080. }
  2081. KSTATUS
  2082. AcpipCreatePackageStatement (
  2083. PAML_EXECUTION_CONTEXT Context,
  2084. PAML_STATEMENT NextStatement
  2085. )
  2086. /*++
  2087. Routine Description:
  2088. This routine creates a Package statement (basically an array of objects).
  2089. Arguments:
  2090. Context - Supplies a pointer to an initialized AML execution context. The
  2091. next statement will be created based on the current execution offset.
  2092. The current offset of the context will be incremented beyond the portion
  2093. of this statement that was successfully parsed.
  2094. NextStatement - Supplies a pointer where the next statement will be
  2095. returned. The caller is responsible for freeing this memory.
  2096. Return Value:
  2097. Status code.
  2098. --*/
  2099. {
  2100. PUCHAR InstructionPointer;
  2101. NextStatement->Type = AmlStatementPackage;
  2102. Context->CurrentOffset += 1;
  2103. NextStatement->ArgumentsNeeded = 0;
  2104. NextStatement->ArgumentsAcquired = 0;
  2105. //
  2106. // Get the package length.
  2107. //
  2108. NextStatement->AdditionalData = Context->CurrentOffset;
  2109. NextStatement->AdditionalData += AcpipParsePackageLength(Context);
  2110. if (NextStatement->AdditionalData == Context->CurrentOffset) {
  2111. return STATUS_UNSUCCESSFUL;
  2112. }
  2113. //
  2114. // Store the number of elements in Additional Data 2.
  2115. //
  2116. InstructionPointer = (PUCHAR)Context->AmlCode + Context->CurrentOffset;
  2117. NextStatement->AdditionalData2 = *InstructionPointer;
  2118. Context->CurrentOffset += 1;
  2119. NextStatement->Reduction = NULL;
  2120. return STATUS_SUCCESS;
  2121. }
  2122. KSTATUS
  2123. AcpipCreatePowerResourceStatement (
  2124. PAML_EXECUTION_CONTEXT Context,
  2125. PAML_STATEMENT NextStatement
  2126. )
  2127. /*++
  2128. Routine Description:
  2129. This routine creates a statement for a Power Resource declaration statement.
  2130. Arguments:
  2131. Context - Supplies a pointer to an initialized AML execution context. The
  2132. next statement will be created based on the current execution offset.
  2133. The current offset of the context will be incremented beyond the portion
  2134. of this statement that was successfully parsed.
  2135. NextStatement - Supplies a pointer where the next statement will be
  2136. returned.
  2137. Return Value:
  2138. Status code.
  2139. --*/
  2140. {
  2141. NextStatement->Type = AmlStatementPowerResource;
  2142. Context->CurrentOffset += 1;
  2143. //
  2144. // Store the end offset of the object list in additional data.
  2145. //
  2146. NextStatement->AdditionalData = Context->CurrentOffset;
  2147. NextStatement->AdditionalData += AcpipParsePackageLength(Context);
  2148. if (NextStatement->AdditionalData == Context->CurrentOffset) {
  2149. return STATUS_UNSUCCESSFUL;
  2150. }
  2151. //
  2152. // Parse the name string argument.
  2153. //
  2154. NextStatement->ArgumentsNeeded = 1;
  2155. NextStatement->Argument[0] = AcpipParseNameString(Context);
  2156. if (NextStatement->Argument[0] == NULL) {
  2157. return STATUS_UNSUCCESSFUL;
  2158. }
  2159. NextStatement->ArgumentsAcquired = 1;
  2160. //
  2161. // Store the offset to the additional argumenents (a byte and a short) for
  2162. // later execution, and advance beyond them.
  2163. //
  2164. NextStatement->AdditionalData2 = Context->CurrentOffset;
  2165. Context->CurrentOffset += sizeof(BYTE) + sizeof(USHORT);
  2166. return STATUS_SUCCESS;
  2167. }
  2168. KSTATUS
  2169. AcpipCreateProcessorStatement (
  2170. PAML_EXECUTION_CONTEXT Context,
  2171. PAML_STATEMENT NextStatement
  2172. )
  2173. /*++
  2174. Routine Description:
  2175. This routine creates a statement for a Processor declaration statement.
  2176. Arguments:
  2177. Context - Supplies a pointer to an initialized AML execution context. The
  2178. next statement will be created based on the current execution offset.
  2179. The current offset of the context will be incremented beyond the portion
  2180. of this statement that was successfully parsed.
  2181. NextStatement - Supplies a pointer where the next statement will be
  2182. returned.
  2183. Return Value:
  2184. Status code.
  2185. --*/
  2186. {
  2187. NextStatement->Type = AmlStatementProcessor;
  2188. Context->CurrentOffset += 1;
  2189. //
  2190. // Store the end offset of the object list in additional data.
  2191. //
  2192. NextStatement->AdditionalData = Context->CurrentOffset;
  2193. NextStatement->AdditionalData += AcpipParsePackageLength(Context);
  2194. if (NextStatement->AdditionalData == Context->CurrentOffset) {
  2195. return STATUS_UNSUCCESSFUL;
  2196. }
  2197. //
  2198. // Parse the name string argument.
  2199. //
  2200. NextStatement->ArgumentsNeeded = 1;
  2201. NextStatement->Argument[0] = AcpipParseNameString(Context);
  2202. if (NextStatement->Argument[0] == NULL) {
  2203. return STATUS_UNSUCCESSFUL;
  2204. }
  2205. NextStatement->ArgumentsAcquired = 1;
  2206. //
  2207. // Store the offset to the additional argumenents (two bytes and a DWORD)
  2208. // for later execution, and advance beyond them.
  2209. //
  2210. NextStatement->AdditionalData2 = Context->CurrentOffset;
  2211. Context->CurrentOffset += sizeof(BYTE) + sizeof(ULONG) + sizeof(BYTE);
  2212. return STATUS_SUCCESS;
  2213. }
  2214. KSTATUS
  2215. AcpipCreateReferenceOfStatement (
  2216. PAML_EXECUTION_CONTEXT Context,
  2217. PAML_STATEMENT NextStatement
  2218. )
  2219. /*++
  2220. Routine Description:
  2221. This routine creates a "Reference Of" statement.
  2222. Arguments:
  2223. Context - Supplies a pointer to an initialized AML execution context. The
  2224. next statement will be created based on the current execution offset.
  2225. The current offset of the context will be incremented beyond the portion
  2226. of this statement that was successfully parsed.
  2227. NextStatement - Supplies a pointer where the next statement will be
  2228. returned.
  2229. Return Value:
  2230. STATUS_SUCCESS always.
  2231. --*/
  2232. {
  2233. NextStatement->Type = AmlStatementReferenceOf;
  2234. Context->CurrentOffset += 1;
  2235. //
  2236. // Start with one argument needed, though upon evaluation a simple name
  2237. // may be evaluated immediately, which means no arguments are needed.
  2238. //
  2239. NextStatement->ArgumentsNeeded = 1;
  2240. NextStatement->ArgumentsAcquired = 0;
  2241. return STATUS_SUCCESS;
  2242. }
  2243. KSTATUS
  2244. AcpipCreateReleaseStatement (
  2245. PAML_EXECUTION_CONTEXT Context,
  2246. PAML_STATEMENT NextStatement
  2247. )
  2248. /*++
  2249. Routine Description:
  2250. This routine creates a Release (mutex) statement.
  2251. Arguments:
  2252. Context - Supplies a pointer to an initialized AML execution context. The
  2253. next statement will be created based on the current execution offset.
  2254. The current offset of the context will be incremented beyond the portion
  2255. of this statement that was successfully parsed.
  2256. NextStatement - Supplies a pointer where the next statement will be
  2257. returned.
  2258. Return Value:
  2259. STATUS_SUCCESS always.
  2260. --*/
  2261. {
  2262. NextStatement->Type = AmlStatementRelease;
  2263. Context->CurrentOffset += 1;
  2264. NextStatement->ArgumentsNeeded = 1;
  2265. NextStatement->ArgumentsAcquired = 0;
  2266. return STATUS_SUCCESS;
  2267. }
  2268. KSTATUS
  2269. AcpipCreateResetStatement (
  2270. PAML_EXECUTION_CONTEXT Context,
  2271. PAML_STATEMENT NextStatement
  2272. )
  2273. /*++
  2274. Routine Description:
  2275. This routine creates a Reset (event) statement.
  2276. Arguments:
  2277. Context - Supplies a pointer to an initialized AML execution context. The
  2278. next statement will be created based on the current execution offset.
  2279. The current offset of the context will be incremented beyond the portion
  2280. of this statement that was successfully parsed.
  2281. NextStatement - Supplies a pointer where the next statement will be
  2282. returned.
  2283. Return Value:
  2284. STATUS_SUCCESS always.
  2285. --*/
  2286. {
  2287. NextStatement->Type = AmlStatementRelease;
  2288. Context->CurrentOffset += 1;
  2289. NextStatement->ArgumentsNeeded = 1;
  2290. NextStatement->ArgumentsAcquired = 0;
  2291. return STATUS_SUCCESS;
  2292. }
  2293. KSTATUS
  2294. AcpipCreateReturnStatement (
  2295. PAML_EXECUTION_CONTEXT Context,
  2296. PAML_STATEMENT NextStatement
  2297. )
  2298. /*++
  2299. Routine Description:
  2300. This routine creates a Return statement.
  2301. Arguments:
  2302. Context - Supplies a pointer to an initialized AML execution context. The
  2303. next statement will be created based on the current execution offset.
  2304. The current offset of the context will be incremented beyond the portion
  2305. of this statement that was successfully parsed.
  2306. NextStatement - Supplies a pointer where the next statement will be
  2307. returned. The caller is responsible for freeing this memory.
  2308. Return Value:
  2309. STATUS_SUCCESS always.
  2310. --*/
  2311. {
  2312. NextStatement->Type = AmlStatementReturn;
  2313. NextStatement->ArgumentsNeeded = 1;
  2314. NextStatement->ArgumentsAcquired = 0;
  2315. Context->CurrentOffset += 1;
  2316. return STATUS_SUCCESS;
  2317. }
  2318. KSTATUS
  2319. AcpipCreateRevisionStatement (
  2320. PAML_EXECUTION_CONTEXT Context,
  2321. PAML_STATEMENT NextStatement
  2322. )
  2323. /*++
  2324. Routine Description:
  2325. This routine creates a Revision statement.
  2326. Arguments:
  2327. Context - Supplies a pointer to an initialized AML execution context. The
  2328. next statement will be created based on the current execution offset.
  2329. The current offset of the context will be incremented beyond the portion
  2330. of this statement that was successfully parsed.
  2331. NextStatement - Supplies a pointer where the next statement will be
  2332. returned. The caller is responsible for freeing this memory.
  2333. Return Value:
  2334. STATUS_SUCCESS always.
  2335. --*/
  2336. {
  2337. NextStatement->Type = AmlStatementRevision;
  2338. NextStatement->ArgumentsNeeded = 0;
  2339. NextStatement->ArgumentsAcquired = 0;
  2340. Context->CurrentOffset += 1;
  2341. return STATUS_SUCCESS;
  2342. }
  2343. KSTATUS
  2344. AcpipCreateScopeStatement (
  2345. PAML_EXECUTION_CONTEXT Context,
  2346. PAML_STATEMENT NextStatement
  2347. )
  2348. /*++
  2349. Routine Description:
  2350. This routine creates a Scope statement.
  2351. Arguments:
  2352. Context - Supplies a pointer to an initialized AML execution context. The
  2353. next statement will be created based on the current execution offset.
  2354. The current offset of the context will be incremented beyond the portion
  2355. of this statement that was successfully parsed.
  2356. NextStatement - Supplies a pointer where the next statement will be
  2357. returned.
  2358. Return Value:
  2359. Status code.
  2360. --*/
  2361. {
  2362. NextStatement->Type = AmlStatementScope;
  2363. Context->CurrentOffset += 1;
  2364. NextStatement->ArgumentsNeeded = 1;
  2365. NextStatement->ArgumentsAcquired = 1;
  2366. //
  2367. // Parse the package length. Store the end offset in the additional data
  2368. // field.
  2369. //
  2370. NextStatement->AdditionalData = Context->CurrentOffset;
  2371. NextStatement->AdditionalData += AcpipParsePackageLength(Context);
  2372. if (NextStatement->AdditionalData == Context->CurrentOffset) {
  2373. return STATUS_UNSUCCESSFUL;
  2374. }
  2375. //
  2376. // Parse the name string, and store as argument 0.
  2377. //
  2378. NextStatement->Argument[0] = AcpipParseNameString(Context);
  2379. return STATUS_SUCCESS;
  2380. }
  2381. KSTATUS
  2382. AcpipCreateShiftLeftStatement (
  2383. PAML_EXECUTION_CONTEXT Context,
  2384. PAML_STATEMENT NextStatement
  2385. )
  2386. /*++
  2387. Routine Description:
  2388. This routine creates a statement for a Shift Left statement.
  2389. Arguments:
  2390. Context - Supplies a pointer to an initialized AML execution context. The
  2391. next statement will be created based on the current execution offset.
  2392. The current offset of the context will be incremented beyond the portion
  2393. of this statement that was successfully parsed.
  2394. NextStatement - Supplies a pointer where the next statement will be
  2395. returned.
  2396. Return Value:
  2397. STATUS_SUCCESS always.
  2398. --*/
  2399. {
  2400. KSTATUS Status;
  2401. NextStatement->Type = AmlStatementShiftLeft;
  2402. Context->CurrentOffset += 1;
  2403. NextStatement->ArgumentsNeeded = 3;
  2404. NextStatement->ArgumentsAcquired = 0;
  2405. Status = STATUS_SUCCESS;
  2406. return Status;
  2407. }
  2408. KSTATUS
  2409. AcpipCreateShiftRightStatement (
  2410. PAML_EXECUTION_CONTEXT Context,
  2411. PAML_STATEMENT NextStatement
  2412. )
  2413. /*++
  2414. Routine Description:
  2415. This routine creates a statement for a Shift Right statement.
  2416. Arguments:
  2417. Context - Supplies a pointer to an initialized AML execution context. The
  2418. next statement will be created based on the current execution offset.
  2419. The current offset of the context will be incremented beyond the portion
  2420. of this statement that was successfully parsed.
  2421. NextStatement - Supplies a pointer where the next statement will be
  2422. returned.
  2423. Return Value:
  2424. STATUS_SUCCESS always.
  2425. --*/
  2426. {
  2427. KSTATUS Status;
  2428. NextStatement->Type = AmlStatementShiftRight;
  2429. Context->CurrentOffset += 1;
  2430. NextStatement->ArgumentsNeeded = 3;
  2431. NextStatement->ArgumentsAcquired = 0;
  2432. Status = STATUS_SUCCESS;
  2433. return Status;
  2434. }
  2435. KSTATUS
  2436. AcpipCreateSignalStatement (
  2437. PAML_EXECUTION_CONTEXT Context,
  2438. PAML_STATEMENT NextStatement
  2439. )
  2440. /*++
  2441. Routine Description:
  2442. This routine creates a Signal (event) statement.
  2443. Arguments:
  2444. Context - Supplies a pointer to an initialized AML execution context. The
  2445. next statement will be created based on the current execution offset.
  2446. The current offset of the context will be incremented beyond the portion
  2447. of this statement that was successfully parsed.
  2448. NextStatement - Supplies a pointer where the next statement will be
  2449. returned.
  2450. Return Value:
  2451. STATUS_SUCCESS always.
  2452. --*/
  2453. {
  2454. NextStatement->Type = AmlStatementSignal;
  2455. Context->CurrentOffset += 1;
  2456. NextStatement->ArgumentsNeeded = 1;
  2457. NextStatement->ArgumentsAcquired = 0;
  2458. return STATUS_SUCCESS;
  2459. }
  2460. KSTATUS
  2461. AcpipCreateSizeOfStatement (
  2462. PAML_EXECUTION_CONTEXT Context,
  2463. PAML_STATEMENT NextStatement
  2464. )
  2465. /*++
  2466. Routine Description:
  2467. This routine creates a "SizeOf" statement.
  2468. Arguments:
  2469. Context - Supplies a pointer to an initialized AML execution context. The
  2470. next statement will be created based on the current execution offset.
  2471. The current offset of the context will be incremented beyond the portion
  2472. of this statement that was successfully parsed.
  2473. NextStatement - Supplies a pointer where the next statement will be
  2474. returned.
  2475. Return Value:
  2476. STATUS_SUCCESS on success.
  2477. Other error codes on failure.
  2478. --*/
  2479. {
  2480. KSTATUS Status;
  2481. NextStatement->Type = AmlStatementSizeOf;
  2482. Context->CurrentOffset += 1;
  2483. NextStatement->ArgumentsNeeded = 1;
  2484. NextStatement->ArgumentsAcquired = 0;
  2485. Status = STATUS_SUCCESS;
  2486. return Status;
  2487. }
  2488. KSTATUS
  2489. AcpipCreateSleepStatement (
  2490. PAML_EXECUTION_CONTEXT Context,
  2491. PAML_STATEMENT NextStatement
  2492. )
  2493. /*++
  2494. Routine Description:
  2495. This routine creates a Sleep statement.
  2496. Arguments:
  2497. Context - Supplies a pointer to an initialized AML execution context. The
  2498. next statement will be created based on the current execution offset.
  2499. The current offset of the context will be incremented beyond the portion
  2500. of this statement that was successfully parsed.
  2501. NextStatement - Supplies a pointer where the next statement will be
  2502. returned. The caller is responsible for freeing this memory.
  2503. Return Value:
  2504. STATUS_SUCCESS always.
  2505. --*/
  2506. {
  2507. NextStatement->Type = AmlStatementSleep;
  2508. NextStatement->ArgumentsNeeded = 1;
  2509. NextStatement->ArgumentsAcquired = 0;
  2510. Context->CurrentOffset += 1;
  2511. return STATUS_SUCCESS;
  2512. }
  2513. KSTATUS
  2514. AcpipCreateStallStatement (
  2515. PAML_EXECUTION_CONTEXT Context,
  2516. PAML_STATEMENT NextStatement
  2517. )
  2518. /*++
  2519. Routine Description:
  2520. This routine creates a Stall statement.
  2521. Arguments:
  2522. Context - Supplies a pointer to an initialized AML execution context. The
  2523. next statement will be created based on the current execution offset.
  2524. The current offset of the context will be incremented beyond the portion
  2525. of this statement that was successfully parsed.
  2526. NextStatement - Supplies a pointer where the next statement will be
  2527. returned. The caller is responsible for freeing this memory.
  2528. Return Value:
  2529. STATUS_SUCCESS always.
  2530. --*/
  2531. {
  2532. NextStatement->Type = AmlStatementStall;
  2533. NextStatement->ArgumentsNeeded = 1;
  2534. NextStatement->ArgumentsAcquired = 0;
  2535. Context->CurrentOffset += 1;
  2536. return STATUS_SUCCESS;
  2537. }
  2538. KSTATUS
  2539. AcpipCreateStoreStatement (
  2540. PAML_EXECUTION_CONTEXT Context,
  2541. PAML_STATEMENT NextStatement
  2542. )
  2543. /*++
  2544. Routine Description:
  2545. This routine creates a Store statement.
  2546. Arguments:
  2547. Context - Supplies a pointer to an initialized AML execution context. The
  2548. next statement will be created based on the current execution offset.
  2549. The current offset of the context will be incremented beyond the portion
  2550. of this statement that was successfully parsed.
  2551. NextStatement - Supplies a pointer where the next statement will be
  2552. returned.
  2553. Return Value:
  2554. STATUS_SUCCESS always.
  2555. --*/
  2556. {
  2557. KSTATUS Status;
  2558. NextStatement->Type = AmlStatementStore;
  2559. Context->CurrentOffset += 1;
  2560. NextStatement->ArgumentsNeeded = 2;
  2561. NextStatement->ArgumentsAcquired = 0;
  2562. Status = STATUS_SUCCESS;
  2563. return Status;
  2564. }
  2565. KSTATUS
  2566. AcpipCreateSubtractStatement (
  2567. PAML_EXECUTION_CONTEXT Context,
  2568. PAML_STATEMENT NextStatement
  2569. )
  2570. /*++
  2571. Routine Description:
  2572. This routine creates a Subtract statement.
  2573. Arguments:
  2574. Context - Supplies a pointer to an initialized AML execution context. The
  2575. next statement will be created based on the current execution offset.
  2576. The current offset of the context will be incremented beyond the portion
  2577. of this statement that was successfully parsed.
  2578. NextStatement - Supplies a pointer where the next statement will be
  2579. returned.
  2580. Return Value:
  2581. STATUS_SUCCESS always.
  2582. --*/
  2583. {
  2584. KSTATUS Status;
  2585. NextStatement->Type = AmlStatementSubtract;
  2586. Context->CurrentOffset += 1;
  2587. NextStatement->ArgumentsNeeded = 3;
  2588. NextStatement->ArgumentsAcquired = 0;
  2589. Status = STATUS_SUCCESS;
  2590. return Status;
  2591. }
  2592. KSTATUS
  2593. AcpipCreateThermalZoneStatement (
  2594. PAML_EXECUTION_CONTEXT Context,
  2595. PAML_STATEMENT NextStatement
  2596. )
  2597. /*++
  2598. Routine Description:
  2599. This routine creates a Thermal Zone statement.
  2600. Arguments:
  2601. Context - Supplies a pointer to an initialized AML execution context. The
  2602. next statement will be created based on the current execution offset.
  2603. The current offset of the context will be incremented beyond the portion
  2604. of this statement that was successfully parsed.
  2605. NextStatement - Supplies a pointer where the next statement will be
  2606. returned. The caller is responsible for freeing this memory.
  2607. Return Value:
  2608. Status code.
  2609. --*/
  2610. {
  2611. NextStatement->Type = AmlStatementThermalZone;
  2612. Context->CurrentOffset += 1;
  2613. NextStatement->ArgumentsNeeded = 1;
  2614. NextStatement->ArgumentsAcquired = 1;
  2615. //
  2616. // Get the package length.
  2617. //
  2618. NextStatement->AdditionalData = Context->CurrentOffset;
  2619. NextStatement->AdditionalData += AcpipParsePackageLength(Context);
  2620. if (NextStatement->AdditionalData == Context->CurrentOffset) {
  2621. return STATUS_UNSUCCESSFUL;
  2622. }
  2623. //
  2624. // Parse the name string to get the name of the thermal zone.
  2625. //
  2626. NextStatement->Argument[0] = AcpipParseNameString(Context);
  2627. if (NextStatement->Argument[0] == NULL) {
  2628. return STATUS_UNSUCCESSFUL;
  2629. }
  2630. NextStatement->Reduction = NULL;
  2631. return STATUS_SUCCESS;
  2632. }
  2633. KSTATUS
  2634. AcpipCreateTimerStatement (
  2635. PAML_EXECUTION_CONTEXT Context,
  2636. PAML_STATEMENT NextStatement
  2637. )
  2638. /*++
  2639. Routine Description:
  2640. This routine creates a statement for a Timer statement.
  2641. Arguments:
  2642. Context - Supplies a pointer to an initialized AML execution context. The
  2643. next statement will be created based on the current execution offset.
  2644. The current offset of the context will be incremented beyond the portion
  2645. of this statement that was successfully parsed.
  2646. NextStatement - Supplies a pointer where the next statement will be
  2647. returned.
  2648. Return Value:
  2649. STATUS_SUCCESS always.
  2650. --*/
  2651. {
  2652. NextStatement->Type = AmlStatementTimer;
  2653. Context->CurrentOffset += 1;
  2654. NextStatement->ArgumentsNeeded = 0;
  2655. NextStatement->ArgumentsAcquired = 0;
  2656. return STATUS_SUCCESS;
  2657. }
  2658. KSTATUS
  2659. AcpipCreateToBcdStatement (
  2660. PAML_EXECUTION_CONTEXT Context,
  2661. PAML_STATEMENT NextStatement
  2662. )
  2663. /*++
  2664. Routine Description:
  2665. This routine creates a "To BCD" statement.
  2666. Arguments:
  2667. Context - Supplies a pointer to an initialized AML execution context. The
  2668. next statement will be created based on the current execution offset.
  2669. The current offset of the context will be incremented beyond the portion
  2670. of this statement that was successfully parsed.
  2671. NextStatement - Supplies a pointer where the next statement will be
  2672. returned.
  2673. Return Value:
  2674. STATUS_SUCCESS always.
  2675. --*/
  2676. {
  2677. NextStatement->Type = AmlStatementToBcd;
  2678. Context->CurrentOffset += 1;
  2679. NextStatement->ArgumentsNeeded = 2;
  2680. NextStatement->ArgumentsAcquired = 0;
  2681. return STATUS_SUCCESS;
  2682. }
  2683. KSTATUS
  2684. AcpipCreateToBufferStatement (
  2685. PAML_EXECUTION_CONTEXT Context,
  2686. PAML_STATEMENT NextStatement
  2687. )
  2688. /*++
  2689. Routine Description:
  2690. This routine creates a "To Buffer" statement.
  2691. Arguments:
  2692. Context - Supplies a pointer to an initialized AML execution context. The
  2693. next statement will be created based on the current execution offset.
  2694. The current offset of the context will be incremented beyond the portion
  2695. of this statement that was successfully parsed.
  2696. NextStatement - Supplies a pointer where the next statement will be
  2697. returned.
  2698. Return Value:
  2699. STATUS_SUCCESS always.
  2700. --*/
  2701. {
  2702. NextStatement->Type = AmlStatementToBuffer;
  2703. Context->CurrentOffset += 1;
  2704. NextStatement->ArgumentsNeeded = 2;
  2705. NextStatement->ArgumentsAcquired = 0;
  2706. return STATUS_SUCCESS;
  2707. }
  2708. KSTATUS
  2709. AcpipCreateToDecimalStringStatement (
  2710. PAML_EXECUTION_CONTEXT Context,
  2711. PAML_STATEMENT NextStatement
  2712. )
  2713. /*++
  2714. Routine Description:
  2715. This routine creates a "To Decimal String" statement.
  2716. Arguments:
  2717. Context - Supplies a pointer to an initialized AML execution context. The
  2718. next statement will be created based on the current execution offset.
  2719. The current offset of the context will be incremented beyond the portion
  2720. of this statement that was successfully parsed.
  2721. NextStatement - Supplies a pointer where the next statement will be
  2722. returned.
  2723. Return Value:
  2724. STATUS_SUCCESS always.
  2725. --*/
  2726. {
  2727. NextStatement->Type = AmlStatementToDecimalString;
  2728. Context->CurrentOffset += 1;
  2729. NextStatement->ArgumentsNeeded = 2;
  2730. NextStatement->ArgumentsAcquired = 0;
  2731. return STATUS_SUCCESS;
  2732. }
  2733. KSTATUS
  2734. AcpipCreateToHexStringStatement (
  2735. PAML_EXECUTION_CONTEXT Context,
  2736. PAML_STATEMENT NextStatement
  2737. )
  2738. /*++
  2739. Routine Description:
  2740. This routine creates a "To Hex String" statement.
  2741. Arguments:
  2742. Context - Supplies a pointer to an initialized AML execution context. The
  2743. next statement will be created based on the current execution offset.
  2744. The current offset of the context will be incremented beyond the portion
  2745. of this statement that was successfully parsed.
  2746. NextStatement - Supplies a pointer where the next statement will be
  2747. returned.
  2748. Return Value:
  2749. STATUS_SUCCESS always.
  2750. --*/
  2751. {
  2752. NextStatement->Type = AmlStatementToHexString;
  2753. Context->CurrentOffset += 1;
  2754. NextStatement->ArgumentsNeeded = 2;
  2755. NextStatement->ArgumentsAcquired = 0;
  2756. return STATUS_SUCCESS;
  2757. }
  2758. KSTATUS
  2759. AcpipCreateToIntegerStatement (
  2760. PAML_EXECUTION_CONTEXT Context,
  2761. PAML_STATEMENT NextStatement
  2762. )
  2763. /*++
  2764. Routine Description:
  2765. This routine creates a "To Integer" statement.
  2766. Arguments:
  2767. Context - Supplies a pointer to an initialized AML execution context. The
  2768. next statement will be created based on the current execution offset.
  2769. The current offset of the context will be incremented beyond the portion
  2770. of this statement that was successfully parsed.
  2771. NextStatement - Supplies a pointer where the next statement will be
  2772. returned.
  2773. Return Value:
  2774. STATUS_SUCCESS always.
  2775. --*/
  2776. {
  2777. NextStatement->Type = AmlStatementToInteger;
  2778. Context->CurrentOffset += 1;
  2779. NextStatement->ArgumentsNeeded = 2;
  2780. NextStatement->ArgumentsAcquired = 0;
  2781. return STATUS_SUCCESS;
  2782. }
  2783. KSTATUS
  2784. AcpipCreateToStringStatement (
  2785. PAML_EXECUTION_CONTEXT Context,
  2786. PAML_STATEMENT NextStatement
  2787. )
  2788. /*++
  2789. Routine Description:
  2790. This routine creates a "To String" statement.
  2791. Arguments:
  2792. Context - Supplies a pointer to an initialized AML execution context. The
  2793. next statement will be created based on the current execution offset.
  2794. The current offset of the context will be incremented beyond the portion
  2795. of this statement that was successfully parsed.
  2796. NextStatement - Supplies a pointer where the next statement will be
  2797. returned.
  2798. Return Value:
  2799. STATUS_SUCCESS always.
  2800. --*/
  2801. {
  2802. NextStatement->Type = AmlStatementToString;
  2803. Context->CurrentOffset += 1;
  2804. NextStatement->ArgumentsNeeded = 2;
  2805. NextStatement->ArgumentsAcquired = 0;
  2806. return STATUS_SUCCESS;
  2807. }
  2808. KSTATUS
  2809. AcpipCreateUnloadStatement (
  2810. PAML_EXECUTION_CONTEXT Context,
  2811. PAML_STATEMENT NextStatement
  2812. )
  2813. /*++
  2814. Routine Description:
  2815. This routine creates an Unload (definition block) statement.
  2816. Arguments:
  2817. Context - Supplies a pointer to an initialized AML execution context. The
  2818. next statement will be created based on the current execution offset.
  2819. The current offset of the context will be incremented beyond the portion
  2820. of this statement that was successfully parsed.
  2821. NextStatement - Supplies a pointer where the next statement will be
  2822. returned. The caller is responsible for freeing this memory.
  2823. Return Value:
  2824. STATUS_SUCCESS always.
  2825. --*/
  2826. {
  2827. NextStatement->Type = AmlStatementUnload;
  2828. Context->CurrentOffset += 1;
  2829. NextStatement->ArgumentsNeeded = 1;
  2830. NextStatement->ArgumentsAcquired = 0;
  2831. return STATUS_SUCCESS;
  2832. }
  2833. KSTATUS
  2834. AcpipCreateVariablePackageStatement (
  2835. PAML_EXECUTION_CONTEXT Context,
  2836. PAML_STATEMENT NextStatement
  2837. )
  2838. /*++
  2839. Routine Description:
  2840. This routine creates a Variable package statement, whose size is determined
  2841. by a TermArg rather than a constant.
  2842. Arguments:
  2843. Context - Supplies a pointer to an initialized AML execution context. The
  2844. next statement will be created based on the current execution offset.
  2845. The current offset of the context will be incremented beyond the portion
  2846. of this statement that was successfully parsed.
  2847. NextStatement - Supplies a pointer where the next statement will be
  2848. returned. The caller is responsible for freeing this memory.
  2849. Return Value:
  2850. Status code.
  2851. --*/
  2852. {
  2853. NextStatement->Type = AmlStatementVariablePackage;
  2854. Context->CurrentOffset += 1;
  2855. NextStatement->ArgumentsNeeded = 1;
  2856. NextStatement->ArgumentsAcquired = 0;
  2857. //
  2858. // Get the package length.
  2859. //
  2860. NextStatement->AdditionalData = Context->CurrentOffset;
  2861. NextStatement->AdditionalData += AcpipParsePackageLength(Context);
  2862. if (NextStatement->AdditionalData == Context->CurrentOffset) {
  2863. return STATUS_UNSUCCESSFUL;
  2864. }
  2865. NextStatement->Reduction = NULL;
  2866. return STATUS_SUCCESS;
  2867. }
  2868. KSTATUS
  2869. AcpipCreateWaitStatement (
  2870. PAML_EXECUTION_CONTEXT Context,
  2871. PAML_STATEMENT NextStatement
  2872. )
  2873. /*++
  2874. Routine Description:
  2875. This routine creates an Wait (for Event) statement.
  2876. Arguments:
  2877. Context - Supplies a pointer to an initialized AML execution context. The
  2878. next statement will be created based on the current execution offset.
  2879. The current offset of the context will be incremented beyond the portion
  2880. of this statement that was successfully parsed.
  2881. NextStatement - Supplies a pointer where the next statement will be
  2882. returned.
  2883. Return Value:
  2884. STATUS_SUCCESS always.
  2885. --*/
  2886. {
  2887. NextStatement->Type = AmlStatementWait;
  2888. Context->CurrentOffset += 1;
  2889. NextStatement->ArgumentsNeeded = 2;
  2890. NextStatement->ArgumentsAcquired = 0;
  2891. return STATUS_SUCCESS;
  2892. }
  2893. KSTATUS
  2894. AcpipCreateWhileStatement (
  2895. PAML_EXECUTION_CONTEXT Context,
  2896. PAML_STATEMENT NextStatement
  2897. )
  2898. /*++
  2899. Routine Description:
  2900. This routine creates a While statement.
  2901. Arguments:
  2902. Context - Supplies a pointer to an initialized AML execution context. The
  2903. next statement will be created based on the current execution offset.
  2904. The current offset of the context will be incremented beyond the portion
  2905. of this statement that was successfully parsed.
  2906. NextStatement - Supplies a pointer where the next statement will be
  2907. returned.
  2908. Return Value:
  2909. Status code.
  2910. --*/
  2911. {
  2912. NextStatement->Type = AmlStatementWhile;
  2913. Context->CurrentOffset += 1;
  2914. //
  2915. // Grab the package length, use it to calculate the end offset, and store
  2916. // that in additional data.
  2917. //
  2918. NextStatement->AdditionalData = Context->CurrentOffset;
  2919. NextStatement->AdditionalData += AcpipParsePackageLength(Context);
  2920. if (NextStatement->AdditionalData == Context->CurrentOffset) {
  2921. return STATUS_UNSUCCESSFUL;
  2922. }
  2923. //
  2924. // Store the predicate offset in additional data 2, so it can be
  2925. // re-evaluated on subsequent iterations through the while loop.
  2926. //
  2927. NextStatement->AdditionalData2 = Context->CurrentOffset;
  2928. NextStatement->ArgumentsNeeded = 1;
  2929. NextStatement->ArgumentsAcquired = 0;
  2930. return STATUS_SUCCESS;
  2931. }
  2932. KSTATUS
  2933. AcpipCreateXorStatement (
  2934. PAML_EXECUTION_CONTEXT Context,
  2935. PAML_STATEMENT NextStatement
  2936. )
  2937. /*++
  2938. Routine Description:
  2939. This routine creates a statement for an Exclusive Or statement.
  2940. Arguments:
  2941. Context - Supplies a pointer to an initialized AML execution context. The
  2942. next statement will be created based on the current execution offset.
  2943. The current offset of the context will be incremented beyond the portion
  2944. of this statement that was successfully parsed.
  2945. NextStatement - Supplies a pointer where the next statement will be
  2946. returned.
  2947. Return Value:
  2948. STATUS_SUCCESS always.
  2949. --*/
  2950. {
  2951. KSTATUS Status;
  2952. NextStatement->Type = AmlStatementXor;
  2953. Context->CurrentOffset += 1;
  2954. NextStatement->ArgumentsNeeded = 3;
  2955. NextStatement->ArgumentsAcquired = 0;
  2956. Status = STATUS_SUCCESS;
  2957. return Status;
  2958. }
  2959. KSTATUS
  2960. AcpipCreateZeroStatement (
  2961. PAML_EXECUTION_CONTEXT Context,
  2962. PAML_STATEMENT NextStatement
  2963. )
  2964. /*++
  2965. Routine Description:
  2966. This routine creates a statement for opcode 0, a constant 0.
  2967. Arguments:
  2968. Context - Supplies a pointer to an initialized AML execution context. The
  2969. next statement will be created based on the current execution offset.
  2970. The current offset of the context will be incremented beyond the portion
  2971. of this statement that was successfully parsed.
  2972. NextStatement - Supplies a pointer where the next statement will be
  2973. returned. The caller is responsible for freeing this memory.
  2974. Return Value:
  2975. STATUS_SUCCESS always.
  2976. --*/
  2977. {
  2978. NextStatement->Type = AmlStatementZero;
  2979. Context->CurrentOffset += 1;
  2980. return STATUS_SUCCESS;
  2981. }
  2982. PACPI_OBJECT
  2983. AcpipParseNameString (
  2984. PAML_EXECUTION_CONTEXT Context
  2985. )
  2986. /*++
  2987. Routine Description:
  2988. This routine parses a namespace string from the AML stream.
  2989. Arguments:
  2990. Context - Supplies a pointer to the AML execution context. The name string
  2991. will be evaluated from the current offset.
  2992. Return Value:
  2993. Returns a pointer to a string object (unconnected to any namespace) on
  2994. success.
  2995. NULL on failure. The AML stream current offset will be unchanged on failure.
  2996. --*/
  2997. {
  2998. PUCHAR AmlBuffer;
  2999. ULONG AmlStringSize;
  3000. UCHAR Character;
  3001. ULONG DestinationOffset;
  3002. ULONG NameCount;
  3003. BOOL RootCharacterFound;
  3004. ULONG SourceOffset;
  3005. KSTATUS Status;
  3006. ULONG StringBufferSize;
  3007. PACPI_OBJECT StringObject;
  3008. RootCharacterFound = FALSE;
  3009. StringObject = NULL;
  3010. AmlStringSize = 0;
  3011. StringBufferSize = 0;
  3012. AmlBuffer = (PUCHAR)Context->AmlCode + Context->CurrentOffset;
  3013. //
  3014. // Determine the length of the string in the AML stream and validate the
  3015. // string at the same time.
  3016. //
  3017. while (Context->CurrentOffset + AmlStringSize < Context->AmlCodeSize) {
  3018. Character = *(AmlBuffer + AmlStringSize);
  3019. //
  3020. // A root character can only come at the beginning and only once.
  3021. //
  3022. if (Character == ACPI_NAMESPACE_ROOT_CHARACTER) {
  3023. AmlStringSize += 1;
  3024. if (AmlStringSize == 1) {
  3025. RootCharacterFound = TRUE;
  3026. StringBufferSize += 1;
  3027. continue;
  3028. } else {
  3029. Status = STATUS_MALFORMED_DATA_STREAM;
  3030. goto ParseNameStringEnd;
  3031. }
  3032. }
  3033. //
  3034. // Handle a "current parent" string.
  3035. //
  3036. if (Character == ACPI_NAMESPACE_PARENT_CHARACTER) {
  3037. AmlStringSize += 1;
  3038. if (RootCharacterFound != FALSE) {
  3039. Status = STATUS_MALFORMED_DATA_STREAM;
  3040. goto ParseNameStringEnd;
  3041. }
  3042. StringBufferSize += 1;
  3043. continue;
  3044. }
  3045. //
  3046. // Handle a NULL string.
  3047. //
  3048. if (Character == ACPI_NULL_NAME_CHARACTER) {
  3049. AmlStringSize += 1;
  3050. break;
  3051. }
  3052. //
  3053. // Handle a dual-name string.
  3054. //
  3055. if (Character == ACPI_DUAL_NAME_PREFIX_CHARACTER) {
  3056. AmlStringSize += (ACPI_MAX_NAME_LENGTH * 2) + 1;
  3057. StringBufferSize += ACPI_MAX_NAME_LENGTH * 2;
  3058. break;
  3059. }
  3060. //
  3061. // Handle a multi-name string.
  3062. //
  3063. if (Character == ACPI_MULTI_NAME_PREFIX_CHARACTER) {
  3064. AmlStringSize += 1;
  3065. if (Context->CurrentOffset + AmlStringSize > Context->AmlCodeSize) {
  3066. Status = STATUS_MALFORMED_DATA_STREAM;
  3067. goto ParseNameStringEnd;
  3068. }
  3069. NameCount = *(AmlBuffer + AmlStringSize);
  3070. AmlStringSize += (ACPI_MAX_NAME_LENGTH * NameCount) + 1;
  3071. StringBufferSize += ACPI_MAX_NAME_LENGTH * NameCount;
  3072. break;
  3073. }
  3074. //
  3075. // It must just be a normal character, so the name is being specified.
  3076. //
  3077. if (AcpipIsValidFirstNameCharacter(Character) == FALSE) {
  3078. Status = STATUS_MALFORMED_DATA_STREAM;
  3079. goto ParseNameStringEnd;
  3080. }
  3081. AmlStringSize += ACPI_MAX_NAME_LENGTH;
  3082. StringBufferSize += ACPI_MAX_NAME_LENGTH;
  3083. break;
  3084. }
  3085. //
  3086. // Double check to make sure the string didn't overflow the AML.
  3087. //
  3088. if (Context->CurrentOffset + AmlStringSize > Context->AmlCodeSize) {
  3089. Status = STATUS_MALFORMED_DATA_STREAM;
  3090. goto ParseNameStringEnd;
  3091. }
  3092. //
  3093. // Create the namespace string.
  3094. //
  3095. StringObject = AcpipCreateNamespaceObject(Context,
  3096. AcpiObjectString,
  3097. NULL,
  3098. NULL,
  3099. StringBufferSize + 1);
  3100. if (StringObject == NULL) {
  3101. Status = STATUS_UNSUCCESSFUL;
  3102. goto ParseNameStringEnd;
  3103. }
  3104. //
  3105. // Copy the string in, plucking out the control characters.
  3106. //
  3107. SourceOffset = 0;
  3108. DestinationOffset = 0;
  3109. while (SourceOffset < AmlStringSize) {
  3110. Character = *(AmlBuffer + SourceOffset);
  3111. SourceOffset += 1;
  3112. if (Character == ACPI_DUAL_NAME_PREFIX_CHARACTER) {
  3113. continue;
  3114. }
  3115. if (Character == ACPI_MULTI_NAME_PREFIX_CHARACTER) {
  3116. //
  3117. // Skip past the name count byte too.
  3118. //
  3119. SourceOffset += 1;
  3120. continue;
  3121. }
  3122. if (Character == ACPI_NULL_NAME_CHARACTER) {
  3123. break;
  3124. }
  3125. *(StringObject->U.String.String + DestinationOffset) = Character;
  3126. DestinationOffset += 1;
  3127. }
  3128. //
  3129. // Add a null terminator.
  3130. //
  3131. ASSERT(DestinationOffset < StringBufferSize + 1);
  3132. *(StringObject->U.String.String + DestinationOffset) = '\0';
  3133. Status = STATUS_SUCCESS;
  3134. ParseNameStringEnd:
  3135. if (!KSUCCESS(Status)) {
  3136. if (StringObject != NULL) {
  3137. AcpipObjectReleaseReference(StringObject);
  3138. StringObject = NULL;
  3139. }
  3140. AmlStringSize = 0;
  3141. }
  3142. Context->CurrentOffset += AmlStringSize;
  3143. return StringObject;
  3144. }
  3145. KSTATUS
  3146. AcpipParseFieldList (
  3147. PAML_EXECUTION_CONTEXT Context,
  3148. AML_STATEMENT_TYPE Type,
  3149. PACPI_OBJECT OperationRegion,
  3150. PACPI_OBJECT BankRegister,
  3151. PACPI_OBJECT BankValue,
  3152. PACPI_OBJECT IndexRegister,
  3153. PACPI_OBJECT DataRegister,
  3154. ULONG EndOffset,
  3155. UCHAR InitialAccessFlags
  3156. )
  3157. /*++
  3158. Routine Description:
  3159. This routine parses a field list, used in Operation Region field list
  3160. declarations.
  3161. Arguments:
  3162. Context - Supplies a pointer to the AML execution context.
  3163. Type - Supplies the type of field to create. Valid values are
  3164. AmlStatementField, AmlStatementBankField, and AmlStatementIndexField.
  3165. OperationRegion - Supplies a pointer to the operation region these fields
  3166. belong to. NULL is only valid if the execution context is not
  3167. executing statements.
  3168. BankRegister - Supplies an optional pointer to the bank register to write
  3169. to before accessing these fields. It is expected that the Bank registers
  3170. will be non-null or the Index/Data registers, but not both.
  3171. BankValue - Supplies a pointer to the value to write to the bank register.
  3172. If the bank register is not supplied, this parameter is ignored. If the
  3173. bank register is supplied, this parameter is required.
  3174. IndexRegister - Supplies an optional pointer to the index register to write
  3175. to before accessing the corresponding data register. It is expected
  3176. that the Index/Data registers are non-null or the Bank registers, but
  3177. not both.
  3178. DataRegister - Supplies a pointer to the data register to use in
  3179. Index/Data mode. If the Index register is not supplied, this parameter
  3180. is ignored. If the index register is supplied, this parameter is
  3181. required.
  3182. EndOffset - Supplies the ending offset (exclusive) of the field list in the
  3183. AML code stream.
  3184. InitialAccessFlags - Supplies the initial attributes of the field
  3185. (until the first AccessAs modifier is parsed).
  3186. Return Value:
  3187. Status code.
  3188. --*/
  3189. {
  3190. UCHAR AccessAttributes;
  3191. UCHAR AccessFlags;
  3192. ACPI_FIELD_UNIT_OBJECT FieldUnit;
  3193. PSTR FieldUnitName;
  3194. PUCHAR InstructionPointer;
  3195. CHAR Name[ACPI_MAX_NAME_LENGTH + 1];
  3196. PACPI_OBJECT NewFieldUnit;
  3197. //
  3198. // If the bank register is filled in, the bank value had better be too.
  3199. //
  3200. ASSERT((BankRegister == NULL) || (BankValue != NULL));
  3201. //
  3202. // If the index register is filled in, the data register had better be too.
  3203. //
  3204. ASSERT((IndexRegister == NULL) || (DataRegister != NULL));
  3205. //
  3206. // Assert that they're not both filled in.
  3207. //
  3208. ASSERT(!((BankRegister != NULL) && (IndexRegister != NULL)));
  3209. FieldUnit.OperationRegion = OperationRegion;
  3210. FieldUnit.BankRegister = BankRegister;
  3211. FieldUnit.BankValue = BankValue;
  3212. FieldUnit.IndexRegister = IndexRegister;
  3213. FieldUnit.DataRegister = DataRegister;
  3214. FieldUnitName = "FieldUnit";
  3215. if (Type == AmlStatementBankField) {
  3216. FieldUnitName = "BankField";
  3217. } else if (Type == AmlStatementIndexField) {
  3218. FieldUnitName = "IndexField";
  3219. } else {
  3220. ASSERT(Type == AmlStatementField);
  3221. }
  3222. //
  3223. // Parse the initial attributes bitfields.
  3224. //
  3225. FieldUnit.Access = InitialAccessFlags & FIELD_LIST_FLAG_ACCESS_MASK;
  3226. FieldUnit.AcquireGlobalLock = FALSE;
  3227. if ((InitialAccessFlags & FIELD_LIST_FLAG_LOCK_MASK) != 0) {
  3228. FieldUnit.AcquireGlobalLock = TRUE;
  3229. }
  3230. FieldUnit.UpdateRule = (InitialAccessFlags &
  3231. FIELD_LIST_FLAG_UPDATE_RULE_MASK) >>
  3232. FIELD_LIST_FLAG_UPDATE_RULE_SHIFT;
  3233. ASSERT(FieldUnit.UpdateRule < AcpiFieldUpdateRuleCount);
  3234. //
  3235. // Null terminate the field name.
  3236. //
  3237. Name[ACPI_MAX_NAME_LENGTH] = '\0';
  3238. //
  3239. // Loop parsing fields until the end.
  3240. //
  3241. FieldUnit.BitOffset = 0;
  3242. InstructionPointer = (PUCHAR)Context->AmlCode + Context->CurrentOffset;
  3243. while (Context->CurrentOffset < EndOffset) {
  3244. //
  3245. // A field unit list contains one of the following:
  3246. // * NameSeg PkgLength - Defines a new field of PkgLength bits.
  3247. // * 0x00 PkgLength - Defines an unnamed (reserved) field.
  3248. // * 0x01 AccessType AccessAttrib - Define the new access type and
  3249. // attributes. Both of these are bytes. Start by checking for the
  3250. // special byte 0.
  3251. //
  3252. if (*InstructionPointer == FIELD_LIST_RESERVED_FIELD) {
  3253. InstructionPointer += 1;
  3254. Context->CurrentOffset += 1;
  3255. FieldUnit.BitLength = AcpipParsePackageLength(Context);
  3256. if (Context->PrintStatements != FALSE) {
  3257. RtlDebugPrint("Skip 0x%I64x", FieldUnit.BitLength);
  3258. }
  3259. FieldUnit.BitOffset += FieldUnit.BitLength;
  3260. //
  3261. // Check for the special change of attributes byte.
  3262. //
  3263. } else if (*InstructionPointer == FIELD_CHANGE_ATTRIBUTES) {
  3264. InstructionPointer += 1;
  3265. Context->CurrentOffset += 1;
  3266. AccessFlags = *InstructionPointer;
  3267. FieldUnit.Access = AccessFlags & FIELD_LIST_FLAG_ACCESS_MASK;
  3268. FieldUnit.AcquireGlobalLock = FALSE;
  3269. if ((AccessFlags & FIELD_LIST_FLAG_LOCK_MASK) != 0) {
  3270. FieldUnit.AcquireGlobalLock = TRUE;
  3271. }
  3272. FieldUnit.UpdateRule = (AccessFlags &
  3273. FIELD_LIST_FLAG_UPDATE_RULE_MASK) >>
  3274. FIELD_LIST_FLAG_UPDATE_RULE_SHIFT;
  3275. ASSERT(FieldUnit.UpdateRule < AcpiFieldUpdateRuleCount);
  3276. InstructionPointer += 1;
  3277. Context->CurrentOffset += 1;
  3278. //
  3279. // TODO: Parse SMBus Access attributes when SMBus access support
  3280. // is implemented.
  3281. //
  3282. AccessAttributes = *InstructionPointer;
  3283. InstructionPointer += 1;
  3284. Context->CurrentOffset += 1;
  3285. if (Context->PrintStatements != FALSE) {
  3286. RtlDebugPrint("AccessAs (0x%02x, 0x%02x)",
  3287. AccessFlags,
  3288. AccessAttributes);
  3289. }
  3290. //
  3291. // Parse a normal field name and bit length.
  3292. //
  3293. } else {
  3294. //
  3295. // Create the name string.
  3296. //
  3297. RtlCopyMemory(Name, InstructionPointer, ACPI_MAX_NAME_LENGTH);
  3298. InstructionPointer += ACPI_MAX_NAME_LENGTH;
  3299. Context->CurrentOffset += ACPI_MAX_NAME_LENGTH;
  3300. //
  3301. // Parse the bit length of this field.
  3302. //
  3303. FieldUnit.BitLength = AcpipParsePackageLength(Context);
  3304. if (FieldUnit.BitLength == 0) {
  3305. return STATUS_MALFORMED_DATA_STREAM;
  3306. }
  3307. if (Context->PrintStatements != FALSE) {
  3308. RtlDebugPrint("%s (%s, 0x%I64x, 0x%I64x)",
  3309. FieldUnitName,
  3310. Name,
  3311. FieldUnit.BitOffset,
  3312. FieldUnit.BitLength);
  3313. }
  3314. if (Context->ExecuteStatements != FALSE) {
  3315. NewFieldUnit = AcpipCreateNamespaceObject(
  3316. Context,
  3317. AcpiObjectFieldUnit,
  3318. Name,
  3319. &FieldUnit,
  3320. sizeof(ACPI_FIELD_UNIT_OBJECT));
  3321. if (NewFieldUnit == NULL) {
  3322. return STATUS_UNSUCCESSFUL;
  3323. }
  3324. AcpipObjectReleaseReference(NewFieldUnit);
  3325. }
  3326. //
  3327. // Advance the bit offset past these bits.
  3328. //
  3329. FieldUnit.BitOffset += FieldUnit.BitLength;
  3330. }
  3331. //
  3332. // Update the instruction pointer.
  3333. //
  3334. InstructionPointer = (PUCHAR)Context->AmlCode + Context->CurrentOffset;
  3335. AcpipPrintIndentedNewLine(Context);
  3336. }
  3337. ASSERT(Context->CurrentOffset == EndOffset);
  3338. return STATUS_SUCCESS;
  3339. }
  3340. ULONGLONG
  3341. AcpipParsePackageLength (
  3342. PAML_EXECUTION_CONTEXT Context
  3343. )
  3344. /*++
  3345. Routine Description:
  3346. This routine parses a package length from the AML stream.
  3347. Arguments:
  3348. Context - Supplies a pointer to the AML execution context. The name string
  3349. will be evaluated from the current offset.
  3350. Return Value:
  3351. Returns the size of the package that follows.
  3352. 0 on failure.
  3353. --*/
  3354. {
  3355. UCHAR ByteIndex;
  3356. UCHAR DataByte;
  3357. PUCHAR InstructionPointer;
  3358. ULONG LengthSize;
  3359. ULONG PackageLength;
  3360. if (Context->CurrentOffset >= Context->AmlCodeSize) {
  3361. ASSERT(FALSE);
  3362. return 0;
  3363. }
  3364. InstructionPointer = (PUCHAR)Context->AmlCode + Context->CurrentOffset;
  3365. DataByte = *InstructionPointer;
  3366. LengthSize = (DataByte >> PACKAGE_LENGTH_FOLLOW_BYTE_SHIFT) &
  3367. PACKAGE_LENGTH_FOLLOW_BYTE_MASK;
  3368. if (Context->CurrentOffset + LengthSize >= Context->AmlCodeSize) {
  3369. ASSERT(FALSE);
  3370. return 0;
  3371. }
  3372. Context->CurrentOffset += LengthSize + 1;
  3373. //
  3374. // If there are no additional bytes, then the value must be somewhere
  3375. // between 0 and 63. Simply return that byte as the length.
  3376. //
  3377. if (LengthSize == 0) {
  3378. return DataByte;
  3379. }
  3380. //
  3381. // Add the follow bytes. The farthest out bytes are the highest value bits.
  3382. //
  3383. PackageLength = 0;
  3384. for (ByteIndex = 0; ByteIndex < LengthSize; ByteIndex += 1) {
  3385. PackageLength = (PackageLength << 8) |
  3386. InstructionPointer[LengthSize - ByteIndex];
  3387. }
  3388. //
  3389. // Add in the first bit. Only bits 0-3 count.
  3390. //
  3391. PackageLength = (PackageLength << 4) | (DataByte & 0x0F);
  3392. return PackageLength;
  3393. }
  3394. //
  3395. // --------------------------------------------------------- Internal Functions
  3396. //
  3397. BOOL
  3398. AcpipIsValidFirstNameCharacter (
  3399. UCHAR Character
  3400. )
  3401. /*++
  3402. Routine Description:
  3403. This routine checks to see if the given character is suitable for use as
  3404. the first character of an ACPI name. Valid ACPI name leading characters are
  3405. A - Z and _.
  3406. Arguments:
  3407. Character - Supplies the character to evaluate.
  3408. Return Value:
  3409. TRUE if the character is a valid first character of an ACPI name.
  3410. FALSE if the character is not valid.
  3411. --*/
  3412. {
  3413. if ((Character >= 'A') && (Character <= 'Z')) {
  3414. return TRUE;
  3415. }
  3416. if (Character == '_') {
  3417. return TRUE;
  3418. }
  3419. return FALSE;
  3420. }