Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

957 lines
24 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. prefetch.h
  5. Abstract:
  6. This module contains the prefetcher definitions that are shared
  7. between the kernel mode component and the user mode service.
  8. Author:
  9. Stuart Sechrest (stuartse)
  10. Cenk Ergan (cenke)
  11. Chuck Leinzmeier (chuckl)
  12. Revision History:
  13. */
  14. #ifndef _PREFETCH_H
  15. #define _PREFETCH_H
  16. //
  17. // Prefetcher version. Be sure to update this after making any changes
  18. // to any defines or structures in this file. When in doubt, update
  19. // the version.
  20. //
  21. #define PF_CURRENT_VERSION 17
  22. //
  23. // Magic numbers to identify scenario dump files.
  24. //
  25. #define PF_SCENARIO_MAGIC_NUMBER 0x41434353
  26. #define PF_TRACE_MAGIC_NUMBER 0x43435341
  27. #define PF_SYSINFO_MAGIC_NUMBER 0x6B756843
  28. //
  29. // Define various limits used in sanity checking a prefetch scenario.
  30. // Do not use these limits except for sanity checking. Most of these are
  31. // very large values that are overkills.
  32. //
  33. #define PF_MAXIMUM_PAGES (128*1024)
  34. #define PF_MAXIMUM_LOG_ENTRIES PF_MAXIMUM_PAGES
  35. #define PF_MAXIMUM_SECTION_PAGES 8192
  36. // ISSUE-2002/02/21-ScottMa -- The following maximum is also used for
  37. // obtaining the VolumePath. Should they be the same value?
  38. #define PF_MAXIMUM_SECTION_FILE_NAME_LENGTH 1024
  39. #define PF_MAXIMUM_FILE_NAME_DATA_SIZE (4*1024*1024)
  40. #define PF_MAXIMUM_TIMER_PERIOD (-1i64 * 10 * 60 * 1000 * 1000 * 10)
  41. #define PF_MAXIMUM_ACTIVE_TRACES 4096
  42. #define PF_MAXIMUM_SAVED_TRACES 4096
  43. //
  44. // This is the maximum size a scenario can grow to.
  45. //
  46. #define PF_MAXIMUM_SCENARIO_SIZE (16*1024*1024)
  47. //
  48. // This is the maximum size a trace file can grow to. It is a function
  49. // of the limits above.
  50. //
  51. #define PF_MAXIMUM_TRACE_SIZE PF_MAXIMUM_SCENARIO_SIZE
  52. //
  53. // Maximum allowed sections in a scenario should fit into a USHORT,
  54. // sizeof the SectionId field in log entries.
  55. //
  56. #define PF_MAXIMUM_SECTIONS 16384
  57. //
  58. // Maximum number of unique directories the files for a scenario can
  59. // be in. This is a sanity check constant.
  60. //
  61. #define PF_MAXIMUM_DIRECTORIES (PF_MAXIMUM_SECTIONS * 32)
  62. //
  63. // Minimum size in pages for new scenarios. Smaller traces will be discarded.
  64. //
  65. #define PF_MIN_SCENARIO_PAGES 32
  66. //
  67. // Define various types of prefetch scenarios (starting from 0).
  68. //
  69. typedef enum _PF_SCENARIO_TYPE {
  70. PfApplicationLaunchScenarioType,
  71. PfSystemBootScenarioType,
  72. PfMaxScenarioType,
  73. } PF_SCENARIO_TYPE;
  74. //
  75. // Define structure used to identify traces and prefetch instructions
  76. // for a scenario. For application launch scenarios, it consists of
  77. // the first characters in the executable image's name (NUL
  78. // terminated) and a hash of its full path including the image
  79. // name. Both path and image name are uppercased. On a file system
  80. // with case sensitive names executables at the same path with the
  81. // same name except for case will get the same id.
  82. //
  83. #define PF_SCEN_ID_MAX_CHARS 29
  84. typedef struct _PF_SCENARIO_ID {
  85. WCHAR ScenName[PF_SCEN_ID_MAX_CHARS + 1];
  86. ULONG HashId;
  87. } PF_SCENARIO_ID, *PPF_SCENARIO_ID;
  88. //
  89. // This is the scenario name and hash code value for the boot scenario.
  90. //
  91. #define PF_BOOT_SCENARIO_NAME L"NTOSBOOT"
  92. #define PF_BOOT_SCENARIO_HASHID 0xB00DFAAD
  93. //
  94. // Extension for the prefetch files.
  95. //
  96. #define PF_PREFETCH_FILE_EXTENSION L"pf"
  97. //
  98. // A scenario id can be converted to a file name using the following
  99. // sprintf format, using ScenName, HashId and prefetch file extension.
  100. //
  101. #define PF_SCEN_FILE_NAME_FORMAT L"%ws-%08X.%ws"
  102. //
  103. // This is the maximum number of characters in a scenario file name
  104. // (not path) given the format and definitions above with some head
  105. // room.
  106. //
  107. #define PF_MAX_SCENARIO_FILE_NAME 50
  108. //
  109. // Define the number of periods over which we track page faults for a
  110. // scenario. The duration of the periods depend on the scenario type.
  111. //
  112. #define PF_MAX_NUM_TRACE_PERIODS 10
  113. //
  114. // Define maximum number of characters for the relative path from
  115. // system root to where prefetch files can be found.
  116. //
  117. #define PF_MAX_PREFETCH_ROOT_PATH 32
  118. //
  119. // Define maximum number of characters for the list of known hosting
  120. // applications.
  121. //
  122. #define PF_HOSTING_APP_LIST_MAX_CHARS 128
  123. //
  124. // Define invalid page index used to terminate a section's page record
  125. // lists in scenarios.
  126. //
  127. #define PF_INVALID_PAGE_IDX (-1)
  128. //
  129. // Define the number of launches of the scenario we keep track of for
  130. // usage history of pages. In every page record there is a bit field
  131. // of this size. Do not grow this over 32, size of (ULONG).
  132. //
  133. #define PF_PAGE_HISTORY_SIZE 8
  134. //
  135. // Define the maximum and minimum scenario sensitivity. A page has to be
  136. // used in this many of the launches in the history for it to be prefetch.
  137. //
  138. #define PF_MAX_SENSITIVITY PF_PAGE_HISTORY_SIZE
  139. #define PF_MIN_SENSITIVITY 1
  140. //
  141. // Define structure for kernel trace dumps. The dump is all in a
  142. // single contiguous buffer at the top of which is the trace header
  143. // structure. The trace header contains offsets to an array of log
  144. // entries in the buffer and to a list of section info
  145. // structures. Section info structures come one after the other
  146. // containing file names. There is a log entry for every page
  147. // fault. Every log entry has a SectionId that is the number of the
  148. // section info structure that contains the name of the file the fault
  149. // was to. These are followed by variable sized volumeinfo entries
  150. // that describe the volumes on which the sections in the trace are
  151. // located.
  152. //
  153. //
  154. // NOTE: Do not forget about alignment issues on 64 bit platforms as
  155. // you modify these structures or add new ones.
  156. //
  157. //
  158. // One of these is logged for every page fault.
  159. //
  160. typedef struct _PF_LOG_ENTRY {
  161. //
  162. // File offset of the page that was faulted.
  163. //
  164. ULONG FileOffset;
  165. //
  166. // Index into the section info table in the trace header that helps
  167. // us identify the file.
  168. //
  169. USHORT SectionId;
  170. //
  171. // Whether this page was faulted as an image page or data page.
  172. //
  173. BOOLEAN IsImage;
  174. //
  175. // Whether this is a fault that happened in the process in which
  176. // the scenario is active. We may log faults in special system
  177. // process as a part of this scenario.
  178. //
  179. // FUTURE-2002/02/21-ScottMa -- This field is never set in the kernel.
  180. BOOLEAN InProcess;
  181. } PF_LOG_ENTRY, *PPF_LOG_ENTRY;
  182. //
  183. // This structure associates a page fault with a file name.
  184. // Note that because we lay these structures right after each other in
  185. // the trace buffer, if you add a new field which has an alignment
  186. // greater than 2 bytes, we'll hit alignment problems.
  187. //
  188. typedef struct _PF_SECTION_INFO {
  189. //
  190. // Number of characters in the file name, excluding terminating NUL.
  191. //
  192. USHORT FileNameLength;
  193. //
  194. // Whether this section is for filesystem metafile (e.g. directory.)
  195. //
  196. USHORT Metafile:1;
  197. USHORT Unused:15;
  198. //
  199. // Variable length file name buffer including terminating NUL.
  200. //
  201. WCHAR FileName[1];
  202. } PF_SECTION_INFO, *PPF_SECTION_INFO;
  203. //
  204. // This structure describes a volume on which the sections in the
  205. // trace are on.
  206. //
  207. typedef struct _PF_VOLUME_INFO {
  208. //
  209. // Volume creation time and serial number used to identify the
  210. // volume in case its NT/device path e.g. \Device\HarddiskVolume1
  211. // changes.
  212. //
  213. LARGE_INTEGER CreationTime;
  214. ULONG SerialNumber;
  215. //
  216. // Current NT/device path for the volume and its length in
  217. // characters excluding terminating NUL.
  218. //
  219. ULONG VolumePathLength;
  220. WCHAR VolumePath[1];
  221. } PF_VOLUME_INFO, *PPF_VOLUME_INFO;
  222. //
  223. // This is the trace header.
  224. //
  225. typedef struct _PF_TRACE_HEADER {
  226. //
  227. // Prefetcher version.
  228. //
  229. ULONG Version;
  230. //
  231. // Magic number identifying this as a trace.
  232. //
  233. ULONG MagicNumber;
  234. //
  235. // Total size of the trace buffer in bytes.
  236. //
  237. ULONG Size;
  238. //
  239. // Scenario id for which this trace was acquired.
  240. //
  241. PF_SCENARIO_ID ScenarioId;
  242. //
  243. // Type of this scenario.
  244. //
  245. PF_SCENARIO_TYPE ScenarioType;
  246. // FUTURE-2002/02/20-ScottMa -- Consider reordering the following two
  247. // groups of fields to better reflect the in-memory structure of the
  248. // trace. Sections should appear first, followed by Entries, then
  249. // followed by Volumes.
  250. //
  251. // Offset from the start of the trace buffer where logged
  252. // entries can be found and the number of them.
  253. //
  254. ULONG TraceBufferOffset;
  255. ULONG NumEntries;
  256. //
  257. // Offset from the start of the trace buffer where the section and
  258. // file name information is located.
  259. //
  260. ULONG SectionInfoOffset;
  261. ULONG NumSections;
  262. //
  263. // Offset from the start of the trace buffer where the volume
  264. // information is located, the number of volumes and the total
  265. // size of the volume information block.
  266. //
  267. ULONG VolumeInfoOffset;
  268. ULONG NumVolumes;
  269. ULONG VolumeInfoSize;
  270. //
  271. // Distribution of the pagefaults over the duration of the trace.
  272. // PeriodLength is in 100ns.
  273. //
  274. LONGLONG PeriodLength;
  275. ULONG FaultsPerPeriod[PF_MAX_NUM_TRACE_PERIODS];
  276. //
  277. // System time when we started tracing this scenario as
  278. // returned by KeQuerySystemTime.
  279. //
  280. LARGE_INTEGER LaunchTime;
  281. } PF_TRACE_HEADER, *PPF_TRACE_HEADER;
  282. //
  283. // Define structure for prefetch scenario instructions. The
  284. // instructions are all in a single contiguous buffer at the top of
  285. // which is the scenario header structure. The header contains offsets
  286. // to arrays of section and page records as well as a file name data
  287. // buffer. Every section contains an offset into the file name data
  288. // buffer where the file name for that section is located. It also has
  289. // an index into the page record table where the first page for that
  290. // section is located. Subsequent pages of the section are linked
  291. // through indices embedded in the page records.
  292. //
  293. // This data is followed by the file system metadata prefetch
  294. // instructions so opening the files will not be as expensive. These
  295. // instructions consist of metadata records that describe the metadata
  296. // that needs to be prefetched on the volumes containing the files to
  297. // be prefetched.
  298. //
  299. //
  300. // NOTE: Do not forget about alignment issues on 64 bit platforms as
  301. // you modify these structures or add new ones.
  302. //
  303. //
  304. // Define structure used for describing pages to be prefetched.
  305. //
  306. typedef struct _PF_PAGE_RECORD {
  307. //
  308. // Index of the next page for this section in the page record
  309. // table or PF_INVALID_PAGE_IDX to terminate the list.
  310. //
  311. LONG NextPageIdx;
  312. //
  313. // File offset of the page that was faulted.
  314. //
  315. ULONG FileOffset;
  316. //
  317. // Whether we should just ignore this page record.
  318. //
  319. ULONG IsIgnore:1;
  320. //
  321. // Whether this page was faulted as an image page.
  322. //
  323. ULONG IsImage:1;
  324. //
  325. // Whether this page was faulted as a data page.
  326. //
  327. ULONG IsData:1;
  328. //
  329. // The following fields are only used by the service:
  330. //
  331. //
  332. // Whether this page was used in the last PF_PAGE_HISTORY_SIZE
  333. // launches of the scenario. The least significant bit stands for
  334. // the most recent launch. If a bit is on, it means the page was
  335. // used in that launch.
  336. //
  337. ULONG UsageHistory:PF_PAGE_HISTORY_SIZE;
  338. //
  339. // Whether this page was prefetched in the last PF_PAGE_HISTORY_SIZE
  340. // launches of the scenario. The least significant bit stands for
  341. // the most recent launch. If a bit is on, it means the page was
  342. // prefetched in that launch.
  343. //
  344. ULONG PrefetchHistory:PF_PAGE_HISTORY_SIZE;
  345. } PF_PAGE_RECORD, *PPF_PAGE_RECORD;
  346. //
  347. // Define structure used for describing sections to prefetch from.
  348. //
  349. typedef struct _PF_SECTION_RECORD {
  350. //
  351. // Index of the first page for this section in the page record
  352. // table or PF_INVALID_PAGE_IDX to terminate the list. That page
  353. // will contain the index for the next page etc.
  354. //
  355. LONG FirstPageIdx;
  356. //
  357. // Total number of page records for this section.
  358. //
  359. ULONG NumPages;
  360. //
  361. // Byte offset relative to the beginning of the file name data
  362. // block where the file path for this section can be found, and
  363. // the number of characters in the file path excluding NUL.
  364. //
  365. ULONG FileNameOffset;
  366. ULONG FileNameLength;
  367. //
  368. // Do we just ignore this section record.
  369. //
  370. ULONG IsIgnore:1;
  371. //
  372. // Was this section accessed through an image mapping.
  373. //
  374. ULONG IsImage:1;
  375. //
  376. // Was this section accessed through a data mapping.
  377. //
  378. ULONG IsData:1;
  379. } PF_SECTION_RECORD, *PPF_SECTION_RECORD;
  380. //
  381. // Define a counted string structure. It can be used to put paths one
  382. // after the other in the scenario/trace file. Its count coming before
  383. // the string would help us verify that the strings are terminated and
  384. // within bounds. The string is still NUL terminated.
  385. //
  386. typedef struct _PF_COUNTED_STRING {
  387. //
  388. // Number of characters excluding the terminating NUL. Making this
  389. // a USHORT helps alignment when stacking counted strings one
  390. // after the other.
  391. //
  392. USHORT Length;
  393. //
  394. // The NUL terminated string.
  395. //
  396. WCHAR String[1];
  397. } PF_COUNTED_STRING, *PPF_COUNTED_STRING;
  398. //
  399. // Define structure used for describing the filesystem metadata that
  400. // should be prefetched before prefetching the scenario.
  401. //
  402. typedef struct _PF_METADATA_RECORD {
  403. //
  404. // Byte offset relative to the beginning of metadata prefetch info
  405. // for the NUL terminated volume name on which the metadata to
  406. // prefetch resides. VolumeNameLength is in characters excluding
  407. // the terminating NUL.
  408. //
  409. ULONG VolumeNameOffset;
  410. ULONG VolumeNameLength;
  411. //
  412. // In case volume's NT/device path changes, these magics are used
  413. // to identify the volume.
  414. //
  415. LARGE_INTEGER CreationTime;
  416. ULONG SerialNumber;
  417. //
  418. // Byte offset relative to the beginning of metadata prefetch info
  419. // for the input buffer to FSCTL to prefetch the metadata and its size.
  420. //
  421. ULONG FilePrefetchInfoOffset;
  422. ULONG FilePrefetchInfoSize;
  423. //
  424. // Byte offset relative to the beginning of metadata prefetch info
  425. // for the full paths of directories (PF_COUNTED_STRING's) that
  426. // need to be prefetched on this volume. The paths come one after
  427. // the other in the buffer.
  428. //
  429. ULONG DirectoryPathsOffset;
  430. ULONG NumDirectories;
  431. } PF_METADATA_RECORD, *PPF_METADATA_RECORD;
  432. //
  433. // This is the scenario header.
  434. //
  435. typedef struct _PF_SCENARIO_HEADER {
  436. //
  437. // Prefetcher version.
  438. //
  439. ULONG Version;
  440. //
  441. // Magic number identifying this as a scenario.
  442. //
  443. ULONG MagicNumber;
  444. //
  445. // This is the version of the prefetcher maintenance service that
  446. // generated this file.
  447. //
  448. ULONG ServiceVersion;
  449. //
  450. // Total size of the scenario.
  451. //
  452. ULONG Size;
  453. //
  454. // Scenario id identifying the scenario.
  455. //
  456. PF_SCENARIO_ID ScenarioId;
  457. //
  458. // Type of this scenario.
  459. //
  460. PF_SCENARIO_TYPE ScenarioType;
  461. //
  462. // Offset from the start of the scenario buffer where the section
  463. // info table is located.
  464. //
  465. ULONG SectionInfoOffset;
  466. ULONG NumSections;
  467. //
  468. // Offset from the start of the scenario buffer where the page
  469. // records are located.
  470. //
  471. ULONG PageInfoOffset;
  472. ULONG NumPages;
  473. //
  474. // Offset from the start of the scenario buffer where file names
  475. // are located.
  476. //
  477. ULONG FileNameInfoOffset;
  478. ULONG FileNameInfoSize;
  479. //
  480. // Offset from the start of the scenario buffer where file system
  481. // metadata prefetch record table is located, number of these
  482. // structures and the size of the whole metadata prefetch
  483. // information.
  484. //
  485. ULONG MetadataInfoOffset;
  486. ULONG NumMetadataRecords;
  487. ULONG MetadataInfoSize;
  488. //
  489. // The following three fields are used to determine if a scenario
  490. // is getting launched too frequently (e.g. multiple times a
  491. // second/minute) for prefetching to be useful.
  492. //
  493. //
  494. // This is the KeQuerySystemTime time of the last launch of this
  495. // scenario for which these scenario instructions were updated.
  496. //
  497. LARGE_INTEGER LastLaunchTime;
  498. //
  499. // If this much time (in 100ns) has not passed since last launch
  500. // time, we should not prefetch this scenario.
  501. //
  502. LARGE_INTEGER MinRePrefetchTime;
  503. //
  504. // If this much time (in 100ns) has not passed since last launch
  505. // time, we should not trace this scenario.
  506. //
  507. LARGE_INTEGER MinReTraceTime;
  508. //
  509. // The following fields are used only by the service:
  510. //
  511. //
  512. // Number of times this scenario has been launched.
  513. //
  514. ULONG NumLaunches;
  515. //
  516. // A page should be used at least this many times in the last
  517. // PF_PAGE_HISTORY_SIZE launches to be prefetched. Otherwise the
  518. // ignore bit on the page is set. The kernel does not have look at
  519. // this variable. The sensitivity is adjusted dynamically by the
  520. // service according to the hit rate of the prefetched pages.
  521. //
  522. ULONG Sensitivity;
  523. } PF_SCENARIO_HEADER, *PPF_SCENARIO_HEADER;
  524. //
  525. // Definitions for the interface between the kernel and the service.
  526. //
  527. //
  528. // This is the name of the event that will be signaled by the kernel
  529. // when there are new scenario traces for the service.
  530. //
  531. #define PF_COMPLETED_TRACES_EVENT_NAME L"\\BaseNamedObjects\\PrefetchTracesReady"
  532. #define PF_COMPLETED_TRACES_EVENT_WIN32_NAME L"PrefetchTracesReady"
  533. //
  534. // This is the name of the event that gets signaled by the kernel when
  535. // parameters have changed.
  536. //
  537. #define PF_PARAMETERS_CHANGED_EVENT_NAME L"\\BaseNamedObjects\\PrefetchParametersChanged"
  538. #define PF_PARAMETERS_CHANGED_EVENT_WIN32_NAME L"PrefetchParametersChanged"
  539. //
  540. // Define sub information classes for SystemPrefetcherInformation.
  541. //
  542. typedef enum _PREFETCHER_INFORMATION_CLASS {
  543. PrefetcherRetrieveTrace = 1,
  544. PrefetcherSystemParameters,
  545. PrefetcherBootPhase,
  546. } PREFETCHER_INFORMATION_CLASS;
  547. //
  548. // This is the input structure to NtQuerySystemInformation /
  549. // NtSetSystemInformation for the SystemPrefetcherInformation
  550. // information class.
  551. //
  552. typedef struct _PREFETCHER_INFORMATION {
  553. //
  554. // These two fields help make sure caller does not make bogus
  555. // requests and keep track of version for this kernel interface.
  556. //
  557. ULONG Version;
  558. ULONG Magic;
  559. //
  560. // Sub information class.
  561. //
  562. PREFETCHER_INFORMATION_CLASS PrefetcherInformationClass;
  563. //
  564. // Input / Output buffer and its length.
  565. //
  566. PVOID PrefetcherInformation;
  567. ULONG PrefetcherInformationLength;
  568. } PREFETCHER_INFORMATION, *PPREFETCHER_INFORMATION;
  569. //
  570. // Define boot phase id's for use with PrefetcherBootPhase information
  571. // subclass.
  572. //
  573. typedef enum _PF_BOOT_PHASE_ID {
  574. PfKernelInitPhase = 0,
  575. PfBootDriverInitPhase = 90,
  576. PfSystemDriverInitPhase = 120,
  577. PfSessionManagerInitPhase = 150,
  578. PfSMRegistryInitPhase = 180,
  579. PfVideoInitPhase = 210,
  580. PfPostVideoInitPhase = 240,
  581. PfBootAcceptedRegistryInitPhase = 270,
  582. PfUserShellReadyPhase = 300,
  583. PfMaxBootPhaseId = 900,
  584. } PF_BOOT_PHASE_ID, *PPF_BOOT_PHASE_ID;
  585. //
  586. // Define system wide prefetch parameters structure.
  587. //
  588. //
  589. // Whether a particular type of prefetching is enabled, disabled or
  590. // just not specified.
  591. //
  592. typedef enum _PF_ENABLE_STATUS {
  593. PfSvNotSpecified,
  594. PfSvEnabled,
  595. PfSvDisabled,
  596. PfSvMaxEnableStatus
  597. } PF_ENABLE_STATUS, *PPF_ENABLE_STATUS;
  598. //
  599. // Define limits structure for different prefetch types.
  600. //
  601. typedef struct _PF_TRACE_LIMITS {
  602. //
  603. // Maximum number of pages that can be logged.
  604. //
  605. ULONG MaxNumPages;
  606. //
  607. // Maximum number of sections that can be logged.
  608. //
  609. ULONG MaxNumSections;
  610. //
  611. // Period for the trace timer. The trace times out after
  612. // PF_MAX_NUM_TRACE_PERIODS. This is in 100ns. It should be
  613. // negative denoting to the system that periods are relative.
  614. //
  615. LONGLONG TimerPeriod;
  616. } PF_TRACE_LIMITS, *PPF_TRACE_LIMITS;
  617. //
  618. // System wide prefetch parameters structure.
  619. //
  620. typedef struct _PF_SYSTEM_PREFETCH_PARAMETERS {
  621. //
  622. // Whether different types of prefetching are enabled or not.
  623. //
  624. PF_ENABLE_STATUS EnableStatus[PfMaxScenarioType];
  625. //
  626. // Limits for different prefetch types.
  627. //
  628. PF_TRACE_LIMITS TraceLimits[PfMaxScenarioType];
  629. //
  630. // Maximum number of active prefetch traces.
  631. //
  632. ULONG MaxNumActiveTraces;
  633. //
  634. // Maximum number of saved completed prefetch traces.
  635. // Note that this should be greater than the number of boot phases,
  636. // since the service won't be started until later in boot.
  637. //
  638. // ISSUE-2002/02/20-ScottMa -- The default value for this parameter is 8,
  639. // but there appear to be 9 boot phases. Should the default be raised?
  640. ULONG MaxNumSavedTraces;
  641. //
  642. // Path to directory relative to system root where prefetch
  643. // instructions can be found.
  644. //
  645. WCHAR RootDirPath[PF_MAX_PREFETCH_ROOT_PATH];
  646. // ISSUE-2002/02/21-ScottMa -- The comment below should indicate that the
  647. // hosting applications string must be UPCASEd and there should not be
  648. // spaces after each comma.
  649. //
  650. // Comma seperated list of hosting applications (e.g. dllhost.exe, mmc.exe,
  651. // rundll32.exe ...) for which we create scenario ID's based on command line
  652. // as well.
  653. //
  654. WCHAR HostingApplicationList[PF_HOSTING_APP_LIST_MAX_CHARS];
  655. } PF_SYSTEM_PREFETCH_PARAMETERS, *PPF_SYSTEM_PREFETCH_PARAMETERS;
  656. //
  657. // Useful macros.
  658. //
  659. //
  660. // Macros for alignment. Assumptions are that alignments are a power
  661. // of 2 and allocators (malloc, heap, pool etc) allocate chunks with
  662. // bigger alignment than what you need. You should verify these by
  663. // using asserts and the "power of two" macro below.
  664. //
  665. //
  666. // Determines whether the value is a power of two. Zero is not a power
  667. // of 2. The value should be of an unsigned type that supports bit
  668. // operations, e.g. not a pointer.
  669. //
  670. #define PF_IS_POWER_OF_TWO(Value) \
  671. ((Value) && !((Value) & (Value - 1)))
  672. //
  673. // Return value is the Pointer increased to be aligned with
  674. // Alignment. Alignment must be a power of 2.
  675. //
  676. #define PF_ALIGN_UP(Pointer, Alignment) \
  677. ((PVOID)(((ULONG_PTR)(Pointer) + (Alignment) - 1) & (~((ULONG_PTR)(Alignment) - 1))))
  678. //
  679. // Verification code shared with the kernel mode component. This code
  680. // has to be kept in sync copy & paste.
  681. //
  682. BOOLEAN
  683. PfWithinBounds(
  684. PVOID Pointer,
  685. PVOID Base,
  686. ULONG Length
  687. );
  688. BOOLEAN
  689. PfVerifyScenarioId (
  690. PPF_SCENARIO_ID ScenarioId
  691. );
  692. BOOLEAN
  693. PfVerifyScenarioBuffer(
  694. PPF_SCENARIO_HEADER Scenario,
  695. ULONG BufferSize,
  696. PULONG FailedCheck
  697. );
  698. BOOLEAN
  699. PfVerifyTraceBuffer(
  700. PPF_TRACE_HEADER Trace,
  701. ULONG BufferSize,
  702. PULONG FailedCheck
  703. );
  704. #endif // _PREFETCH_H