1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503 |
- /*++
- Copyright (c) 2012 Minoca Corp. All Rights Reserved
- Module Name:
- reslist.c
- Abstract:
- This module implements resource list debugger extensions.
- Author:
- Evan Green 12-Dec-2012
- Environment:
- Debug Client
- --*/
- //
- // ------------------------------------------------------------------- Includes
- //
- #include <minoca/kernel/kernel.h>
- #include <minoca/debug/dbgext.h>
- #include "../../kernel/io/arb.h"
- #include <assert.h>
- #include <errno.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- //
- // ---------------------------------------------------------------- Definitions
- //
- #define MALLOC(_x) malloc(_x)
- #define FREE(_x) free(_x)
- //
- // ------------------------------------------------------ Data Type Definitions
- //
- //
- // ----------------------------------------------- Internal Function Prototypes
- //
- BOOL
- ExtpPrintDeviceResources (
- PDEBUGGER_CONTEXT Context,
- ULONGLONG Address,
- ULONG IndentationLevel
- );
- BOOL
- ExtpPrintResourceConfigurationList (
- PDEBUGGER_CONTEXT Context,
- ULONGLONG Address,
- ULONG IndentationLevel
- );
- BOOL
- ExtpPrintResourceRequirementList (
- PDEBUGGER_CONTEXT Context,
- ULONGLONG Address,
- ULONG IndentationLevel
- );
- BOOL
- ExtpPrintResourceRequirement (
- PDEBUGGER_CONTEXT Context,
- ULONGLONG Address,
- ULONG IndentationLevel
- );
- BOOL
- ExtpPrintResourceAllocationList (
- PDEBUGGER_CONTEXT Context,
- ULONGLONG Address,
- ULONG IndentationLevel
- );
- BOOL
- ExtpPrintResourceAllocation (
- PDEBUGGER_CONTEXT Context,
- ULONGLONG Address,
- ULONG IndentationLevel
- );
- BOOL
- ExtpPrintDeviceArbiters (
- PDEBUGGER_CONTEXT Context,
- ULONGLONG Address,
- ULONG IndentationLevel
- );
- BOOL
- ExtpPrintResourceArbiter (
- PDEBUGGER_CONTEXT Context,
- ULONGLONG Address,
- ULONG IndentationLevel
- );
- BOOL
- ExtpPrintArbiterEntry (
- PDEBUGGER_CONTEXT Context,
- ULONGLONG Address,
- ULONG IndentationLevel
- );
- PSTR
- ExtpGetResourceTypeString (
- RESOURCE_TYPE Type
- );
- //
- // -------------------------------------------------------------------- Globals
- //
- //
- // ------------------------------------------------------------------ Functions
- //
- INT
- ExtResource (
- PDEBUGGER_CONTEXT Context,
- PSTR Command,
- ULONG ArgumentCount,
- PSTR *ArgumentValues
- )
- /*++
- Routine Description:
- This routine implements the resource related debugger extension.
- Arguments:
- Context - Supplies a pointer to the debugger applicaton context, which is
- an argument to most of the API functions.
- Command - Supplies a pointer to the subcommand string.
- ArgumentCount - Supplies the number of arguments in the ArgumentValues
- array.
- ArgumentValues - Supplies the values of each argument. This memory will be
- reused when the function returns, so extensions must not touch this
- memory after returning from this call.
- Return Value:
- 0 if the debugger extension command was successful.
- Returns an error code if a failure occurred along the way.
- --*/
- {
- ULONGLONG Address;
- ULONG ArgumentIndex;
- INT Result;
- Address = 0;
- if (Command == NULL) {
- DbgOut("Error: Supply a subcommand. Valid subcommands are:\n"
- " !res.dev\n !res.req\n !res.reqlist\n "
- "!res.conflist\n !res.alloc\n !res.alloclist\n "
- "!res.arb\n !res.devarbs\n !res.arbentry\n");
- return EINVAL;
- }
- //
- // At least one parameter is required.
- //
- if (ArgumentCount < 2) {
- DbgOut("Error: Supply an address to dump.\n");
- } else {
- //
- // Loop through each argument, evaluate the address, and print the
- // namespace tree at that object.
- //
- for (ArgumentIndex = 1;
- ArgumentIndex < ArgumentCount;
- ArgumentIndex += 1) {
- Result = DbgEvaluate(Context,
- ArgumentValues[ArgumentIndex],
- &Address);
- if (Result != 0) {
- DbgOut("Failed to evaluate address at \"%s\".\n",
- ArgumentValues[ArgumentIndex]);
- return Result;
- }
- if (strcmp(Command, "dev") == 0) {
- ExtpPrintDeviceResources(Context, Address, 0);
- } else if (strcmp(Command, "req") == 0) {
- ExtpPrintResourceRequirement(Context, Address, 0);
- } else if (strcmp(Command, "reqlist") == 0) {
- ExtpPrintResourceRequirementList(Context, Address, 0);
- } else if (strcmp(Command, "conflist") == 0) {
- ExtpPrintResourceConfigurationList(Context, Address, 0);
- } else if (strcmp(Command, "alloc") == 0) {
- ExtpPrintResourceAllocation(Context, Address, 0);
- } else if (strcmp(Command, "alloclist") == 0) {
- ExtpPrintResourceAllocationList(Context, Address, 0);
- } else if (strcmp(Command, "arbentry") == 0) {
- ExtpPrintArbiterEntry(Context, Address, 0);
- } else if (strcmp(Command, "arb") == 0) {
- ExtpPrintResourceArbiter(Context, Address, 0);
- } else if (strcmp(Command, "devarbs") == 0) {
- ExtpPrintDeviceArbiters(Context, Address, 0);
- } else {
- DbgOut("Error: Invalid subcommand. Run !res for detailed"
- "usage.\n");
- }
- if (ArgumentIndex != ArgumentCount - 1) {
- DbgOut("\n----\n");
- }
- }
- }
- return 0;
- }
- //
- // --------------------------------------------------------- Internal Functions
- //
- BOOL
- ExtpPrintDeviceResources (
- PDEBUGGER_CONTEXT Context,
- ULONGLONG Address,
- ULONG IndentationLevel
- )
- /*++
- Routine Description:
- This routine prints out a device's resources.
- Arguments:
- Context - Supplies a pointer to the application context.
- Address - Supplies the address of the devices whose resources should be
- dumped.
- IndentationLevel - Supplies the indentation level to print the object at.
- Return Value:
- TRUE on success.
- FALSE on failure.
- --*/
- {
- ULONGLONG BootResources;
- ULONGLONG BusLocalResources;
- PVOID Data;
- ULONG DataSize;
- ULONGLONG DeviceAddress;
- PTYPE_SYMBOL DeviceType;
- ULONGLONG HeaderType;
- ULONGLONG ProcessorLocalResources;
- ULONGLONG ResourceRequirements;
- BOOL Result;
- ULONGLONG SelectedConfiguration;
- INT Status;
- Data = NULL;
- //
- // Bail out if the indentation seems too deep.
- //
- if (IndentationLevel > 50) {
- return FALSE;
- }
- //
- // Print out the indentation.
- //
- DbgOut("%*s", IndentationLevel, "");
- DeviceAddress = Address;
- DbgOut("Device %I64x:\n", DeviceAddress);
- Status = DbgReadTypeByName(Context,
- Address,
- "_DEVICE",
- &DeviceType,
- &Data,
- &DataSize);
- if (Status != 0) {
- DbgOut("Error: Could not read _DEVICE at 0x%I64x\n", Address);
- goto PrintDeviceResourcesEnd;
- }
- Status = DbgReadIntegerMember(Context,
- DeviceType,
- "Header.Type",
- Address,
- Data,
- DataSize,
- &HeaderType);
- if (Status != 0) {
- goto PrintDeviceResourcesEnd;
- }
- if (HeaderType != ObjectDevice) {
- DbgOut("Object header type %I64d, probably not a device!\n",
- HeaderType);
- Status = EINVAL;
- goto PrintDeviceResourcesEnd;
- }
- IndentationLevel += 1;
- //
- // Print the processor resources.
- //
- DbgOut("%*s", IndentationLevel, "");
- Status = DbgReadIntegerMember(Context,
- DeviceType,
- "ProcessorLocalResources",
- Address,
- Data,
- DataSize,
- &ProcessorLocalResources);
- if (Status != 0) {
- goto PrintDeviceResourcesEnd;
- }
- if (ProcessorLocalResources == 0) {
- DbgOut("No Processor Local Resources.\n");
- } else {
- DbgOut("Processor Local Resources @ %x\n", ProcessorLocalResources);
- ExtpPrintResourceAllocationList(Context,
- ProcessorLocalResources,
- IndentationLevel);
- }
- //
- // Print the bus local resources.
- //
- DbgOut("%*s", IndentationLevel, "");
- Status = DbgReadIntegerMember(Context,
- DeviceType,
- "BusLocalResources",
- Address,
- Data,
- DataSize,
- &BusLocalResources);
- if (Status != 0) {
- goto PrintDeviceResourcesEnd;
- }
- if (BusLocalResources == 0) {
- DbgOut("No Bus Local Resources.\n");
- } else {
- DbgOut("Bus Local Resources @ %x\n", BusLocalResources);
- ExtpPrintResourceAllocationList(Context,
- BusLocalResources,
- IndentationLevel);
- }
- //
- // Print the boot resources.
- //
- DbgOut("%*s", IndentationLevel, "");
- Status = DbgReadIntegerMember(Context,
- DeviceType,
- "BootResources",
- Address,
- Data,
- DataSize,
- &BootResources);
- if (Status != 0) {
- goto PrintDeviceResourcesEnd;
- }
- if (BootResources == 0) {
- DbgOut("No Boot Resources.\n");
- } else {
- DbgOut("Boot Resources @ %x\n", BootResources);
- ExtpPrintResourceAllocationList(Context,
- BootResources,
- IndentationLevel);
- }
- //
- // Print the selected configuration.
- //
- Status = DbgReadIntegerMember(Context,
- DeviceType,
- "SelectedConfiguration",
- Address,
- Data,
- DataSize,
- &SelectedConfiguration);
- if (Status != 0) {
- goto PrintDeviceResourcesEnd;
- }
- if (SelectedConfiguration != 0) {
- DbgOut("%*s", IndentationLevel, "");
- DbgOut("Selected Configuration %x\n", SelectedConfiguration);
- }
- //
- // Print the resource requirements.
- //
- DbgOut("%*s", IndentationLevel, "");
- Status = DbgReadIntegerMember(Context,
- DeviceType,
- "ResourceRequirements",
- Address,
- Data,
- DataSize,
- &ResourceRequirements);
- if (Status != 0) {
- goto PrintDeviceResourcesEnd;
- }
- if (ResourceRequirements == 0) {
- DbgOut("No Resource Requirements.\n");
- } else {
- DbgOut("Resource Requirements @ %x\n", ResourceRequirements);
- ExtpPrintResourceConfigurationList(Context,
- ResourceRequirements,
- IndentationLevel);
- }
- Status = 0;
- PrintDeviceResourcesEnd:
- if (Data != NULL) {
- free(Data);
- }
- Result = TRUE;
- if (Status != 0) {
- Result = FALSE;
- }
- return Result;
- }
- BOOL
- ExtpPrintResourceConfigurationList (
- PDEBUGGER_CONTEXT Context,
- ULONGLONG Address,
- ULONG IndentationLevel
- )
- /*++
- Routine Description:
- This routine prints out a resource configuration list.
- Arguments:
- Context - Supplies a pointer to the application context.
- Address - Supplies the address of the resource configuration list to print.
- IndentationLevel - Supplies the indentation level to print the object at.
- Return Value:
- TRUE on success.
- FALSE on failure.
- --*/
- {
- ULONGLONG ChildListHead;
- ULONGLONG ChildObjectAddress;
- PTYPE_SYMBOL ConfigurationListType;
- ULONGLONG CurrentEntryAddress;
- PVOID Data;
- ULONG DataSize;
- PTYPE_SYMBOL ListEntryType;
- ULONG RequirementHeadOffset;
- ULONG RequirementListEntryOffset;
- PTYPE_SYMBOL RequirementListType;
- BOOL Result;
- INT Status;
- Data = NULL;
- //
- // Bail out if the indentation seems too deep.
- //
- if (IndentationLevel > 50) {
- return FALSE;
- }
- //
- // Print out the indentation.
- //
- DbgOut("%*s", IndentationLevel, "");
- DbgOut("Resource Configuration List @ %08I64x\n", Address);
- Status = DbgReadTypeByName(Context,
- Address,
- "_RESOURCE_CONFIGURATION_LIST",
- &ConfigurationListType,
- &Data,
- &DataSize);
- if (Status != 0) {
- DbgOut("Error: Could not read configuration list at 0x%I64x.\n",
- Address);
- goto PrintResourceConfigurationListEnd;
- }
- Status = DbgGetMemberOffset(ConfigurationListType,
- "RequirementListListHead",
- &RequirementHeadOffset,
- NULL);
- if (Status != 0) {
- goto PrintResourceConfigurationListEnd;
- }
- RequirementHeadOffset /= BITS_PER_BYTE;
- Status = DbgGetTypeByName(Context, "LIST_ENTRY", &ListEntryType);
- if (Status != 0) {
- goto PrintResourceConfigurationListEnd;
- }
- Status = DbgGetTypeByName(Context,
- "_RESOURCE_REQUIREMENT_LIST",
- &RequirementListType);
- if (Status != 0) {
- goto PrintResourceConfigurationListEnd;
- }
- Status = DbgGetMemberOffset(RequirementListType,
- "ListEntry",
- &RequirementListEntryOffset,
- NULL);
- if (Status != 0) {
- goto PrintResourceConfigurationListEnd;
- }
- RequirementListEntryOffset /= BITS_PER_BYTE;
- //
- // Print out all children.
- //
- IndentationLevel += 1;
- ChildListHead = Address + RequirementHeadOffset;
- Status = DbgReadIntegerMember(Context,
- ConfigurationListType,
- "RequirementListListHead.Next",
- Address,
- Data,
- DataSize,
- &CurrentEntryAddress);
- if (Status != 0) {
- goto PrintResourceConfigurationListEnd;
- }
- free(Data);
- Data = NULL;
- while (CurrentEntryAddress != ChildListHead) {
- //
- // Read the list entry.
- //
- assert(Data == NULL);
- Status = DbgReadType(Context,
- CurrentEntryAddress,
- ListEntryType,
- &Data,
- &DataSize);
- if (Status != 0) {
- goto PrintResourceConfigurationListEnd;
- }
- //
- // Print the resource requirement list.
- //
- ChildObjectAddress = CurrentEntryAddress - RequirementListEntryOffset;
- Status = ExtpPrintResourceRequirementList(Context,
- ChildObjectAddress,
- IndentationLevel);
- if (Status == FALSE) {
- Status = EINVAL;
- goto PrintResourceConfigurationListEnd;
- }
- //
- // Move to the next child.
- //
- Status = DbgReadIntegerMember(Context,
- ListEntryType,
- "Next",
- CurrentEntryAddress,
- Data,
- DataSize,
- &CurrentEntryAddress);
- if (Status != 0) {
- goto PrintResourceConfigurationListEnd;
- }
- free(Data);
- Data = NULL;
- }
- PrintResourceConfigurationListEnd:
- if (Data != NULL) {
- free(Data);
- }
- Result = TRUE;
- if (Status != 0) {
- Result = FALSE;
- }
- return Result;
- }
- BOOL
- ExtpPrintResourceRequirementList (
- PDEBUGGER_CONTEXT Context,
- ULONGLONG Address,
- ULONG IndentationLevel
- )
- /*++
- Routine Description:
- This routine prints out a resource requirement list.
- Arguments:
- Context - Supplies a pointer to the application context.
- Address - Supplies the address of the resource requirement list to print.
- IndentationLevel - Supplies the indentation level to print the object at.
- Return Value:
- TRUE on success.
- FALSE on failure.
- --*/
- {
- ULONGLONG ChildListHead;
- ULONGLONG ChildObjectAddress;
- ULONGLONG CurrentEntryAddress;
- PVOID Data;
- ULONG DataSize;
- PTYPE_SYMBOL ListEntryType;
- ULONG RequirementEntryOffset;
- ULONG RequirementListHeadOffset;
- PTYPE_SYMBOL RequirementListType;
- PTYPE_SYMBOL RequirementType;
- BOOL Result;
- INT Status;
- //
- // Bail out if the indentation seems too deep.
- //
- if (IndentationLevel > 50) {
- return FALSE;
- }
- //
- // Print out the indentation.
- //
- DbgOut("%*s", IndentationLevel, "");
- DbgOut("Resource Requirement List @ %08I64x\n", Address);
- Status = DbgReadTypeByName(Context,
- Address,
- "_RESOURCE_REQUIREMENT_LIST",
- &RequirementListType,
- &Data,
- &DataSize);
- if (Status != 0) {
- DbgOut("Error: Could not read requirement list at 0x%I64x.\n",
- Address);
- goto PrintResourceRequirementListEnd;
- }
- Status = DbgGetMemberOffset(RequirementListType,
- "RequirementListHead",
- &RequirementListHeadOffset,
- NULL);
- if (Status != 0) {
- goto PrintResourceRequirementListEnd;
- }
- RequirementListHeadOffset /= BITS_PER_BYTE;
- Status = DbgGetTypeByName(Context, "LIST_ENTRY", &ListEntryType);
- if (Status != 0) {
- goto PrintResourceRequirementListEnd;
- }
- Status = DbgGetTypeByName(Context,
- "_RESOURCE_REQUIREMENT",
- &RequirementType);
- if (Status != 0) {
- goto PrintResourceRequirementListEnd;
- }
- Status = DbgGetMemberOffset(RequirementType,
- "ListEntry",
- &RequirementEntryOffset,
- NULL);
- if (Status != 0) {
- goto PrintResourceRequirementListEnd;
- }
- RequirementEntryOffset /= BITS_PER_BYTE;
- //
- // Print out all children.
- //
- IndentationLevel += 1;
- ChildListHead = Address + RequirementListHeadOffset;
- Status = DbgReadIntegerMember(Context,
- RequirementListType,
- "RequirementListHead.Next",
- Address,
- Data,
- DataSize,
- &CurrentEntryAddress);
- if (Status != 0) {
- goto PrintResourceRequirementListEnd;
- }
- free(Data);
- Data = NULL;
- while (CurrentEntryAddress != ChildListHead) {
- //
- // Read the list entry.
- //
- assert(Data == NULL);
- Status = DbgReadType(Context,
- CurrentEntryAddress,
- ListEntryType,
- &Data,
- &DataSize);
- if (Status != 0) {
- goto PrintResourceRequirementListEnd;
- }
- //
- // Print the resource requirement list.
- //
- ChildObjectAddress = CurrentEntryAddress - RequirementEntryOffset;
- Result = ExtpPrintResourceRequirement(Context,
- ChildObjectAddress,
- IndentationLevel);
- if (Result == FALSE) {
- Status = EINVAL;
- goto PrintResourceRequirementListEnd;
- }
- //
- // Move to the next child.
- //
- Status = DbgReadIntegerMember(Context,
- ListEntryType,
- "Next",
- CurrentEntryAddress,
- Data,
- DataSize,
- &CurrentEntryAddress);
- if (Status != 0) {
- goto PrintResourceRequirementListEnd;
- }
- free(Data);
- Data = NULL;
- }
- PrintResourceRequirementListEnd:
- if (Data != NULL) {
- free(Data);
- }
- Result = TRUE;
- if (Status != 0) {
- Result = FALSE;
- }
- return Result;
- }
- BOOL
- ExtpPrintResourceRequirement (
- PDEBUGGER_CONTEXT Context,
- ULONGLONG Address,
- ULONG IndentationLevel
- )
- /*++
- Routine Description:
- This routine prints out a resource requirement.
- Arguments:
- Context - Supplies a pointer to the application context.
- Address - Supplies the address of the resource requirement to print.
- IndentationLevel - Supplies the indentation level to print the object at.
- Return Value:
- TRUE on success.
- FALSE on failure.
- --*/
- {
- ULONG AlternativeListEntryOffset;
- ULONGLONG ChildListHead;
- ULONGLONG ChildObjectAddress;
- ULONGLONG CurrentEntryAddress;
- PVOID Data;
- ULONG DataSize;
- ULONGLONG Flags;
- PTYPE_SYMBOL ListEntryType;
- ULONGLONG RequirementDataSize;
- PTYPE_SYMBOL RequirementType;
- PSTR ResourceType;
- BOOL Result;
- INT Status;
- ULONGLONG Value;
- Data = NULL;
- //
- // Bail out if the indentation seems too deep.
- //
- if (IndentationLevel > 50) {
- return FALSE;
- }
- //
- // Print out the indentation.
- //
- DbgOut("%*s", IndentationLevel, "");
- Status = DbgReadTypeByName(Context,
- Address,
- "_RESOURCE_REQUIREMENT",
- &RequirementType,
- &Data,
- &DataSize);
- if (Status != 0) {
- DbgOut("Error: Could not read requirement at 0x%I64x.\n", Address);
- goto PrintResourceRequirementEnd;
- }
- Status = DbgReadIntegerMember(Context,
- RequirementType,
- "Type",
- Address,
- Data,
- DataSize,
- &Value);
- if (Status != 0) {
- goto PrintResourceRequirementEnd;
- }
- ResourceType = ExtpGetResourceTypeString(Value);
- DbgOut("%08I64x %16s: Range ", Address, ResourceType);
- Status = DbgReadIntegerMember(Context,
- RequirementType,
- "Minimum",
- Address,
- Data,
- DataSize,
- &Value);
- if (Status != 0) {
- goto PrintResourceRequirementEnd;
- }
- DbgOut("%08I64x - ", Value);
- Status = DbgReadIntegerMember(Context,
- RequirementType,
- "Maximum",
- Address,
- Data,
- DataSize,
- &Value);
- if (Status != 0) {
- goto PrintResourceRequirementEnd;
- }
- DbgOut("%08I64x, Len ", Value);
- Status = DbgReadIntegerMember(Context,
- RequirementType,
- "Length",
- Address,
- Data,
- DataSize,
- &Value);
- if (Status != 0) {
- goto PrintResourceRequirementEnd;
- }
- DbgOut("%08I64x, Align ", Value);
- Status = DbgReadIntegerMember(Context,
- RequirementType,
- "Alignment",
- Address,
- Data,
- DataSize,
- &Value);
- if (Status != 0) {
- goto PrintResourceRequirementEnd;
- }
- DbgOut("%I64x, Char ", Value);
- Status = DbgReadIntegerMember(Context,
- RequirementType,
- "Characteristics",
- Address,
- Data,
- DataSize,
- &Value);
- if (Status != 0) {
- goto PrintResourceRequirementEnd;
- }
- DbgOut("%I64x, Flags ", Value);
- Status = DbgReadIntegerMember(Context,
- RequirementType,
- "Flags",
- Address,
- Data,
- DataSize,
- &Flags);
- if (Status != 0) {
- goto PrintResourceRequirementEnd;
- }
- DbgOut("%I64x", Flags);
- Status = DbgReadIntegerMember(Context,
- RequirementType,
- "OwningRequirement",
- Address,
- Data,
- DataSize,
- &Value);
- if (Status != 0) {
- goto PrintResourceRequirementEnd;
- }
- if (Value != 0) {
- DbgOut(", Owner %I64x", Value);
- }
- if ((Flags & RESOURCE_FLAG_NOT_SHAREABLE) != 0) {
- DbgOut(" NotShared");
- }
- Status = DbgReadIntegerMember(Context,
- RequirementType,
- "Provider",
- Address,
- Data,
- DataSize,
- &Value);
- if (Status != 0) {
- goto PrintResourceRequirementEnd;
- }
- if (Value != 0) {
- DbgOut(", Provider %x", Value);
- }
- Status = DbgReadIntegerMember(Context,
- RequirementType,
- "DataSize",
- Address,
- Data,
- DataSize,
- &RequirementDataSize);
- if (Status != 0) {
- goto PrintResourceRequirementEnd;
- }
- if (RequirementDataSize != 0) {
- Status = DbgReadIntegerMember(Context,
- RequirementType,
- "Data",
- Address,
- Data,
- DataSize,
- &Value);
- if (Status != 0) {
- goto PrintResourceRequirementEnd;
- }
- DbgOut(", Data 0x%I64x Size 0x%I64x", Value, RequirementDataSize);
- }
- DbgOut("\n");
- //
- // If the requirement is not linked in, assume it is an alternative and
- // don't try to traverse alternatives.
- //
- Status = DbgReadIntegerMember(Context,
- RequirementType,
- "ListEntry.Next",
- Address,
- Data,
- DataSize,
- &Value);
- if (Status != 0) {
- goto PrintResourceRequirementEnd;
- }
- if (Value == 0) {
- Status = 0;
- goto PrintResourceRequirementEnd;
- }
- Status = DbgGetTypeByName(Context, "LIST_ENTRY", &ListEntryType);
- if (Status != 0) {
- goto PrintResourceRequirementEnd;
- }
- Status = DbgGetMemberOffset(RequirementType,
- "AlternativeListEntry",
- &AlternativeListEntryOffset,
- NULL);
- if (Status != 0) {
- goto PrintResourceRequirementEnd;
- }
- AlternativeListEntryOffset /= BITS_PER_BYTE;
- //
- // Print out all children.
- //
- IndentationLevel += 1;
- ChildListHead = Address + AlternativeListEntryOffset;
- Status = DbgReadIntegerMember(Context,
- RequirementType,
- "AlternativeListEntry.Next",
- Address,
- Data,
- DataSize,
- &CurrentEntryAddress);
- if (Status != 0) {
- goto PrintResourceRequirementEnd;
- }
- free(Data);
- Data = NULL;
- while (CurrentEntryAddress != ChildListHead) {
- //
- // Read the list entry.
- //
- assert(Data == NULL);
- Status = DbgReadType(Context,
- CurrentEntryAddress,
- ListEntryType,
- &Data,
- &DataSize);
- if (Status != 0) {
- goto PrintResourceRequirementEnd;
- }
- //
- // Print the resource requirement alternative.
- //
- ChildObjectAddress = CurrentEntryAddress - AlternativeListEntryOffset;
- Result = ExtpPrintResourceRequirement(Context,
- ChildObjectAddress,
- IndentationLevel);
- if (Result == FALSE) {
- Status = EINVAL;
- goto PrintResourceRequirementEnd;
- }
- //
- // Move to the next child.
- //
- Status = DbgReadIntegerMember(Context,
- ListEntryType,
- "Next",
- CurrentEntryAddress,
- Data,
- DataSize,
- &CurrentEntryAddress);
- if (Status != 0) {
- goto PrintResourceRequirementEnd;
- }
- free(Data);
- Data = NULL;
- }
- Status = 0;
- PrintResourceRequirementEnd:
- if (Data != NULL) {
- free(Data);
- }
- Result = TRUE;
- if (Status != 0) {
- Result = FALSE;
- }
- return Result;
- }
- BOOL
- ExtpPrintResourceAllocationList (
- PDEBUGGER_CONTEXT Context,
- ULONGLONG Address,
- ULONG IndentationLevel
- )
- /*++
- Routine Description:
- This routine prints out a resource allocation list.
- Arguments:
- Context - Supplies a pointer to the application context.
- Address - Supplies the address of the resource allocation list to print.
- IndentationLevel - Supplies the indentation level to print the object at.
- Return Value:
- TRUE on success.
- FALSE on failure.
- --*/
- {
- ULONG AllocationEntryOffset;
- ULONG AllocationListHeadOffset;
- PTYPE_SYMBOL AllocationListType;
- PTYPE_SYMBOL AllocationType;
- ULONGLONG ChildListHead;
- ULONGLONG ChildObjectAddress;
- ULONGLONG CurrentEntryAddress;
- PVOID Data;
- ULONG DataSize;
- PTYPE_SYMBOL ListEntryType;
- BOOL Result;
- INT Status;
- Data = NULL;
- //
- // Bail out if the indentation seems too deep.
- //
- if (IndentationLevel > 50) {
- return FALSE;
- }
- //
- // Print out the indentation.
- //
- DbgOut("%*s", IndentationLevel, "");
- DbgOut("Resource Allocation List @ %08I64x\n", Address);
- Status = DbgReadTypeByName(Context,
- Address,
- "_RESOURCE_ALLOCATION_LIST",
- &AllocationListType,
- &Data,
- &DataSize);
- if (Status != 0) {
- DbgOut("Error: Could not read allocation list at 0x%I64x.\n", Address);
- goto PrintResourceAllocationListEnd;
- }
- Status = DbgGetMemberOffset(AllocationListType,
- "AllocationListHead",
- &AllocationListHeadOffset,
- NULL);
- if (Status != 0) {
- goto PrintResourceAllocationListEnd;
- }
- AllocationListHeadOffset /= BITS_PER_BYTE;
- Status = DbgGetTypeByName(Context, "LIST_ENTRY", &ListEntryType);
- if (Status != 0) {
- goto PrintResourceAllocationListEnd;
- }
- Status = DbgGetTypeByName(Context, "_RESOURCE_ALLOCATION", &AllocationType);
- if (Status != 0) {
- goto PrintResourceAllocationListEnd;
- }
- Status = DbgGetMemberOffset(AllocationType,
- "ListEntry",
- &AllocationEntryOffset,
- NULL);
- if (Status != 0) {
- goto PrintResourceAllocationListEnd;
- }
- //
- // Print out all children.
- //
- IndentationLevel += 1;
- ChildListHead = Address + AllocationListHeadOffset;
- Status = DbgReadIntegerMember(Context,
- AllocationListType,
- "AllocationListHead.Next",
- Address,
- Data,
- DataSize,
- &CurrentEntryAddress);
- if (Status != 0) {
- goto PrintResourceAllocationListEnd;
- }
- free(Data);
- Data = NULL;
- while (CurrentEntryAddress != ChildListHead) {
- //
- // Read the list entry.
- //
- assert(Data == NULL);
- Status = DbgReadType(Context,
- CurrentEntryAddress,
- ListEntryType,
- &Data,
- &DataSize);
- if (Status != 0) {
- goto PrintResourceAllocationListEnd;
- }
- //
- // Print the resource requirement list.
- //
- ChildObjectAddress = CurrentEntryAddress - AllocationEntryOffset;
- Result = ExtpPrintResourceAllocation(Context,
- ChildObjectAddress,
- IndentationLevel);
- if (Result == FALSE) {
- Status = EINVAL;
- goto PrintResourceAllocationListEnd;
- }
- //
- // Move to the next child.
- //
- Status = DbgReadIntegerMember(Context,
- ListEntryType,
- "Next",
- CurrentEntryAddress,
- Data,
- DataSize,
- &CurrentEntryAddress);
- if (Status != 0) {
- goto PrintResourceAllocationListEnd;
- }
- free(Data);
- Data = NULL;
- }
- Status = 0;
- PrintResourceAllocationListEnd:
- if (Data != NULL) {
- free(Data);
- }
- Result = TRUE;
- if (Status != 0) {
- Result = FALSE;
- }
- return Result;
- }
- BOOL
- ExtpPrintResourceAllocation (
- PDEBUGGER_CONTEXT Context,
- ULONGLONG Address,
- ULONG IndentationLevel
- )
- /*++
- Routine Description:
- This routine prints out a resource allocation.
- Arguments:
- Context - Supplies a pointer to the application context.
- Address - Supplies the address of the resource allocation to print.
- IndentationLevel - Supplies the indentation level to print the object at.
- Return Value:
- TRUE on success.
- FALSE on failure.
- --*/
- {
- ULONGLONG AllocationDataSize;
- PTYPE_SYMBOL AllocationType;
- PVOID Data;
- ULONG DataSize;
- PSTR ResourceType;
- BOOL Result;
- INT Status;
- ULONGLONG Value;
- Data = NULL;
- //
- // Bail out if the indentation seems too deep.
- //
- if (IndentationLevel > 50) {
- return FALSE;
- }
- //
- // Print out the indentation.
- //
- DbgOut("%*s", IndentationLevel, "");
- Status = DbgReadTypeByName(Context,
- Address,
- "_RESOURCE_ALLOCATION",
- &AllocationType,
- &Data,
- &DataSize);
- if (Status != 0) {
- DbgOut("Error: Could not read allocation at 0x%I64x.\n",
- Address);
- goto PrintResourceAllocationEnd;
- }
- Status = DbgReadIntegerMember(Context,
- AllocationType,
- "Type",
- Address,
- Data,
- DataSize,
- &Value);
- if (Status != 0) {
- goto PrintResourceAllocationEnd;
- }
- ResourceType = ExtpGetResourceTypeString(Value);
- DbgOut("%08I64x %16s: ", Address, ResourceType);
- Status = DbgReadIntegerMember(Context,
- AllocationType,
- "Allocation",
- Address,
- Data,
- DataSize,
- &Value);
- if (Status != 0) {
- goto PrintResourceAllocationEnd;
- }
- DbgOut("%08I64x, Len ", Value);
- Status = DbgReadIntegerMember(Context,
- AllocationType,
- "Length",
- Address,
- Data,
- DataSize,
- &Value);
- if (Status != 0) {
- goto PrintResourceAllocationEnd;
- }
- DbgOut("%08I64x, Char ", Value);
- Status = DbgReadIntegerMember(Context,
- AllocationType,
- "Characteristics",
- Address,
- Data,
- DataSize,
- &Value);
- if (Status != 0) {
- goto PrintResourceAllocationEnd;
- }
- DbgOut("%I64x", Value);
- Status = DbgReadIntegerMember(Context,
- AllocationType,
- "OwningAllocation",
- Address,
- Data,
- DataSize,
- &Value);
- if (Status != 0) {
- goto PrintResourceAllocationEnd;
- }
- if (Value != 0) {
- DbgOut(", Owner %I64x", Value);
- }
- Status = DbgReadIntegerMember(Context,
- AllocationType,
- "Flags",
- Address,
- Data,
- DataSize,
- &Value);
- if (Status != 0) {
- goto PrintResourceAllocationEnd;
- }
- if ((Value & RESOURCE_FLAG_NOT_SHAREABLE) != 0) {
- DbgOut(" NotShared");
- }
- Status = DbgReadIntegerMember(Context,
- AllocationType,
- "Provider",
- Address,
- Data,
- DataSize,
- &Value);
- if (Status != 0) {
- goto PrintResourceAllocationEnd;
- }
- if (Value != 0) {
- DbgOut(", Provider %I64x", Value);
- }
- Status = DbgReadIntegerMember(Context,
- AllocationType,
- "DataSize",
- Address,
- Data,
- DataSize,
- &AllocationDataSize);
- if (Status != 0) {
- goto PrintResourceAllocationEnd;
- }
- if (AllocationDataSize != 0) {
- Status = DbgReadIntegerMember(Context,
- AllocationType,
- "Data",
- Address,
- Data,
- DataSize,
- &Value);
- if (Status != 0) {
- goto PrintResourceAllocationEnd;
- }
- DbgOut(", Data %I64x Size 0x%I64x", Value, AllocationDataSize);
- }
- Status = 0;
- PrintResourceAllocationEnd:
- if (Data != NULL) {
- free(Data);
- }
- Result = TRUE;
- if (Status != 0) {
- Result = FALSE;
- }
- DbgOut("\n");
- return Result;
- }
- BOOL
- ExtpPrintDeviceArbiters (
- PDEBUGGER_CONTEXT Context,
- ULONGLONG Address,
- ULONG IndentationLevel
- )
- /*++
- Routine Description:
- This routine prints out the resource arbiters associated with a device.
- Arguments:
- Context - Supplies a pointer to the application context.
- Address - Supplies the address of the device whose arbiters should be
- dumped.
- IndentationLevel - Supplies the indentation level to print the object at.
- Return Value:
- TRUE on success.
- FALSE on failure.
- --*/
- {
- ULONG ArbiterIndex;
- ULONG ArbiterListEntryOffset;
- ULONG ArbiterListHeadOffset;
- PTYPE_SYMBOL ArbiterType;
- ULONGLONG ChildListHead;
- ULONGLONG ChildObjectAddress;
- ULONGLONG CurrentEntryAddress;
- PVOID Data;
- ULONG DataSize;
- ULONGLONG DeviceAddress;
- ULONGLONG DeviceParentAddress;
- PTYPE_SYMBOL DeviceType;
- ULONGLONG HeaderType;
- PVOID ListEntryData;
- ULONG ListEntryDataSize;
- PTYPE_SYMBOL ListEntryType;
- ULONGLONG NextParent;
- ULONGLONG OriginalDeviceAddress;
- ULONGLONG ResourceType;
- BOOL Result;
- INT Status;
- ChildObjectAddress = 0;
- Data = NULL;
- ListEntryData = NULL;
- //
- // Bail out if the indentation seems too deep.
- //
- if (IndentationLevel > 50) {
- return FALSE;
- }
- //
- // Print out the indentation.
- //
- DbgOut("%*s", IndentationLevel, "");
- //
- // Get the parent of the current device.
- //
- OriginalDeviceAddress = Address;
- Status = DbgReadTypeByName(Context,
- Address,
- "_DEVICE",
- &DeviceType,
- &Data,
- &DataSize);
- if (Status != 0) {
- DbgOut("Failed to read device at %I64x.\n", Address);
- goto PrintDeviceArbitersEnd;
- }
- Status = DbgGetMemberOffset(DeviceType,
- "ArbiterListHead",
- &ArbiterListHeadOffset,
- NULL);
- if (Status != 0) {
- goto PrintDeviceArbitersEnd;
- }
- ArbiterListHeadOffset /= BITS_PER_BYTE;
- Status = DbgGetTypeByName(Context, "LIST_ENTRY", &ListEntryType);
- if (Status != 0) {
- goto PrintDeviceArbitersEnd;
- }
- Status = DbgGetTypeByName(Context, "_RESOURCE_ARBITER", &ArbiterType);
- if (Status != 0) {
- goto PrintDeviceArbitersEnd;
- }
- Status = DbgGetMemberOffset(ArbiterType,
- "ListEntry",
- &ArbiterListEntryOffset,
- NULL);
- if (Status != 0) {
- goto PrintDeviceArbitersEnd;
- }
- Status = DbgReadIntegerMember(Context,
- DeviceType,
- "Header.Type",
- Address,
- Data,
- DataSize,
- &HeaderType);
- if (Status != 0) {
- goto PrintDeviceArbitersEnd;
- }
- if (HeaderType != ObjectDevice) {
- DbgOut("Object header type %I64d, probably not a device!\n",
- HeaderType);
- return FALSE;
- }
- Status = DbgReadIntegerMember(Context,
- DeviceType,
- "ParentDevice",
- Address,
- Data,
- DataSize,
- &DeviceParentAddress);
- if (Status != 0) {
- goto PrintDeviceArbitersEnd;
- }
- DbgOut("Arbiters for device %I64x (parent %I64x):\n",
- OriginalDeviceAddress,
- DeviceParentAddress);
- free(Data);
- Data = NULL;
- //
- // Attempt to find each arbiter.
- //
- IndentationLevel += 1;
- for (ArbiterIndex = 1; ArbiterIndex < ArbiterTypeCount; ArbiterIndex += 1) {
- //
- // Start at the original device address and look through all its
- // arbiters.
- //
- DeviceAddress = DeviceParentAddress;
- while (TRUE) {
- assert(Data == NULL);
- Status = DbgReadType(Context,
- DeviceAddress,
- DeviceType,
- &Data,
- &DataSize);
- if (Status != 0) {
- DbgOut("Failed to read device at %I64x.\n", DeviceAddress);
- goto PrintDeviceArbitersEnd;
- }
- Status = DbgReadIntegerMember(Context,
- DeviceType,
- "Header.Type",
- DeviceAddress,
- Data,
- DataSize,
- &HeaderType);
- if (Status != 0) {
- goto PrintDeviceArbitersEnd;
- }
- if (HeaderType != ObjectDevice) {
- DbgOut("Object header type %I64d, probably not a device!\n",
- HeaderType);
- Status = EINVAL;
- goto PrintDeviceArbitersEnd;
- }
- Status = DbgReadIntegerMember(Context,
- DeviceType,
- "ParentDevice",
- Address,
- Data,
- DataSize,
- &NextParent);
- if (Status != 0) {
- goto PrintDeviceArbitersEnd;
- }
- //
- // Loop through every arbiter in the device.
- //
- ChildListHead = DeviceAddress + ArbiterListHeadOffset;
- Status = DbgReadIntegerMember(Context,
- DeviceType,
- "ArbiterListHead.Next",
- DeviceAddress,
- Data,
- DataSize,
- &CurrentEntryAddress);
- if (Status != 0) {
- goto PrintDeviceArbitersEnd;
- }
- free(Data);
- Data = NULL;
- while (CurrentEntryAddress != ChildListHead) {
- //
- // Read the list entry.
- //
- assert(ListEntryData == NULL);
- Status = DbgReadType(Context,
- CurrentEntryAddress,
- ListEntryType,
- &ListEntryData,
- &ListEntryDataSize);
- if (Status != 0) {
- goto PrintDeviceArbitersEnd;
- }
- //
- // Read in the arbiter.
- //
- ChildObjectAddress =
- CurrentEntryAddress - ArbiterListEntryOffset;
- assert(Data == NULL);
- Status = DbgReadType(Context,
- ChildObjectAddress,
- ArbiterType,
- &Data,
- &DataSize);
- if (Status != 0) {
- DbgOut("Error: Could not read arbiter at 0x%I64x.\n",
- ChildObjectAddress);
- goto PrintDeviceArbitersEnd;
- }
- Status = DbgReadIntegerMember(Context,
- ArbiterType,
- "ResourceType",
- ChildObjectAddress,
- Data,
- DataSize,
- &ResourceType);
- if (Status != 0) {
- goto PrintDeviceArbitersEnd;
- }
- free(Data);
- Data = NULL;
- //
- // Stop looking if this arbiter is the right type.
- //
- if (ResourceType == ArbiterIndex) {
- free(ListEntryData);
- ListEntryData = NULL;
- break;
- }
- //
- // Move to the next entry.
- //
- Status = DbgReadIntegerMember(Context,
- ListEntryType,
- "Next",
- CurrentEntryAddress,
- ListEntryData,
- ListEntryDataSize,
- &CurrentEntryAddress);
- if (Status != 0) {
- goto PrintDeviceArbitersEnd;
- }
- free(ListEntryData);
- ListEntryData = NULL;
- }
- //
- // If an arbiter was found, print it out and stop looking for this
- // arbiter type.
- //
- if (CurrentEntryAddress != ChildListHead) {
- ExtpPrintResourceArbiter(Context,
- ChildObjectAddress,
- IndentationLevel);
- break;
- }
- //
- // No arbiter was found in this device, so move to the parent
- // device.
- //
- DeviceAddress = NextParent;
- if (DeviceAddress == 0) {
- DbgOut("Could not find %s arbiter.\n",
- ExtpGetResourceTypeString(ArbiterIndex));
- break;
- }
- }
- }
- PrintDeviceArbitersEnd:
- if (Data != NULL) {
- free(Data);
- }
- if (ListEntryData != NULL) {
- free(ListEntryData);
- }
- Result = TRUE;
- if (Status != 0) {
- Result = FALSE;
- }
- return Result;
- }
- BOOL
- ExtpPrintResourceArbiter (
- PDEBUGGER_CONTEXT Context,
- ULONGLONG Address,
- ULONG IndentationLevel
- )
- /*++
- Routine Description:
- This routine prints out a resource arbiter.
- Arguments:
- Context - Supplies a pointer to the application context.
- Address - Supplies the address of the arbiter to print.
- IndentationLevel - Supplies the indentation level to print the object at.
- Return Value:
- TRUE on success.
- FALSE on failure.
- --*/
- {
- ULONG ArbiterEntryListHeadOffset;
- ULONG ArbiterEntryOffset;
- PTYPE_SYMBOL ArbiterType;
- ULONGLONG ChildListHead;
- ULONGLONG ChildObjectAddress;
- ULONGLONG CurrentEntryAddress;
- PVOID Data;
- ULONG DataSize;
- PTYPE_SYMBOL ListEntryType;
- PSTR ResourceType;
- BOOL Result;
- INT Status;
- ULONGLONG Value;
- //
- // Bail out if the indentation seems too deep.
- //
- if (IndentationLevel > 50) {
- return FALSE;
- }
- //
- // Print out the indentation.
- //
- DbgOut("%*s", IndentationLevel, "");
- Status = DbgReadTypeByName(Context,
- Address,
- "_RESOURCE_ARBITER",
- &ArbiterType,
- &Data,
- &DataSize);
- if (Status != 0) {
- DbgOut("Failed to read _RESOURCE_ARBITER at %I64x.\n", Address);
- goto PrintResourceArbiterEnd;
- }
- Status = DbgReadIntegerMember(Context,
- ArbiterType,
- "ResourceType",
- Address,
- Data,
- DataSize,
- &Value);
- if (Status != 0) {
- goto PrintResourceArbiterEnd;
- }
- ResourceType = ExtpGetResourceTypeString(Value);
- DbgOut("%s Arbiter @ 0x%I64x owned by device ", ResourceType, Address);
- Status = DbgReadIntegerMember(Context,
- ArbiterType,
- "OwningDevice",
- Address,
- Data,
- DataSize,
- &Value);
- if (Status != 0) {
- goto PrintResourceArbiterEnd;
- }
- DbgOut("0x%I64x\n", Value);
- Status = DbgGetMemberOffset(ArbiterType,
- "EntryListHead",
- &ArbiterEntryListHeadOffset,
- NULL);
- if (Status != 0) {
- goto PrintResourceArbiterEnd;
- }
- ArbiterEntryListHeadOffset /= BITS_PER_BYTE;
- Status = DbgGetMemberOffset(ArbiterType,
- "ListEntry",
- &ArbiterEntryOffset,
- NULL);
- if (Status != 0) {
- goto PrintResourceArbiterEnd;
- }
- ArbiterEntryOffset /= BITS_PER_BYTE;
- Status = DbgGetTypeByName(Context, "LIST_ENTRY", &ListEntryType);
- if (Status != 0) {
- goto PrintResourceArbiterEnd;
- }
- //
- // Print out all entries.
- //
- IndentationLevel += 1;
- ChildListHead = Address + ArbiterEntryListHeadOffset;
- Status = DbgReadIntegerMember(Context,
- ArbiterType,
- "EntryListHead.Next",
- Address,
- Data,
- DataSize,
- &CurrentEntryAddress);
- if (Status != 0) {
- goto PrintResourceArbiterEnd;
- }
- free(Data);
- Data = NULL;
- while (CurrentEntryAddress != ChildListHead) {
- //
- // Read the list entry.
- //
- assert(Data == NULL);
- Status = DbgReadType(Context,
- CurrentEntryAddress,
- ListEntryType,
- &Data,
- &DataSize);
- if (Status != 0) {
- goto PrintResourceArbiterEnd;
- }
- //
- // Print the arbiter entry.
- //
- ChildObjectAddress = CurrentEntryAddress - ArbiterEntryOffset;
- Result = ExtpPrintArbiterEntry(Context,
- ChildObjectAddress,
- IndentationLevel);
- if (Result == FALSE) {
- Status = EINVAL;
- goto PrintResourceArbiterEnd;
- }
- //
- // Move to the next entry.
- //
- Status = DbgReadIntegerMember(Context,
- ListEntryType,
- "Next",
- CurrentEntryAddress,
- Data,
- DataSize,
- &CurrentEntryAddress);
- if (Status != 0) {
- goto PrintResourceArbiterEnd;
- }
- free(Data);
- Data = NULL;
- }
- Status = 0;
- PrintResourceArbiterEnd:
- if (Data != NULL) {
- free(Data);
- }
- Result = TRUE;
- if (Status != 0) {
- Result = FALSE;
- }
- return Result;
- }
- BOOL
- ExtpPrintArbiterEntry (
- PDEBUGGER_CONTEXT Context,
- ULONGLONG Address,
- ULONG IndentationLevel
- )
- /*++
- Routine Description:
- This routine prints out an arbiter entry.
- Arguments:
- Context - Supplies a pointer to the application context.
- Address - Supplies the address of the arbiter entry to print.
- IndentationLevel - Supplies the indentation level to print the object at.
- Return Value:
- TRUE on success.
- FALSE on failure.
- --*/
- {
- PVOID Data;
- ULONG DataSize;
- PTYPE_SYMBOL EntryType;
- BOOL Result;
- PSTR SpaceType;
- INT Status;
- ULONGLONG Value;
- Data = NULL;
- //
- // Bail out if the indentation seems too deep.
- //
- if (IndentationLevel > 50) {
- return FALSE;
- }
- //
- // Print out the indentation.
- //
- DbgOut("%*s", IndentationLevel, "");
- Status = DbgReadTypeByName(Context,
- Address,
- "_ARBITER_ENTRY",
- &EntryType,
- &Data,
- &DataSize);
- if (Status != 0) {
- DbgOut("Error: Could not read entry at 0x%I64x.\n",
- Address);
- goto PrintArbiterEntryEnd;
- }
- Status = DbgReadIntegerMember(Context,
- EntryType,
- "Type",
- Address,
- Data,
- DataSize,
- &Value);
- if (Status != 0) {
- goto PrintArbiterEntryEnd;
- }
- switch (Value) {
- case ArbiterSpaceInvalid:
- SpaceType = "Invalid";
- break;
- case ArbiterSpaceFree:
- SpaceType = "Free";
- break;
- case ArbiterSpaceReserved:
- SpaceType = "Reserved";
- break;
- case ArbiterSpaceAllocated:
- SpaceType = "Allocated";
- break;
- default:
- SpaceType = "INVALID";
- break;
- }
- DbgOut("%08I64x %9s: ", Address, SpaceType);
- Status = DbgReadIntegerMember(Context,
- EntryType,
- "Allocation",
- Address,
- Data,
- DataSize,
- &Value);
- if (Status != 0) {
- goto PrintArbiterEntryEnd;
- }
- DbgOut("%08I64x, Len ", Value);
- Status = DbgReadIntegerMember(Context,
- EntryType,
- "Length",
- Address,
- Data,
- DataSize,
- &Value);
- if (Status != 0) {
- goto PrintArbiterEntryEnd;
- }
- DbgOut("%08I64x, Char ", Value);
- Status = DbgReadIntegerMember(Context,
- EntryType,
- "Characteristics",
- Address,
- Data,
- DataSize,
- &Value);
- if (Status != 0) {
- goto PrintArbiterEntryEnd;
- }
- DbgOut("%I64x, Requirement ", Value);
- Status = DbgReadIntegerMember(Context,
- EntryType,
- "CorrespondingRequirement",
- Address,
- Data,
- DataSize,
- &Value);
- if (Status != 0) {
- goto PrintArbiterEntryEnd;
- }
- DbgOut("0x%I64x, Device ", Value);
- Status = DbgReadIntegerMember(Context,
- EntryType,
- "Device",
- Address,
- Data,
- DataSize,
- &Value);
- if (Status != 0) {
- goto PrintArbiterEntryEnd;
- }
- DbgOut("0x%I64x", Value);
- Status = DbgReadIntegerMember(Context,
- EntryType,
- "DependentEntry",
- Address,
- Data,
- DataSize,
- &Value);
- if (Status != 0) {
- goto PrintArbiterEntryEnd;
- }
- if (Value != 0) {
- DbgOut(", Dependent %I64x", Value);
- }
- Status = DbgReadIntegerMember(Context,
- EntryType,
- "Flags",
- Address,
- Data,
- DataSize,
- &Value);
- if (Status != 0) {
- goto PrintArbiterEntryEnd;
- }
- if ((Value & RESOURCE_FLAG_NOT_SHAREABLE) != 0) {
- DbgOut(" NotShared");
- }
- if ((Value & RESOURCE_FLAG_BOOT) != 0) {
- DbgOut(" Boot");
- }
- DbgOut("\n");
- PrintArbiterEntryEnd:
- if (Data != NULL) {
- free(Data);
- }
- Result = TRUE;
- if (Status != 0) {
- Result = FALSE;
- }
- return Result;
- }
- PSTR
- ExtpGetResourceTypeString (
- RESOURCE_TYPE Type
- )
- /*++
- Routine Description:
- This routine returns a string representing the given resource type.
- Arguments:
- Type - Supplies the resource type.
- Return Value:
- Returns a pointer to a constant read-only string representing the given
- resource type.
- --*/
- {
- PSTR ResourceType;
- switch (Type) {
- case ResourceTypeInvalid:
- ResourceType = "Invalid";
- break;
- case ResourceTypePhysicalAddressSpace:
- ResourceType = "Physical Address";
- break;
- case ResourceTypeIoPort:
- ResourceType = "I/O Port";
- break;
- case ResourceTypeInterruptLine:
- ResourceType = "Interrupt Line";
- break;
- case ResourceTypeInterruptVector:
- ResourceType = "Interrupt Vector";
- break;
- case ResourceTypeBusNumber:
- ResourceType = "Bus Number";
- break;
- case ResourceTypeDmaChannel:
- ResourceType = "DMA Channel";
- break;
- case ResourceTypeVendorSpecific:
- ResourceType = "Vendor Specific";
- break;
- case ResourceTypeGpio:
- ResourceType = "GPIO";
- break;
- case ResourceTypeSimpleBus:
- ResourceType = "SPB";
- break;
- default:
- ResourceType = "INVALID RESOURCE TYPE";
- break;
- }
- return ResourceType;
- }
|