Source code of Windows XP (NT5)
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.

1674 lines
52 KiB

  1. #include <windows.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <wtypes.h>
  5. #include <cfgmgr32.h>
  6. #include <malloc.h>
  7. #include "cmtest.h"
  8. VOID
  9. SpecialCase_LogConf(
  10. DEVNODE dnDevNode
  11. );
  12. //-----------------------------------------------------------------------------
  13. VOID
  14. RegressionTest_LogConf(
  15. HWND hDlg
  16. )
  17. {
  18. CONFIGRET Status;
  19. TCHAR szMsg[MAX_PATH], szMsg1[MAX_PATH];
  20. DEVNODE dnDevNode;
  21. LOG_CONF TempLC, BootLC1, BootLC2, BootLC3;
  22. LOG_CONF BasicLC1, BasicLC2, BasicLC3;
  23. RES_DES ResDes, ResDes1, ResDes2, ResDes3;
  24. PCS_DES pResourceData;
  25. ULONG ulSize = 0;
  26. BYTE i;
  27. PMEM_RESOURCE pMemRes = NULL;
  28. PIO_RESOURCE pIoRes = NULL;
  29. PCS_RESOURCE pCs1Res = NULL, pCs2Res = NULL;
  30. PIRQ_RESOURCE pIrqRes = NULL;
  31. PDMA_RESOURCE pDmaRes = NULL;
  32. BYTE LegacyData[512];
  33. RESOURCEID ResType;
  34. LPBYTE pBuffer = NULL, pData = NULL;
  35. PRIORITY Priority = 0;
  36. //
  37. // free, free handle, modify, get size, get data
  38. //
  39. SendDlgItemMessage(
  40. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  41. (LPARAM)TEXT("____LOGCONF-RESDES REGRESSION TEST_____"));
  42. SendDlgItemMessage(
  43. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  44. (LPARAM)TEXT("Testing Device ID: Root\\Device001\\0000"));
  45. Status = CM_Locate_DevNode(&dnDevNode, TEXT("Root\\Device001\\0000"), 0);
  46. if (Status != CR_SUCCESS) {
  47. wsprintf(szMsg, TEXT("CM_Locate_DevNode Failed (%xh)"), Status);
  48. SendDlgItemMessage(
  49. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  50. (LPARAM)(LPTSTR)szMsg);
  51. return;
  52. }
  53. SpecialCase_LogConf(dnDevNode);
  54. return;
  55. //------------------------------------------------------
  56. // Add/Get Boot Configs
  57. //------------------------------------------------------
  58. lstrcpy(szMsg, TEXT("Test empty boot 1 config: "));
  59. Status = CM_Add_Empty_Log_Conf(&BootLC1, dnDevNode, LCPRI_BOOTCONFIG,
  60. BOOT_LOG_CONF | PRIORITY_EQUAL_FIRST);
  61. if (Status != CR_SUCCESS) {
  62. wsprintf(szMsg1, TEXT("CM_Add_Empty_Log_Conf Failed (%xh)"), Status);
  63. }
  64. else wsprintf(szMsg1, TEXT("Passed"));
  65. lstrcat(szMsg, szMsg1);
  66. SendDlgItemMessage(
  67. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  68. (LPARAM)(LPTSTR)szMsg);
  69. lstrcpy(szMsg, TEXT("Test add empty boot 2 config: "));
  70. Status = CM_Add_Empty_Log_Conf(&BootLC2, dnDevNode, LCPRI_BOOTCONFIG,
  71. BOOT_LOG_CONF | PRIORITY_EQUAL_FIRST);
  72. if (Status != CR_SUCCESS) {
  73. wsprintf(szMsg1, TEXT("CM_Add_Empty_Log_Conf Failed (%xh)"), Status);
  74. }
  75. else wsprintf(szMsg1, TEXT("Passed"));
  76. lstrcat(szMsg, szMsg1);
  77. SendDlgItemMessage(
  78. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  79. (LPARAM)(LPTSTR)szMsg);
  80. Status = CM_Free_Log_Conf_Handle(BootLC1);
  81. Status = CM_Free_Log_Conf_Handle(BootLC2);
  82. lstrcpy(szMsg, TEXT("Test get first boot config: "));
  83. Status = CM_Get_First_Log_Conf(&BootLC1, dnDevNode, BOOT_LOG_CONF);
  84. if (Status != CR_SUCCESS) {
  85. wsprintf(szMsg1, TEXT("CM_Get_First_Log_Conf Failed (%xh)"), Status);
  86. }
  87. else wsprintf(szMsg1, TEXT("Passed"));
  88. lstrcat(szMsg, szMsg1);
  89. SendDlgItemMessage(
  90. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  91. (LPARAM)(LPTSTR)szMsg);
  92. lstrcpy(szMsg, TEXT("Test get next boot config: "));
  93. Status = CM_Get_Next_Log_Conf(&BootLC2, BootLC1, 0);
  94. if (Status != CR_SUCCESS) {
  95. wsprintf(szMsg1, TEXT("Failed (%xh)"), Status);
  96. }
  97. else wsprintf(szMsg1, TEXT("Passed"));
  98. lstrcat(szMsg, szMsg1);
  99. SendDlgItemMessage(
  100. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  101. (LPARAM)(LPTSTR)szMsg);
  102. lstrcpy(szMsg, TEXT("Test get next (nonexistent) boot config: "));
  103. Status = CM_Get_Next_Log_Conf(&TempLC, BootLC2, 0);
  104. if (Status != CR_NO_MORE_LOG_CONF) {
  105. wsprintf(szMsg1, TEXT("Failed (%xh)"), Status);
  106. }
  107. else wsprintf(szMsg1, TEXT("Passed"));
  108. lstrcat(szMsg, szMsg1);
  109. SendDlgItemMessage(
  110. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  111. (LPARAM)(LPTSTR)szMsg);
  112. lstrcpy(szMsg, TEXT("Test get priority of boot config: "));
  113. Status = CM_Get_Log_Conf_Priority(BootLC1, &Priority, 0);
  114. if (Status != CR_INVALID_LOG_CONF) {
  115. wsprintf(szMsg1, TEXT("Passed, should have failed! (%d)\n"), Status);
  116. } else {
  117. wsprintf(szMsg1, TEXT("Failed as expected (%d)\n"), Status);
  118. }
  119. lstrcat(szMsg, szMsg1);
  120. SendDlgItemMessage(
  121. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  122. (LPARAM)(LPTSTR)szMsg);
  123. //------------------------------------------------------
  124. // Add/Get Basic Configs
  125. //------------------------------------------------------
  126. lstrcpy(szMsg, TEXT("Test empty basic 1 config: "));
  127. Status = CM_Add_Empty_Log_Conf(&BasicLC1, dnDevNode, LCPRI_NORMAL,
  128. BASIC_LOG_CONF | PRIORITY_EQUAL_FIRST);
  129. if (Status != CR_SUCCESS) {
  130. wsprintf(szMsg1, TEXT("CM_Add_Empty_Log_Conf Failed (%xh)"), Status);
  131. }
  132. else wsprintf(szMsg1, TEXT("Passed"));
  133. lstrcat(szMsg, szMsg1);
  134. SendDlgItemMessage(
  135. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  136. (LPARAM)(LPTSTR)szMsg);
  137. lstrcpy(szMsg, TEXT("Test add empty basic 2 config: "));
  138. Status = CM_Add_Empty_Log_Conf(&BasicLC2, dnDevNode, LCPRI_NORMAL,
  139. BASIC_LOG_CONF | PRIORITY_EQUAL_FIRST);
  140. if (Status != CR_SUCCESS) {
  141. wsprintf(szMsg1, TEXT("CM_Add_Empty_Log_Conf Failed (%xh)"), Status);
  142. }
  143. else wsprintf(szMsg1, TEXT("Passed"));
  144. lstrcat(szMsg, szMsg1);
  145. SendDlgItemMessage(
  146. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  147. (LPARAM)(LPTSTR)szMsg);
  148. Status = CM_Free_Log_Conf_Handle(BasicLC1);
  149. Status = CM_Free_Log_Conf_Handle(BasicLC2);
  150. lstrcpy(szMsg, TEXT("Test get first basic config: "));
  151. Status = CM_Get_First_Log_Conf(&BasicLC1, dnDevNode, BASIC_LOG_CONF);
  152. if (Status != CR_SUCCESS) {
  153. wsprintf(szMsg1, TEXT("CM_Get_First_Log_Conf Failed (%xh)"), Status);
  154. }
  155. else wsprintf(szMsg1, TEXT("Passed"));
  156. lstrcat(szMsg, szMsg1);
  157. SendDlgItemMessage(
  158. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  159. (LPARAM)(LPTSTR)szMsg);
  160. lstrcpy(szMsg, TEXT("Test get next basic config: "));
  161. Status = CM_Get_Next_Log_Conf(&BasicLC2, BasicLC1, 0);
  162. if (Status != CR_SUCCESS) {
  163. wsprintf(szMsg1, TEXT("Failed (%xh)"), Status);
  164. }
  165. else wsprintf(szMsg1, TEXT("Passed"));
  166. lstrcat(szMsg, szMsg1);
  167. SendDlgItemMessage(
  168. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  169. (LPARAM)(LPTSTR)szMsg);
  170. lstrcpy(szMsg, TEXT("Test get next (nonexistent) basic config: "));
  171. Status = CM_Get_Next_Log_Conf(&TempLC, BasicLC3, 0);
  172. if (Status != CR_NO_MORE_LOG_CONF) {
  173. wsprintf(szMsg1, TEXT("Failed (%xh)"), Status);
  174. }
  175. else wsprintf(szMsg1, TEXT("Passed"));
  176. lstrcat(szMsg, szMsg1);
  177. SendDlgItemMessage(
  178. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  179. (LPARAM)(LPTSTR)szMsg);
  180. lstrcpy(szMsg, TEXT("Test get priority of basic config: "));
  181. Status = CM_Get_Log_Conf_Priority(BasicLC2, &Priority, 0);
  182. if (Status == CR_SUCCESS) {
  183. if (Priority == LCPRI_NORMAL) {
  184. wsprintf(szMsg1, TEXT("Passed\n"));
  185. } else {
  186. wsprintf(szMsg1, TEXT("Failed, priority should be %x (%x)\n"), LCPRI_NORMAL, Priority);
  187. }
  188. } else {
  189. wsprintf(szMsg1, TEXT("Failed (%d)\n"), Status);
  190. }
  191. lstrcat(szMsg, szMsg1);
  192. SendDlgItemMessage(
  193. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  194. (LPARAM)(LPTSTR)szMsg);
  195. //----------------------------------------------------------
  196. // Test adding res des 's
  197. //----------------------------------------------------------
  198. lstrcpy(szMsg, TEXT("Test add MEMORY res des to LC1: "));
  199. pMemRes = malloc(sizeof(MEM_RESOURCE) + sizeof(MEM_RANGE));
  200. pMemRes->MEM_Header.MD_Count = 2;
  201. pMemRes->MEM_Header.MD_Type = MType_Range;
  202. pMemRes->MEM_Header.MD_Alloc_Base = (DWORDLONG)0xD8000;
  203. pMemRes->MEM_Header.MD_Alloc_End = (DWORDLONG)0xD9000;
  204. pMemRes->MEM_Header.MD_Flags = fMD_ROM | fMD_32 | fMD_ReadAllowed;
  205. pMemRes->MEM_Header.MD_Reserved = 0;
  206. pMemRes->MEM_Data[0].MR_Align = 8; //?
  207. pMemRes->MEM_Data[0].MR_nBytes = 4096;
  208. pMemRes->MEM_Data[0].MR_Min = (DWORDLONG)0xD8000;
  209. pMemRes->MEM_Data[0].MR_Max = (DWORDLONG)0xDC000;
  210. pMemRes->MEM_Data[0].MR_Flags = fMD_ROM | fMD_32 | fMD_ReadAllowed;
  211. pMemRes->MEM_Data[0].MR_Reserved = 0;
  212. pMemRes->MEM_Data[1].MR_Align = 8; //?
  213. pMemRes->MEM_Data[1].MR_nBytes = 4096;
  214. pMemRes->MEM_Data[1].MR_Min = (DWORDLONG)0xE0000;
  215. pMemRes->MEM_Data[1].MR_Max = (DWORDLONG)0xE4000;
  216. pMemRes->MEM_Data[1].MR_Flags = fMD_ROM | fMD_32 | fMD_ReadAllowed;
  217. pMemRes->MEM_Data[1].MR_Reserved = 0;
  218. Status = CM_Add_Res_Des(&ResDes, BootLC1, ResType_Mem, pMemRes,
  219. sizeof(MEM_RESOURCE) + sizeof(MEM_RANGE), 0);
  220. if (Status != CR_SUCCESS) {
  221. wsprintf(szMsg1, TEXT("Failed (%xh)"), Status);
  222. }
  223. else wsprintf(szMsg1, TEXT("Passed"));
  224. lstrcat(szMsg, szMsg1);
  225. SendDlgItemMessage(
  226. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  227. (LPARAM)(LPTSTR)szMsg);
  228. Status = CM_Add_Res_Des(&ResDes, BasicLC1, ResType_Mem, pMemRes,
  229. sizeof(MEM_RESOURCE) + sizeof(MEM_RANGE), 0);
  230. if (Status != CR_SUCCESS) {
  231. wsprintf(szMsg1, TEXT("Failed (%xh)"), Status);
  232. }
  233. else wsprintf(szMsg1, TEXT("Passed"));
  234. lstrcat(szMsg, szMsg1);
  235. SendDlgItemMessage(
  236. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  237. (LPARAM)(LPTSTR)szMsg);
  238. lstrcpy(szMsg, TEXT("Test add CS res des to LC2: "));
  239. pCs2Res = malloc(sizeof(CS_RESOURCE) + 47); //48-1
  240. pCs2Res->CS_Header.CSD_SignatureLength = 16;
  241. pCs2Res->CS_Header.CSD_LegacyDataOffset = 16;
  242. pCs2Res->CS_Header.CSD_LegacyDataSize = 32;
  243. pCs2Res->CS_Header.CSD_Flags = 0;
  244. CM_Enumerate_Classes(0, &(pCs2Res->CS_Header.CSD_ClassGuid), 0);
  245. for (i = 0; i < 16; i++) {
  246. pCs2Res->CS_Header.CSD_Signature[i] = i;
  247. }
  248. for (i = 0; i < 32; i++) {
  249. LegacyData[i] = 50;
  250. }
  251. memcpy(pCs2Res->CS_Header.CSD_Signature + pCs2Res->CS_Header.CSD_SignatureLength,
  252. LegacyData, 32);
  253. Status = CM_Add_Res_Des(&ResDes, BootLC2, ResType_ClassSpecific, pCs2Res,
  254. sizeof(CS_RESOURCE) + 47, 0);
  255. if (Status != CR_SUCCESS) {
  256. wsprintf(szMsg1, TEXT("Failed (%xh)"), Status);
  257. }
  258. else wsprintf(szMsg1, TEXT("Passed"));
  259. lstrcat(szMsg, szMsg1);
  260. SendDlgItemMessage(
  261. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  262. (LPARAM)(LPTSTR)szMsg);
  263. lstrcpy(szMsg, TEXT("Test add PORT res des to LC2: "));
  264. pIoRes = malloc(sizeof(IO_RESOURCE) + sizeof(IO_RANGE));
  265. pIoRes->IO_Header.IOD_Count = 2;
  266. pIoRes->IO_Header.IOD_Type = IOType_Range;
  267. pIoRes->IO_Header.IOD_Alloc_Base = (DWORDLONG)0x300;
  268. pIoRes->IO_Header.IOD_Alloc_End = (DWORDLONG)0x330;
  269. pIoRes->IO_Header.IOD_DesFlags = 0;
  270. pIoRes->IO_Data[0].IOR_Align = 8; //?
  271. pIoRes->IO_Data[0].IOR_nPorts = 0x30;
  272. pIoRes->IO_Data[0].IOR_Min = (DWORDLONG)0x300;
  273. pIoRes->IO_Data[0].IOR_Max = (DWORDLONG)0x430;
  274. pIoRes->IO_Data[0].IOR_RangeFlags = 0;
  275. pIoRes->IO_Data[0].IOR_Alias = 0;
  276. pIoRes->IO_Data[1].IOR_Align = 8; //?
  277. pIoRes->IO_Data[1].IOR_nPorts = 0x30;
  278. pIoRes->IO_Data[1].IOR_Min = (DWORDLONG)0x200;
  279. pIoRes->IO_Data[1].IOR_Max = (DWORDLONG)0x300;
  280. pIoRes->IO_Data[1].IOR_RangeFlags = 0;
  281. pIoRes->IO_Data[1].IOR_Alias = 0;
  282. Status = CM_Add_Res_Des(&ResDes, BootLC2, ResType_IO, pIoRes,
  283. sizeof(IO_RESOURCE) + sizeof(IO_RANGE), 0);
  284. if (Status != CR_SUCCESS) {
  285. wsprintf(szMsg1, TEXT("Failed (%xh)"), Status);
  286. }
  287. else wsprintf(szMsg1, TEXT("Passed"));
  288. lstrcat(szMsg, szMsg1);
  289. SendDlgItemMessage(
  290. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  291. (LPARAM)(LPTSTR)szMsg);
  292. Status = CM_Add_Res_Des(&ResDes, BasicLC2, ResType_IO, pIoRes,
  293. sizeof(IO_RESOURCE) + sizeof(IO_RANGE), 0);
  294. if (Status != CR_SUCCESS) {
  295. wsprintf(szMsg1, TEXT("Failed (%xh)"), Status);
  296. }
  297. else wsprintf(szMsg1, TEXT("Passed"));
  298. lstrcat(szMsg, szMsg1);
  299. SendDlgItemMessage(
  300. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  301. (LPARAM)(LPTSTR)szMsg);
  302. lstrcpy(szMsg, TEXT("Test add CS res des to LC1: "));
  303. pCs1Res = malloc(sizeof(CS_RESOURCE) + 15); //16-1
  304. pCs1Res->CS_Header.CSD_SignatureLength = 16;
  305. pCs1Res->CS_Header.CSD_LegacyDataOffset = 0;
  306. pCs1Res->CS_Header.CSD_LegacyDataSize = 0;
  307. pCs1Res->CS_Header.CSD_Flags = 0;
  308. CM_Enumerate_Classes(0, &(pCs1Res->CS_Header.CSD_ClassGuid), 0);
  309. for (i = 0; i < 16; i++) {
  310. pCs1Res->CS_Header.CSD_Signature[i] = i;
  311. }
  312. Status = CM_Add_Res_Des(&ResDes, BootLC1, ResType_ClassSpecific, pCs1Res,
  313. sizeof(CS_RESOURCE) + 15, 0);
  314. if (Status != CR_SUCCESS) {
  315. wsprintf(szMsg1, TEXT("Failed (%xh)"), Status);
  316. }
  317. else wsprintf(szMsg1, TEXT("Passed"));
  318. lstrcat(szMsg, szMsg1);
  319. SendDlgItemMessage(
  320. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  321. (LPARAM)(LPTSTR)szMsg);
  322. lstrcpy(szMsg, TEXT("Test add second CS res des to LC2: "));
  323. Status = CM_Add_Res_Des(&ResDes, BootLC2, ResType_ClassSpecific, pCs2Res,
  324. sizeof(CS_RESOURCE) + 47, 0);
  325. if (Status != CR_INVALID_RES_DES) {
  326. wsprintf(szMsg1, TEXT("Failed (%xh)"), Status);
  327. }
  328. else wsprintf(szMsg1, TEXT("Passed"));
  329. lstrcat(szMsg, szMsg1);
  330. SendDlgItemMessage(
  331. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  332. (LPARAM)(LPTSTR)szMsg);
  333. //----------------------------------------------------------------
  334. // Add 3rd empty configs - priority last
  335. //----------------------------------------------------------------
  336. lstrcpy(szMsg, TEXT("Test add 3rd empty boot config: "));
  337. Status = CM_Add_Empty_Log_Conf(&BootLC3, dnDevNode, LCPRI_BOOTCONFIG,
  338. BOOT_LOG_CONF | PRIORITY_EQUAL_LAST);
  339. if (Status != CR_SUCCESS) {
  340. wsprintf(szMsg1, TEXT("CM_Add_Empty_Log_Conf Failed (%xh)"), Status);
  341. }
  342. else wsprintf(szMsg1, TEXT("Passed"));
  343. lstrcat(szMsg, szMsg1);
  344. SendDlgItemMessage(
  345. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  346. (LPARAM)(LPTSTR)szMsg);
  347. lstrcpy(szMsg, TEXT("Test add 3rd empty basic config: "));
  348. Status = CM_Add_Empty_Log_Conf(&BasicLC3, dnDevNode, LCPRI_NORMAL,
  349. BASIC_LOG_CONF | PRIORITY_EQUAL_LAST);
  350. if (Status != CR_SUCCESS) {
  351. wsprintf(szMsg1, TEXT("CM_Add_Empty_Log_Conf Failed (%xh)"), Status);
  352. }
  353. else wsprintf(szMsg1, TEXT("Passed"));
  354. lstrcat(szMsg, szMsg1);
  355. SendDlgItemMessage(
  356. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  357. (LPARAM)(LPTSTR)szMsg);
  358. lstrcpy(szMsg, TEXT("Test get priority of 3rd boot config: "));
  359. Status = CM_Get_Log_Conf_Priority(BootLC3, &Priority, 0);
  360. if (Status == CR_SUCCESS) {
  361. if (Priority == LCPRI_BOOTCONFIG) {
  362. wsprintf(szMsg1, TEXT("Passed\n"));
  363. } else {
  364. wsprintf(szMsg1, TEXT("Failed, priority should be %x (%x)\n"), LCPRI_BOOTCONFIG, Priority);
  365. }
  366. } else {
  367. wsprintf(szMsg1, TEXT("Failed (%d)\n"), Status);
  368. }
  369. lstrcat(szMsg, szMsg1);
  370. SendDlgItemMessage(
  371. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  372. (LPARAM)(LPTSTR)szMsg);
  373. //----------------------------------------------------------------
  374. // Add DMA resource to LC3
  375. //----------------------------------------------------------------
  376. lstrcpy(szMsg, TEXT("Test add DMA res des to LC3: "));
  377. pDmaRes = malloc(sizeof(DMA_RESOURCE));
  378. pDmaRes->DMA_Header.DD_Count = 1;
  379. pDmaRes->DMA_Header.DD_Type = DType_Range;
  380. pDmaRes->DMA_Header.DD_Flags = fDD_DWORD;
  381. pDmaRes->DMA_Header.DD_Alloc_Chan = (DWORDLONG)0x3;
  382. pDmaRes->DMA_Data[0].DR_Min = 1;
  383. pDmaRes->DMA_Data[0].DR_Max = 3;
  384. pDmaRes->DMA_Data[0].DR_Flags = fDD_DWORD;
  385. Status = CM_Add_Res_Des(&ResDes, BootLC3, ResType_DMA, pDmaRes,
  386. sizeof(DMA_RESOURCE), 0);
  387. if (Status != CR_SUCCESS) {
  388. wsprintf(szMsg1, TEXT("Failed (%xh)"), Status);
  389. }
  390. else wsprintf(szMsg1, TEXT("Passed"));
  391. lstrcat(szMsg, szMsg1);
  392. SendDlgItemMessage(
  393. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  394. (LPARAM)(LPTSTR)szMsg);
  395. Status = CM_Add_Res_Des(&ResDes, BasicLC3, ResType_DMA, pDmaRes,
  396. sizeof(DMA_RESOURCE), 0);
  397. if (Status != CR_SUCCESS) {
  398. wsprintf(szMsg1, TEXT("Failed (%xh)"), Status);
  399. }
  400. else wsprintf(szMsg1, TEXT("Passed"));
  401. lstrcat(szMsg, szMsg1);
  402. SendDlgItemMessage(
  403. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  404. (LPARAM)(LPTSTR)szMsg);
  405. //----------------------------------------------------------------
  406. // Add IRQ resource to LC3
  407. //----------------------------------------------------------------
  408. lstrcpy(szMsg, TEXT("Test add IRQ res des to LC3: "));
  409. pIrqRes = malloc(sizeof(IRQ_RESOURCE) + sizeof(IRQ_RANGE) * 2);
  410. pIrqRes->IRQ_Header.IRQD_Count = 3;
  411. pIrqRes->IRQ_Header.IRQD_Type = IRQType_Range;
  412. pIrqRes->IRQ_Header.IRQD_Flags = fDD_DWORD;
  413. pIrqRes->IRQ_Header.IRQD_Alloc_Num = (DWORDLONG)11;
  414. pIrqRes->IRQ_Header.IRQD_Affinity = 0;
  415. pIrqRes->IRQ_Data[0].IRQR_Min = 1;
  416. pIrqRes->IRQ_Data[0].IRQR_Max = 3;
  417. pIrqRes->IRQ_Data[0].IRQR_Flags = fIRQD_Exclusive | fIRQD_Level;
  418. pIrqRes->IRQ_Data[1].IRQR_Min = 5;
  419. pIrqRes->IRQ_Data[1].IRQR_Max = 7;
  420. pIrqRes->IRQ_Data[1].IRQR_Flags = fIRQD_Exclusive | fIRQD_Level;
  421. pIrqRes->IRQ_Data[2].IRQR_Min = 9;
  422. pIrqRes->IRQ_Data[2].IRQR_Max = 11;
  423. pIrqRes->IRQ_Data[2].IRQR_Flags = fIRQD_Exclusive | fIRQD_Level;
  424. Status = CM_Add_Res_Des(&ResDes, BootLC3, ResType_IRQ, pIrqRes,
  425. sizeof(IRQ_RESOURCE) + sizeof(IRQ_RANGE) * 2, 0);
  426. if (Status != CR_SUCCESS) {
  427. wsprintf(szMsg1, TEXT("Failed (%xh)"), Status);
  428. }
  429. else wsprintf(szMsg1, TEXT("Passed"));
  430. lstrcat(szMsg, szMsg1);
  431. SendDlgItemMessage(
  432. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  433. (LPARAM)(LPTSTR)szMsg);
  434. Status = CM_Add_Res_Des(&ResDes, BasicLC3, ResType_IRQ, pIrqRes,
  435. sizeof(IRQ_RESOURCE) + sizeof(IRQ_RANGE) * 2, 0);
  436. if (Status != CR_SUCCESS) {
  437. wsprintf(szMsg1, TEXT("Failed (%xh)"), Status);
  438. }
  439. else wsprintf(szMsg1, TEXT("Passed"));
  440. lstrcat(szMsg, szMsg1);
  441. SendDlgItemMessage(
  442. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  443. (LPARAM)(LPTSTR)szMsg);
  444. MessageBox(hDlg, TEXT("Check registry contents"), TEXT("CMTEST"), MB_OK);
  445. //----------------------------------------------------------------
  446. // Delete an lc that still has rd's in it (then recreate it)
  447. //----------------------------------------------------------------
  448. lstrcpy(szMsg, TEXT("Test free Boot Config LC2: "));
  449. Status = CM_Free_Log_Conf(BootLC2, 0);
  450. if (Status != CR_SUCCESS) {
  451. wsprintf(szMsg1, TEXT("Failed (%xh)"), Status);
  452. }
  453. else wsprintf(szMsg1, TEXT("Passed"));
  454. lstrcat(szMsg, szMsg1);
  455. SendDlgItemMessage(
  456. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  457. (LPARAM)(LPTSTR)szMsg);
  458. CM_Free_Log_Conf_Handle(BootLC1);
  459. lstrcpy(szMsg, TEXT("Recreate Boot LC2 (will be first): "));
  460. Status = CM_Add_Empty_Log_Conf(&BootLC1, dnDevNode, LCPRI_BOOTCONFIG,
  461. BOOT_LOG_CONF | PRIORITY_EQUAL_FIRST);
  462. if (Status != CR_SUCCESS) {
  463. wsprintf(szMsg1, TEXT("CM_Add_Empty_Log_Conf Failed (%xh)"), Status);
  464. }
  465. else wsprintf(szMsg1, TEXT("Passed"));
  466. lstrcat(szMsg, szMsg1);
  467. SendDlgItemMessage(
  468. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  469. (LPARAM)(LPTSTR)szMsg);
  470. lstrcpy(szMsg, TEXT("Re-add CS to LC2: "));
  471. Status = CM_Add_Res_Des(&ResDes, BootLC1, ResType_ClassSpecific, pCs2Res,
  472. sizeof(CS_RESOURCE) + 47, 0);
  473. if (Status != CR_SUCCESS) {
  474. wsprintf(szMsg1, TEXT("Failed (%xh)"), Status);
  475. }
  476. else wsprintf(szMsg1, TEXT("Passed"));
  477. lstrcat(szMsg, szMsg1);
  478. SendDlgItemMessage(
  479. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  480. (LPARAM)(LPTSTR)szMsg);
  481. lstrcpy(szMsg, TEXT("Re-add IO to LC2: "));
  482. Status = CM_Add_Res_Des(&ResDes, BootLC1, ResType_IO, pIoRes,
  483. sizeof(IO_RESOURCE) + sizeof(IO_RANGE), 0);
  484. if (Status != CR_SUCCESS) {
  485. wsprintf(szMsg1, TEXT("Failed (%xh)"), Status);
  486. }
  487. else wsprintf(szMsg1, TEXT("Passed"));
  488. lstrcat(szMsg, szMsg1);
  489. SendDlgItemMessage(
  490. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  491. (LPARAM)(LPTSTR)szMsg);
  492. // free handles and retreive them again in order
  493. CM_Free_Log_Conf_Handle(BootLC1);
  494. CM_Free_Log_Conf_Handle(BootLC2);
  495. CM_Free_Log_Conf_Handle(BootLC3);
  496. CM_Get_First_Log_Conf(&BootLC1, dnDevNode, BOOT_LOG_CONF);
  497. CM_Get_Next_Log_Conf(&BootLC2, BootLC1, 0);
  498. CM_Get_Next_Log_Conf(&BootLC3, BootLC2, 0);
  499. lstrcpy(szMsg, TEXT("Test free Basic Config LC2: "));
  500. Status = CM_Free_Log_Conf(BasicLC2, 0);
  501. if (Status != CR_SUCCESS) {
  502. wsprintf(szMsg1, TEXT("Failed (%xh)"), Status);
  503. }
  504. else wsprintf(szMsg1, TEXT("Passed"));
  505. lstrcat(szMsg, szMsg1);
  506. SendDlgItemMessage(
  507. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  508. (LPARAM)(LPTSTR)szMsg);
  509. CM_Free_Log_Conf_Handle(BasicLC1);
  510. lstrcpy(szMsg, TEXT("Recreate LC2 (will be first): "));
  511. Status = CM_Add_Empty_Log_Conf(&BasicLC1, dnDevNode, LCPRI_NORMAL,
  512. BASIC_LOG_CONF | PRIORITY_EQUAL_FIRST);
  513. if (Status != CR_SUCCESS) {
  514. wsprintf(szMsg1, TEXT("CM_Add_Empty_Log_Conf Failed (%xh)"), Status);
  515. }
  516. else wsprintf(szMsg1, TEXT("Passed"));
  517. lstrcat(szMsg, szMsg1);
  518. SendDlgItemMessage(
  519. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  520. (LPARAM)(LPTSTR)szMsg);
  521. lstrcpy(szMsg, TEXT("Attempt adding a CS: "));
  522. Status = CM_Add_Res_Des(&ResDes, BasicLC1, ResType_ClassSpecific, pCs2Res,
  523. sizeof(CS_RESOURCE) + 47, 0);
  524. if (Status != CR_INVALID_RES_DES) {
  525. wsprintf(szMsg1, TEXT("Failed (%xh)"), Status);
  526. }
  527. else wsprintf(szMsg1, TEXT("Passed"));
  528. lstrcat(szMsg, szMsg1);
  529. SendDlgItemMessage(
  530. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  531. (LPARAM)(LPTSTR)szMsg);
  532. lstrcpy(szMsg, TEXT("Re-add IO to LC2: "));
  533. Status = CM_Add_Res_Des(&ResDes, BasicLC1, ResType_IO, pIoRes,
  534. sizeof(IO_RESOURCE) + sizeof(IO_RANGE), 0);
  535. if (Status != CR_SUCCESS) {
  536. wsprintf(szMsg1, TEXT("Failed (%xh)"), Status);
  537. }
  538. else wsprintf(szMsg1, TEXT("Passed"));
  539. lstrcat(szMsg, szMsg1);
  540. SendDlgItemMessage(
  541. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  542. (LPARAM)(LPTSTR)szMsg);
  543. // free handles and retreive them again in order
  544. CM_Free_Log_Conf_Handle(BasicLC1);
  545. CM_Free_Log_Conf_Handle(BasicLC2);
  546. CM_Free_Log_Conf_Handle(BasicLC3);
  547. CM_Get_First_Log_Conf(&BasicLC1, dnDevNode, BASIC_LOG_CONF);
  548. CM_Get_Next_Log_Conf(&BasicLC2, BasicLC1, 0);
  549. CM_Get_Next_Log_Conf(&BasicLC3, BasicLC2, 0);
  550. MessageBox(hDlg, TEXT("Check registry contents"), TEXT("CMTEST"), MB_OK);
  551. //----------------------------------------------------------------
  552. // Get-next test
  553. //----------------------------------------------------------------
  554. lstrcpy(szMsg, TEXT("Get first res des from Boot LC1: "));
  555. Status = CM_Get_Next_Res_Des(&ResDes1, BootLC1, ResType_All, &ResType, 0);
  556. if (Status != CR_SUCCESS) {
  557. wsprintf(szMsg1, TEXT("Failed (%xh)"), Status);
  558. }
  559. else wsprintf(szMsg1, TEXT("Passed"));
  560. lstrcat(szMsg, szMsg1);
  561. SendDlgItemMessage(
  562. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  563. (LPARAM)(LPTSTR)szMsg);
  564. lstrcpy(szMsg, TEXT("Get next res des from Boot LC1 (all): "));
  565. Status = CM_Get_Next_Res_Des(&ResDes2, ResDes1, ResType_All, &ResType, 0);
  566. if (Status != CR_SUCCESS) {
  567. wsprintf(szMsg1, TEXT("Failed (%xh)"), Status);
  568. }
  569. else wsprintf(szMsg1, TEXT("Passed"));
  570. lstrcat(szMsg, szMsg1);
  571. SendDlgItemMessage(
  572. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  573. (LPARAM)(LPTSTR)szMsg);
  574. lstrcpy(szMsg, TEXT("Get next res des from Boot LC1 (all): "));
  575. Status = CM_Get_Next_Res_Des(&ResDes3, ResDes2, ResType_All, &ResType, 0);
  576. if (Status != CR_NO_MORE_RES_DES) {
  577. wsprintf(szMsg1, TEXT("Failed (%xh)"), Status);
  578. }
  579. else wsprintf(szMsg1, TEXT("Passed"));
  580. lstrcat(szMsg, szMsg1);
  581. SendDlgItemMessage(
  582. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  583. (LPARAM)(LPTSTR)szMsg);
  584. lstrcpy(szMsg, TEXT("Get next res des from Boot LC2 (ClassSpecific): "));
  585. Status = CM_Get_Next_Res_Des(&ResDes1, BootLC2, ResType_ClassSpecific,
  586. &ResType, 0);
  587. if (Status != CR_SUCCESS) {
  588. wsprintf(szMsg1, TEXT("Failed (%xh)"), Status);
  589. }
  590. else wsprintf(szMsg1, TEXT("Passed"));
  591. lstrcat(szMsg, szMsg1);
  592. SendDlgItemMessage(
  593. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  594. (LPARAM)(LPTSTR)szMsg);
  595. SendDlgItemMessage(
  596. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  597. (LPARAM)(LPTSTR)szMsg);
  598. lstrcpy(szMsg, TEXT("Get next res des from Boot LC2 (DMA): "));
  599. Status = CM_Get_Next_Res_Des(&ResDes2, ResDes1, ResType_DMA, &ResType, 0);
  600. if (Status != CR_NO_MORE_RES_DES) {
  601. wsprintf(szMsg1, TEXT("Failed (%xh)"), Status);
  602. }
  603. else wsprintf(szMsg1, TEXT("Passed"));
  604. lstrcat(szMsg, szMsg1);
  605. SendDlgItemMessage(
  606. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  607. (LPARAM)(LPTSTR)szMsg);
  608. lstrcpy(szMsg, TEXT("Get first res des from Basic LC3: "));
  609. Status = CM_Get_Next_Res_Des(&ResDes1, BasicLC3, ResType_All, &ResType, 0);
  610. if (Status != CR_SUCCESS) {
  611. wsprintf(szMsg1, TEXT("Failed (%xh)"), Status);
  612. }
  613. else wsprintf(szMsg1, TEXT("Passed"));
  614. lstrcat(szMsg, szMsg1);
  615. SendDlgItemMessage(
  616. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  617. (LPARAM)(LPTSTR)szMsg);
  618. lstrcpy(szMsg, TEXT("Get next res des from Basic LC3 (all): "));
  619. Status = CM_Get_Next_Res_Des(&ResDes2, ResDes1, ResType_All, &ResType, 0);
  620. if (Status != CR_SUCCESS) {
  621. wsprintf(szMsg1, TEXT("Failed (%xh)"), Status);
  622. }
  623. else wsprintf(szMsg1, TEXT("Passed"));
  624. lstrcat(szMsg, szMsg1);
  625. SendDlgItemMessage(
  626. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  627. (LPARAM)(LPTSTR)szMsg);
  628. SendDlgItemMessage(
  629. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  630. (LPARAM)(LPTSTR)szMsg);
  631. lstrcpy(szMsg, TEXT("Get next res des from Basic LC3 (all): "));
  632. Status = CM_Get_Next_Res_Des(&ResDes3, ResDes2, ResType_All, &ResType, 0);
  633. if (Status != CR_NO_MORE_RES_DES) {
  634. wsprintf(szMsg1, TEXT("Failed (%xh)"), Status);
  635. }
  636. else wsprintf(szMsg1, TEXT("Passed"));
  637. lstrcat(szMsg, szMsg1);
  638. SendDlgItemMessage(
  639. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  640. (LPARAM)(LPTSTR)szMsg);
  641. lstrcpy(szMsg, TEXT("Get first res des from Basic LC3 (IRQ): "));
  642. Status = CM_Get_Next_Res_Des(&ResDes1, BasicLC3, ResType_IRQ,
  643. &ResType, 0);
  644. if (Status != CR_SUCCESS) {
  645. wsprintf(szMsg1, TEXT("Failed (%xh)"), Status);
  646. }
  647. else wsprintf(szMsg1, TEXT("Passed"));
  648. lstrcat(szMsg, szMsg1);
  649. SendDlgItemMessage(
  650. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  651. (LPARAM)(LPTSTR)szMsg);
  652. SendDlgItemMessage(
  653. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  654. (LPARAM)(LPTSTR)szMsg);
  655. lstrcpy(szMsg, TEXT("Get next res des from Basic LC1 (IRQ): "));
  656. Status = CM_Get_Next_Res_Des(&ResDes2, BasicLC1, ResType_IRQ, &ResType, 0);
  657. if (Status != CR_NO_MORE_RES_DES) {
  658. wsprintf(szMsg1, TEXT("Failed (%xh)"), Status);
  659. }
  660. else wsprintf(szMsg1, TEXT("Passed"));
  661. lstrcat(szMsg, szMsg1);
  662. SendDlgItemMessage(
  663. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  664. (LPARAM)(LPTSTR)szMsg);
  665. //----------------------------------------------------------------
  666. // Get data size and data for all
  667. //----------------------------------------------------------------
  668. // reset some fields for comparison
  669. pMemRes->MEM_Header.MD_Count = 0;
  670. pMemRes->MEM_Data[0].MR_Align = 0;
  671. pMemRes->MEM_Data[0].MR_nBytes = 0;
  672. pMemRes->MEM_Data[0].MR_Min = 0;
  673. pMemRes->MEM_Data[0].MR_Max = 0;
  674. pMemRes->MEM_Data[0].MR_Flags = 0;
  675. pMemRes->MEM_Data[0].MR_Reserved = 0;
  676. CM_Get_Next_Res_Des(&ResDes1, BootLC2, ResType_All, &ResType, 0);
  677. CM_Get_Res_Des_Data_Size(&ulSize, ResDes1, 0);
  678. pData = malloc(ulSize);
  679. CM_Get_Res_Des_Data(ResDes1, pData, ulSize, 0);
  680. if (memcmp(pData, pMemRes, ulSize) != 0) {
  681. wsprintf(szMsg, TEXT("BOOT LC2-RD1 Data is NOT correct"));
  682. }
  683. else wsprintf(szMsg, TEXT("BOOT LC2-RD1 Data is correct"));
  684. free(pData);
  685. SendDlgItemMessage(
  686. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  687. (LPARAM)(LPTSTR)szMsg);
  688. // reset fields back to original values
  689. pMemRes->MEM_Header.MD_Count = 2;
  690. pMemRes->MEM_Data[0].MR_Align = 8; //?
  691. pMemRes->MEM_Data[0].MR_nBytes = 4096;
  692. pMemRes->MEM_Data[0].MR_Min = (DWORDLONG)0xD8000;
  693. pMemRes->MEM_Data[0].MR_Max = (DWORDLONG)0xDC000;
  694. pMemRes->MEM_Data[0].MR_Flags = fMD_ROM | fMD_32 | fMD_ReadAllowed;
  695. pMemRes->MEM_Data[0].MR_Reserved = 0;
  696. CM_Get_Next_Res_Des(&ResDes2, ResDes1, ResType_All, &ResType, 0);
  697. CM_Get_Res_Des_Data_Size(&ulSize, ResDes2, 0);
  698. pData = malloc(ulSize);
  699. CM_Get_Res_Des_Data(ResDes2, pData, ulSize, 0);
  700. if (memcmp(pData, pCs1Res, ulSize) != 0) {
  701. wsprintf(szMsg, TEXT("BOOT LC2-RD2 Data is NOT correct"));
  702. }
  703. else wsprintf(szMsg, TEXT("BOOT LC2-RD2 Data is correct"));
  704. free(pData);
  705. SendDlgItemMessage(
  706. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  707. (LPARAM)(LPTSTR)szMsg);
  708. // reset some fields for comparison
  709. pIoRes->IO_Header.IOD_Count = 0;
  710. pIoRes->IO_Data[0].IOR_Align = 0;
  711. pIoRes->IO_Data[0].IOR_nPorts = 0;
  712. pIoRes->IO_Data[0].IOR_Min = 0;
  713. pIoRes->IO_Data[0].IOR_Max = 0;
  714. pIoRes->IO_Data[0].IOR_RangeFlags = 0;
  715. pIoRes->IO_Data[0].IOR_Alias = 0;
  716. CM_Get_Next_Res_Des(&ResDes1, BootLC1, ResType_All, &ResType, 0);
  717. CM_Get_Res_Des_Data_Size(&ulSize, ResDes1, 0);
  718. pData = malloc(ulSize);
  719. CM_Get_Res_Des_Data(ResDes1, pData, ulSize, 0);
  720. if (memcmp(pData, pIoRes, ulSize) != 0) {
  721. wsprintf(szMsg, TEXT("BOOT LC1-RD1 Data is NOT correct"));
  722. }
  723. else wsprintf(szMsg, TEXT("BOOT LC1-RD1 Data is correct"));
  724. free(pData);
  725. SendDlgItemMessage(
  726. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  727. (LPARAM)(LPTSTR)szMsg);
  728. // reset fields back to original values
  729. pIoRes->IO_Header.IOD_Count = 2;
  730. pIoRes->IO_Data[0].IOR_Align = 8; //?
  731. pIoRes->IO_Data[0].IOR_nPorts = 0x30;
  732. pIoRes->IO_Data[0].IOR_Min = (DWORDLONG)0x300;
  733. pIoRes->IO_Data[0].IOR_Max = (DWORDLONG)0x430;
  734. pIoRes->IO_Data[0].IOR_RangeFlags = 0;
  735. pIoRes->IO_Data[0].IOR_Alias = 0;
  736. CM_Get_Next_Res_Des(&ResDes2, ResDes1, ResType_All, &ResType, 0);
  737. CM_Get_Res_Des_Data_Size(&ulSize, ResDes2, 0);
  738. pData = malloc(ulSize);
  739. CM_Get_Res_Des_Data(ResDes2, pData, ulSize, 0);
  740. if (ulSize != (sizeof(CS_RESOURCE) + 47) ||
  741. memcmp(pData, pCs2Res, ulSize) != 0) {
  742. wsprintf(szMsg, TEXT("BOOT LC1-RD2 Data is NOT correct"));
  743. }
  744. else wsprintf(szMsg, TEXT("BOOT LC1-RD2 Data is correct"));
  745. free(pData);
  746. SendDlgItemMessage(
  747. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  748. (LPARAM)(LPTSTR)szMsg);
  749. // reset some fields for comparison
  750. pDmaRes->DMA_Header.DD_Count = 0;
  751. pDmaRes->DMA_Data[0].DR_Min = 0;
  752. pDmaRes->DMA_Data[0].DR_Max = 0;
  753. pDmaRes->DMA_Data[0].DR_Flags = 0;
  754. CM_Get_Next_Res_Des(&ResDes1, BootLC3, ResType_All, &ResType, 0);
  755. CM_Get_Res_Des_Data_Size(&ulSize, ResDes1, 0);
  756. pData = malloc(ulSize);
  757. CM_Get_Res_Des_Data(ResDes1, pData, ulSize, 0);
  758. if (memcmp(pData, pDmaRes, ulSize) != 0) {
  759. wsprintf(szMsg, TEXT("BOOT LC3-RD1 Data is NOT correct"));
  760. }
  761. else wsprintf(szMsg, TEXT("BOOT LC3-RD1 Data is correct"));
  762. free(pData);
  763. SendDlgItemMessage(
  764. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  765. (LPARAM)(LPTSTR)szMsg);
  766. // reset fields back to original values
  767. pDmaRes->DMA_Header.DD_Count = 1;
  768. pDmaRes->DMA_Data[0].DR_Min = 1;
  769. pDmaRes->DMA_Data[0].DR_Max = 3;
  770. pDmaRes->DMA_Data[0].DR_Flags = fDD_DWORD;
  771. // reset some fields for comparison
  772. pIrqRes->IRQ_Header.IRQD_Count = 0;
  773. pIrqRes->IRQ_Data[0].IRQR_Min = 0;
  774. pIrqRes->IRQ_Data[0].IRQR_Max = 0;
  775. pIrqRes->IRQ_Data[0].IRQR_Flags = 0;
  776. CM_Get_Next_Res_Des(&ResDes2, ResDes1, ResType_All, &ResType, 0);
  777. CM_Get_Res_Des_Data_Size(&ulSize, ResDes2, 0);
  778. pData = malloc(ulSize);
  779. CM_Get_Res_Des_Data(ResDes2, pData, ulSize, 0);
  780. if (memcmp(pData, pIrqRes, ulSize) != 0) {
  781. wsprintf(szMsg, TEXT("BOOT LC3-RD2 Data is NOT correct"));
  782. }
  783. else wsprintf(szMsg, TEXT("BOOT LC3-RD2 Data is correct"));
  784. free(pData);
  785. SendDlgItemMessage(
  786. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  787. (LPARAM)(LPTSTR)szMsg);
  788. // reset fields back to original values
  789. pIrqRes->IRQ_Header.IRQD_Count = 3;
  790. pIrqRes->IRQ_Data[0].IRQR_Min = 1;
  791. pIrqRes->IRQ_Data[0].IRQR_Max = 3;
  792. pIrqRes->IRQ_Data[0].IRQR_Flags = fIRQD_Exclusive | fIRQD_Level;
  793. // null out header for comparison
  794. pMemRes->MEM_Header.MD_Alloc_Base = 0;
  795. pMemRes->MEM_Header.MD_Alloc_End = 0;
  796. pMemRes->MEM_Header.MD_Flags = 0;
  797. pMemRes->MEM_Header.MD_Reserved = 0;
  798. CM_Get_Next_Res_Des(&ResDes1, BasicLC2, ResType_All, &ResType, 0);
  799. CM_Get_Res_Des_Data_Size(&ulSize, ResDes1, 0);
  800. pData = malloc(ulSize);
  801. CM_Get_Res_Des_Data(ResDes1, pData, ulSize, 0);
  802. if (ulSize != (sizeof(MEM_RESOURCE) + sizeof(MEM_RANGE)) ||
  803. memcmp(pData, pMemRes, ulSize) != 0) {
  804. wsprintf(szMsg, TEXT("BASIC LC2-RD1 Data is NOT correct"));
  805. }
  806. else wsprintf(szMsg, TEXT("BASIC LC2-RD1 Data is correct"));
  807. free(pData);
  808. SendDlgItemMessage(
  809. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  810. (LPARAM)(LPTSTR)szMsg);
  811. // reset header back
  812. pMemRes->MEM_Header.MD_Alloc_Base = (DWORDLONG)0xD8000;
  813. pMemRes->MEM_Header.MD_Alloc_End = (DWORDLONG)0xD9000;
  814. pMemRes->MEM_Header.MD_Flags = fMD_ROM | fMD_32 | fMD_ReadAllowed;
  815. pMemRes->MEM_Header.MD_Reserved = 0;
  816. // null out header for comparison
  817. pIoRes->IO_Header.IOD_Alloc_Base = 0;
  818. pIoRes->IO_Header.IOD_Alloc_End = 0;
  819. pIoRes->IO_Header.IOD_DesFlags = 0;
  820. CM_Get_Next_Res_Des(&ResDes1, BasicLC1, ResType_All, &ResType, 0);
  821. CM_Get_Res_Des_Data_Size(&ulSize, ResDes1, 0);
  822. pData = malloc(ulSize);
  823. CM_Get_Res_Des_Data(ResDes1, pData, ulSize, 0);
  824. if (ulSize != (sizeof(IO_RESOURCE) + sizeof(IO_RANGE)) ||
  825. memcmp(pData, pIoRes, ulSize) != 0) {
  826. wsprintf(szMsg, TEXT("BASIC LC1-RD1 Data is NOT correct"));
  827. }
  828. else wsprintf(szMsg, TEXT("BASIC LC1-RD1 Data is correct"));
  829. free(pData);
  830. SendDlgItemMessage(
  831. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  832. (LPARAM)(LPTSTR)szMsg);
  833. // reset header back
  834. pIoRes->IO_Header.IOD_Alloc_Base = (DWORDLONG)0x300;
  835. pIoRes->IO_Header.IOD_Alloc_End = (DWORDLONG)0x330;
  836. pIoRes->IO_Header.IOD_DesFlags = 0;
  837. // null out header for comparison
  838. pDmaRes->DMA_Header.DD_Flags = 0;
  839. pDmaRes->DMA_Header.DD_Alloc_Chan = 0;
  840. CM_Get_Next_Res_Des(&ResDes1, BasicLC3, ResType_All, &ResType, 0);
  841. CM_Get_Res_Des_Data_Size(&ulSize, ResDes1, 0);
  842. pData = malloc(ulSize);
  843. CM_Get_Res_Des_Data(ResDes1, pData, ulSize, 0);
  844. if (ulSize != sizeof(DMA_RESOURCE) ||
  845. memcmp(pData, pDmaRes, ulSize) != 0) {
  846. wsprintf(szMsg, TEXT("BASIC LC3-RD1 Data is NOT correct"));
  847. }
  848. else wsprintf(szMsg, TEXT("BASIC LC3-RD1 Data is correct"));
  849. free(pData);
  850. SendDlgItemMessage(
  851. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  852. (LPARAM)(LPTSTR)szMsg);
  853. // reset header back
  854. pDmaRes->DMA_Header.DD_Flags = fDD_DWORD;
  855. pDmaRes->DMA_Header.DD_Alloc_Chan = (DWORDLONG)0x3;
  856. // null out header for comparison
  857. pIrqRes->IRQ_Header.IRQD_Flags = 0;
  858. pIrqRes->IRQ_Header.IRQD_Alloc_Num = 0;
  859. pIrqRes->IRQ_Header.IRQD_Affinity = 0;
  860. CM_Get_Next_Res_Des(&ResDes2, ResDes1, ResType_All, &ResType, 0);
  861. CM_Get_Res_Des_Data_Size(&ulSize, ResDes2, 0);
  862. pData = malloc(ulSize);
  863. CM_Get_Res_Des_Data(ResDes2, pData, ulSize, 0);
  864. if (ulSize != sizeof(IRQ_RESOURCE) + sizeof(IRQ_RANGE) * 2 ||
  865. memcmp(pData, pIrqRes, ulSize) != 0) {
  866. wsprintf(szMsg, TEXT("BASIC LC3-RD2 Data is NOT correct"));
  867. }
  868. else wsprintf(szMsg, TEXT("BASIC LC3-RD2 Data is correct"));
  869. free(pData);
  870. SendDlgItemMessage(
  871. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  872. (LPARAM)(LPTSTR)szMsg);
  873. // reset header back
  874. pIrqRes->IRQ_Header.IRQD_Flags = fDD_DWORD;
  875. pIrqRes->IRQ_Header.IRQD_Alloc_Num = (DWORDLONG)11;
  876. pIrqRes->IRQ_Header.IRQD_Affinity = 0;
  877. //---------------------------------------------------------------
  878. // Modify data test
  879. //---------------------------------------------------------------
  880. wsprintf(szMsg, TEXT("Modify Boot LC3-RD2 (shrink): "));
  881. CM_Get_Next_Res_Des(&ResDes2, BootLC3, ResType_IRQ, &ResType, 0);
  882. Status = CM_Modify_Res_Des(&ResDes2, ResDes2, ResType_IO, pIoRes,
  883. sizeof(IO_RESOURCE) + sizeof(IO_RANGE), 0);
  884. if (Status != CR_SUCCESS) {
  885. wsprintf(szMsg1, TEXT("Failed (%xh)"), Status);
  886. }
  887. else wsprintf(szMsg1, TEXT("Passed"));
  888. lstrcat(szMsg, szMsg1);
  889. SendDlgItemMessage(
  890. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  891. (LPARAM)(LPTSTR)szMsg);
  892. CM_Get_Res_Des_Data_Size(&ulSize, ResDes2, 0);
  893. pData = malloc(ulSize);
  894. CM_Get_Res_Des_Data(ResDes2, pData, ulSize, 0);
  895. if (memcmp(pData, pIoRes, ulSize) != 0) {
  896. wsprintf(szMsg, TEXT("BOOT LC3-RD2 Data is NOT correct"));
  897. }
  898. else wsprintf(szMsg, TEXT("BOOT LC3-RD2 Data is correct"));
  899. free(pData);
  900. SendDlgItemMessage(
  901. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  902. (LPARAM)(LPTSTR)szMsg);
  903. wsprintf(szMsg, TEXT("Modify Basic LC3-RD2 (shrink): "));
  904. CM_Get_Next_Res_Des(&ResDes2, BasicLC3, ResType_IRQ, &ResType, 0);
  905. Status = CM_Modify_Res_Des(&ResDes2, ResDes2, ResType_IO, pIoRes,
  906. sizeof(IO_RESOURCE) + sizeof(IO_RANGE), 0);
  907. if (Status != CR_SUCCESS) {
  908. wsprintf(szMsg1, TEXT("Failed (%xh)"), Status);
  909. }
  910. else wsprintf(szMsg1, TEXT("Passed"));
  911. lstrcat(szMsg, szMsg1);
  912. SendDlgItemMessage(
  913. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  914. (LPARAM)(LPTSTR)szMsg);
  915. // null out header for comparison
  916. pIoRes->IO_Header.IOD_Alloc_Base = 0;
  917. pIoRes->IO_Header.IOD_Alloc_End = 0;
  918. pIoRes->IO_Header.IOD_DesFlags = 0;
  919. CM_Get_Res_Des_Data_Size(&ulSize, ResDes2, 0);
  920. pData = malloc(ulSize);
  921. CM_Get_Res_Des_Data(ResDes2, pData, ulSize, 0);
  922. if (ulSize != sizeof(IO_RESOURCE) + sizeof(IO_RANGE)) {
  923. wsprintf(szMsg, TEXT("LC3-RD2 Data size is NOT correct"));
  924. } else if (memcmp(pData, pIoRes, ulSize) != 0) {
  925. wsprintf(szMsg, TEXT("LC3-RD2 Data is NOT correct"));
  926. }
  927. else wsprintf(szMsg, TEXT("LC3-RD2 Data is correct"));
  928. free(pData);
  929. SendDlgItemMessage(
  930. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  931. (LPARAM)(LPTSTR)szMsg);
  932. // reset header back
  933. pIoRes->IO_Header.IOD_Alloc_Base = (DWORDLONG)0x300;
  934. pIoRes->IO_Header.IOD_Alloc_End = (DWORDLONG)0x330;
  935. pIoRes->IO_Header.IOD_DesFlags = 0;
  936. wsprintf(szMsg, TEXT("Modify Boot LC1-RD1 (grow): "));
  937. CM_Get_Next_Res_Des(&ResDes1, BootLC1, ResType_All, &ResType, 0);
  938. Status = CM_Modify_Res_Des(&ResDes1, ResDes1, ResType_IRQ, pIrqRes,
  939. sizeof(IRQ_RESOURCE) + sizeof(IRQ_RANGE) * 2, 0);
  940. if (Status != CR_SUCCESS) {
  941. wsprintf(szMsg1, TEXT("Failed (%xh)"), Status);
  942. }
  943. else wsprintf(szMsg1, TEXT("Passed"));
  944. lstrcat(szMsg, szMsg1);
  945. SendDlgItemMessage(
  946. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  947. (LPARAM)(LPTSTR)szMsg);
  948. CM_Get_Res_Des_Data_Size(&ulSize, ResDes1, 0);
  949. pData = malloc(ulSize);
  950. CM_Get_Res_Des_Data(ResDes1, pData, ulSize, 0);
  951. if (memcmp(pData, pIrqRes, ulSize) != 0) {
  952. wsprintf(szMsg, TEXT("BOOT LC2-RD1 Data is NOT correct"));
  953. }
  954. else wsprintf(szMsg, TEXT("BOOT LC2-RD1 Data is correct"));
  955. free(pData);
  956. SendDlgItemMessage(
  957. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  958. (LPARAM)(LPTSTR)szMsg);
  959. wsprintf(szMsg, TEXT("Modify Basic LC1-RD1 (grow): "));
  960. CM_Get_Next_Res_Des(&ResDes1, BasicLC1, ResType_All, &ResType, 0);
  961. Status = CM_Modify_Res_Des(&ResDes1, ResDes1, ResType_IRQ, pIrqRes,
  962. sizeof(IRQ_RESOURCE) + sizeof(IRQ_RANGE) * 2, 0);
  963. if (Status != CR_SUCCESS) {
  964. wsprintf(szMsg1, TEXT("Failed (%xh)"), Status);
  965. }
  966. else wsprintf(szMsg1, TEXT("Passed"));
  967. lstrcat(szMsg, szMsg1);
  968. SendDlgItemMessage(
  969. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  970. (LPARAM)(LPTSTR)szMsg);
  971. // null out header for comparison
  972. pIrqRes->IRQ_Header.IRQD_Flags = 0;
  973. pIrqRes->IRQ_Header.IRQD_Alloc_Num = 0;
  974. CM_Get_Res_Des_Data_Size(&ulSize, ResDes1, 0);
  975. pData = malloc(ulSize);
  976. CM_Get_Res_Des_Data(ResDes1, pData, ulSize, 0);
  977. if (memcmp(pData, pIrqRes, ulSize) != 0) {
  978. wsprintf(szMsg, TEXT("BASIC LC2-RD1 Data is NOT correct"));
  979. }
  980. else wsprintf(szMsg, TEXT("BASIC LC2-RD1 Data is correct"));
  981. free(pData);
  982. SendDlgItemMessage(
  983. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  984. (LPARAM)(LPTSTR)szMsg);
  985. // reset header back
  986. pIrqRes->IRQ_Header.IRQD_Flags = fDD_DWORD;
  987. pIrqRes->IRQ_Header.IRQD_Alloc_Num = (DWORDLONG)11;
  988. wsprintf(szMsg, TEXT("Modify Boot LC2-RD2 (shrink CS): "));
  989. CM_Get_Next_Res_Des(&ResDes2, BootLC2, ResType_ClassSpecific, &ResType, 0);
  990. Status = CM_Modify_Res_Des(&ResDes2, ResDes2, ResType_ClassSpecific, pCs1Res,
  991. sizeof(CS_RESOURCE) + 15, 0);
  992. if (Status != CR_SUCCESS) {
  993. wsprintf(szMsg1, TEXT("Failed (%xh)"), Status);
  994. }
  995. else wsprintf(szMsg1, TEXT("Passed"));
  996. lstrcat(szMsg, szMsg1);
  997. SendDlgItemMessage(
  998. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  999. (LPARAM)(LPTSTR)szMsg);
  1000. CM_Get_Res_Des_Data_Size(&ulSize, ResDes2, 0);
  1001. pData = malloc(ulSize);
  1002. CM_Get_Res_Des_Data(ResDes2, pData, ulSize, 0);
  1003. if (ulSize != sizeof(CS_RESOURCE) + 15 ||
  1004. memcmp(pData, pCs1Res, ulSize) != 0) {
  1005. wsprintf(szMsg, TEXT("BOOT LC2-RD2 Data is NOT correct"));
  1006. }
  1007. else wsprintf(szMsg, TEXT("BOOT LC2-RD2 Data is correct"));
  1008. free(pData);
  1009. SendDlgItemMessage(
  1010. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  1011. (LPARAM)(LPTSTR)szMsg);
  1012. MessageBox(hDlg, TEXT("Check registry contents"), TEXT("CMTEST"), MB_OK);
  1013. //---------------------------------------------------------------
  1014. // Free res des test
  1015. //---------------------------------------------------------------
  1016. // delete rd2 and rd1 from lc2
  1017. CM_Get_Next_Res_Des(&ResDes2, BootLC2, ResType_ClassSpecific, &ResType, 0);
  1018. CM_Free_Res_Des(&ResDes1, ResDes2, 0);
  1019. CM_Free_Res_Des(&BootLC2, ResDes1, 0);
  1020. // delete rd1 from lc3
  1021. CM_Get_Next_Res_Des(&ResDes1, BootLC3, ResType_All, &ResType, 0);
  1022. CM_Free_Res_Des(&BootLC3, ResDes1, 0);
  1023. // delete rd2 from lc3
  1024. CM_Get_Next_Res_Des(&ResDes1, BootLC3, ResType_All, &ResType, 0);
  1025. CM_Free_Res_Des(&BootLC3, ResDes1, 0);
  1026. // delete rd2 and rd1 from lc1
  1027. CM_Get_Next_Res_Des(&ResDes2, BootLC1, ResType_ClassSpecific, &ResType, 0);
  1028. CM_Free_Res_Des(&ResDes1, ResDes2, 0);
  1029. CM_Free_Res_Des(&BootLC1, ResDes1, 0);
  1030. MessageBox(hDlg, TEXT("Check registry contents"), TEXT("CMTEST"), MB_OK);
  1031. //---------------------------------------------------------------
  1032. // Free LC Test
  1033. //---------------------------------------------------------------
  1034. if (MessageBox(hDlg,
  1035. TEXT("Free all the log confs that were just created?"),
  1036. TEXT("CMTest"), MB_YESNO) == IDYES) {
  1037. lstrcpy(szMsg, TEXT("Test free Boot Config LC2: "));
  1038. Status = CM_Free_Log_Conf(BootLC2, 0);
  1039. if (Status != CR_SUCCESS) {
  1040. wsprintf(szMsg1, TEXT("Failed (%xh)"), Status);
  1041. }
  1042. else wsprintf(szMsg1, TEXT("Passed"));
  1043. lstrcat(szMsg, szMsg1);
  1044. SendDlgItemMessage(
  1045. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  1046. (LPARAM)(LPTSTR)szMsg);
  1047. lstrcpy(szMsg, TEXT("Test free Boot Config LC3: "));
  1048. Status = CM_Free_Log_Conf(BootLC3, 0);
  1049. if (Status != CR_SUCCESS) {
  1050. wsprintf(szMsg1, TEXT("Failed (%xh)"), Status);
  1051. }
  1052. else wsprintf(szMsg1, TEXT("Passed"));
  1053. lstrcat(szMsg, szMsg1);
  1054. SendDlgItemMessage(
  1055. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  1056. (LPARAM)(LPTSTR)szMsg);
  1057. lstrcpy(szMsg, TEXT("Test free Boot Config LC1: "));
  1058. Status = CM_Free_Log_Conf(BootLC1, 0);
  1059. if (Status != CR_SUCCESS) {
  1060. wsprintf(szMsg1, TEXT("Failed (%xh)"), Status);
  1061. }
  1062. else wsprintf(szMsg1, TEXT("Passed"));
  1063. lstrcat(szMsg, szMsg1);
  1064. SendDlgItemMessage(
  1065. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  1066. (LPARAM)(LPTSTR)szMsg);
  1067. lstrcpy(szMsg, TEXT("Test free Basic Config LC2: "));
  1068. Status = CM_Free_Log_Conf(BasicLC2, 0);
  1069. if (Status != CR_SUCCESS) {
  1070. wsprintf(szMsg1, TEXT("Failed (%xh)"), Status);
  1071. }
  1072. else wsprintf(szMsg1, TEXT("Passed"));
  1073. lstrcat(szMsg, szMsg1);
  1074. SendDlgItemMessage(
  1075. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  1076. (LPARAM)(LPTSTR)szMsg);
  1077. lstrcpy(szMsg, TEXT("Test free Basic Config LC3: "));
  1078. Status = CM_Free_Log_Conf(BasicLC3, 0);
  1079. if (Status != CR_SUCCESS) {
  1080. wsprintf(szMsg1, TEXT("Failed (%xh)"), Status);
  1081. }
  1082. else wsprintf(szMsg1, TEXT("Passed"));
  1083. lstrcat(szMsg, szMsg1);
  1084. SendDlgItemMessage(
  1085. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  1086. (LPARAM)(LPTSTR)szMsg);
  1087. lstrcpy(szMsg, TEXT("Test free Basic Config LC1: "));
  1088. Status = CM_Free_Log_Conf(BasicLC1, 0);
  1089. if (Status != CR_SUCCESS) {
  1090. wsprintf(szMsg1, TEXT("Failed (%xh)"), Status);
  1091. }
  1092. else wsprintf(szMsg1, TEXT("Passed"));
  1093. lstrcat(szMsg, szMsg1);
  1094. SendDlgItemMessage(
  1095. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  1096. (LPARAM)(LPTSTR)szMsg);
  1097. }
  1098. //----------------------------------------------------------------
  1099. // Free Log config handles
  1100. //----------------------------------------------------------------
  1101. lstrcpy(szMsg, TEXT("Test free handle LC1: "));
  1102. Status = CM_Free_Log_Conf_Handle(BootLC1);
  1103. if (Status != CR_SUCCESS) {
  1104. wsprintf(szMsg1, TEXT("Failed (%xh)"), Status);
  1105. }
  1106. else lstrcpy(szMsg1, TEXT("Passed"));
  1107. lstrcat(szMsg, szMsg1);
  1108. SendDlgItemMessage(
  1109. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  1110. (LPARAM)(LPTSTR)szMsg);
  1111. lstrcpy(szMsg, TEXT("Test free handle LC2: "));
  1112. Status = CM_Free_Log_Conf_Handle(BootLC2);
  1113. if (Status != CR_SUCCESS) {
  1114. wsprintf(szMsg1, TEXT("Failed (%xh)"), Status);
  1115. }
  1116. else lstrcpy(szMsg1, TEXT("Passed"));
  1117. lstrcat(szMsg, szMsg1);
  1118. SendDlgItemMessage(
  1119. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  1120. (LPARAM)(LPTSTR)szMsg);
  1121. lstrcpy(szMsg, TEXT("Test free handle LC3: "));
  1122. Status = CM_Free_Log_Conf_Handle(BootLC3);
  1123. if (Status != CR_SUCCESS) {
  1124. wsprintf(szMsg1, TEXT("Failed (%xh)"), Status);
  1125. }
  1126. else lstrcpy(szMsg1, TEXT("Passed"));
  1127. lstrcat(szMsg, szMsg1);
  1128. SendDlgItemMessage(
  1129. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  1130. (LPARAM)(LPTSTR)szMsg);
  1131. lstrcpy(szMsg, TEXT("Test freeing already freed handle: "));
  1132. Status = CM_Free_Log_Conf_Handle(BootLC2);
  1133. if (Status != CR_INVALID_LOG_CONF) {
  1134. wsprintf(szMsg1, TEXT("Failed (%xh)"), Status);
  1135. }
  1136. else lstrcpy(szMsg1, TEXT("Passed"));
  1137. lstrcat(szMsg, szMsg1);
  1138. SendDlgItemMessage(
  1139. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  1140. (LPARAM)(LPTSTR)szMsg);
  1141. lstrcpy(szMsg, TEXT("Test freeing invalid config handle: "));
  1142. BootLC2 = 1;
  1143. Status = CM_Free_Log_Conf_Handle(BootLC2);
  1144. if (Status != CR_FAILURE) {
  1145. wsprintf(szMsg1, TEXT("Failed (%xh)"), Status);
  1146. }
  1147. else lstrcpy(szMsg1, TEXT("Passed"));
  1148. lstrcat(szMsg, szMsg1);
  1149. SendDlgItemMessage(
  1150. hDlg, ID_LB_REGRESSION, LB_ADDSTRING, 0,
  1151. (LPARAM)(LPTSTR)szMsg);
  1152. if (pMemRes != NULL) free(pMemRes);
  1153. if (pIoRes != NULL) free(pIoRes);
  1154. if (pCs1Res != NULL) free(pCs1Res);
  1155. if (pCs2Res != NULL) free(pCs2Res);
  1156. if (pDmaRes != NULL) free(pDmaRes);
  1157. if (pIrqRes != NULL) free(pIrqRes);
  1158. return;
  1159. } // RegressionTest_LogConf
  1160. VOID
  1161. SpecialCase_LogConf(
  1162. DEVNODE dnDevNode
  1163. )
  1164. {
  1165. CONFIGRET Status;
  1166. LOG_CONF BootLC1, BasicLC1;
  1167. RES_DES ResDes;
  1168. PCS_DES pResourceData;
  1169. ULONG ulSize = 0;
  1170. BYTE i;
  1171. PMEM_RESOURCE pMemRes = NULL;
  1172. PCS_RESOURCE pCs1Res = NULL;
  1173. RESOURCEID ResourceID;
  1174. LPBYTE pBuffer = NULL, pData = NULL;
  1175. //
  1176. // fill out an arbitrary class specific structure
  1177. //
  1178. pCs1Res = malloc(sizeof(CS_RESOURCE) + 15); //16-1
  1179. pCs1Res->CS_Header.CSD_SignatureLength = 16;
  1180. pCs1Res->CS_Header.CSD_LegacyDataOffset = 0;
  1181. pCs1Res->CS_Header.CSD_LegacyDataSize = 0;
  1182. pCs1Res->CS_Header.CSD_Flags = 0;
  1183. CM_Enumerate_Classes(0, &(pCs1Res->CS_Header.CSD_ClassGuid), 0);
  1184. for (i = 0; i < 16; i++) {
  1185. pCs1Res->CS_Header.CSD_Signature[i] = i;
  1186. }
  1187. CM_Add_Empty_Log_Conf(&BootLC1, dnDevNode, LCPRI_BOOTCONFIG, BOOT_LOG_CONF);
  1188. CM_Add_Res_Des(&ResDes, BootLC1, ResType_ClassSpecific, pCs1Res, sizeof(CS_RESOURCE)+15, 0);
  1189. CM_Free_Res_Des(NULL, ResDes, 0);
  1190. // This last one returns CR_INVALID_RES_DES.
  1191. CM_Get_Next_Res_Des(&ResDes, BootLC1, ResType_ClassSpecific, NULL, 0);
  1192. CM_Free_Res_Des( NULL, ResDes, 0);
  1193. // This last one returns CR_INVALID_RES_DES.
  1194. //Paula, once we're here: is it OK that now for the last resource freed the result will be CR_SUCESS instead CR_NO_MORE_RES_DES ?
  1195. /*
  1196. 1. If you try to free the first res des in a BASIC (FILTERED, OVERRIDE) log conf, this will
  1197. succees with CR_SUCCESS every time, even it's the only res des added (a subsequent
  1198. CM_Get_Next_Res_Des(..., lcLogConf, ...) will return CR_NO_MORE_RES_DES).
  1199. 2. If there are two res des for the same log conf (I tried with two identical memory
  1200. res des, each with MD_Count == 1, BASIC log conf) and you free the first one, when you
  1201. try to retrieve the remaining one (with CM_Get_Next_Res_Des(...,lcLogConf,...) the
  1202. resource type field (pResourceId) is set to 0, causing the next free to fail. More precisely:
  1203. */
  1204. pMemRes = malloc(sizeof(MEM_RESOURCE) + sizeof(MEM_RANGE));
  1205. pMemRes->MEM_Header.MD_Count = 2;
  1206. pMemRes->MEM_Header.MD_Type = MType_Range;
  1207. pMemRes->MEM_Header.MD_Alloc_Base = (DWORDLONG)0xD8000;
  1208. pMemRes->MEM_Header.MD_Alloc_End = (DWORDLONG)0xD9000;
  1209. pMemRes->MEM_Header.MD_Flags = fMD_ROM | fMD_32 | fMD_ReadAllowed;
  1210. pMemRes->MEM_Header.MD_Reserved = 0;
  1211. pMemRes->MEM_Data[0].MR_Align = 8; //?
  1212. pMemRes->MEM_Data[0].MR_nBytes = 4096;
  1213. pMemRes->MEM_Data[0].MR_Min = (DWORDLONG)0xD8000;
  1214. pMemRes->MEM_Data[0].MR_Max = (DWORDLONG)0xDC000;
  1215. pMemRes->MEM_Data[0].MR_Flags = fMD_ROM | fMD_32 | fMD_ReadAllowed;
  1216. pMemRes->MEM_Data[0].MR_Reserved = 0;
  1217. pMemRes->MEM_Data[1].MR_Align = 8; //?
  1218. pMemRes->MEM_Data[1].MR_nBytes = 4096;
  1219. pMemRes->MEM_Data[1].MR_Min = (DWORDLONG)0xE0000;
  1220. pMemRes->MEM_Data[1].MR_Max = (DWORDLONG)0xE4000;
  1221. pMemRes->MEM_Data[1].MR_Flags = fMD_ROM | fMD_32 | fMD_ReadAllowed;
  1222. pMemRes->MEM_Data[1].MR_Reserved = 0;
  1223. CM_Add_Empty_Log_Conf(&BasicLC1, dnDevNode, LCPRI_NORMAL, BASIC_LOG_CONF);
  1224. CM_Add_Res_Des(&ResDes, BasicLC1, ResType_Mem, pMemRes, sizeof(MEM_RESOURCE) + sizeof(MEM_RANGE), 0);
  1225. CM_Free_Res_Des_Handle(ResDes);
  1226. CM_Add_Res_Des(&ResDes, BasicLC1, ResType_Mem, pMemRes, sizeof(MEM_RESOURCE) + sizeof(MEM_RANGE), 0);
  1227. CM_Free_Res_Des_Handle(ResDes);
  1228. CM_Get_Next_Res_Des(&ResDes, BasicLC1, ResType_All, &ResourceID, 0);
  1229. //
  1230. // returns CR_SUCCESS, ridRseourceID is 1 (memory)
  1231. //
  1232. CM_Free_Res_Des(&ResDes, ResDes, 0);
  1233. //
  1234. // returns CR_SUCCESS
  1235. //
  1236. CM_Get_Next_Res_Des(&ResDes, BasicLC1, ResType_All, &ResourceID, 0);
  1237. //
  1238. // This one returns CR_SUCCESS, but ridResourceID is 0, so the next free will fail
  1239. //
  1240. }