- if (*GtdtPlatformTimerCount != 0) {\r
- TimerPtr = Ptr + (*GtdtPlatformTimerOffset);\r
- Index = 0;\r
- do {\r
- // Parse the Platform Timer Header\r
- ParseAcpi (\r
- FALSE,\r
- 0,\r
- NULL,\r
- TimerPtr,\r
- 4, // GT Platform Timer structure header length.\r
- PARSER_PARAMS (GtPlatformTimerHeaderParser)\r
+ TimerPtr = Ptr + *GtdtPlatformTimerOffset;\r
+ Offset = *GtdtPlatformTimerOffset;\r
+ Index = 0;\r
+\r
+ // Parse the specified number of Platform Timer Structures or the GTDT\r
+ // buffer length. Whichever is minimum.\r
+ while ((Index++ < *GtdtPlatformTimerCount) &&\r
+ (Offset < AcpiTableLength)) {\r
+ // Parse the Platform Timer Header to obtain Length and Type\r
+ ParseAcpi (\r
+ FALSE,\r
+ 0,\r
+ NULL,\r
+ TimerPtr,\r
+ AcpiTableLength - Offset,\r
+ PARSER_PARAMS (GtPlatformTimerHeaderParser)\r
+ );\r
+\r
+ // Make sure the Platform Timer is inside the table.\r
+ if ((Offset + *PlatformTimerLength) > AcpiTableLength) {\r
+ IncrementErrorCount ();\r
+ Print (\r
+ L"ERROR: Invalid Platform Timer Structure length. " \\r
+ L"PlatformTimerLength = %d. RemainingTableBufferLength = %d. " \\r
+ L"GTDT parsing aborted.\n",\r
+ *PlatformTimerLength,\r
+ AcpiTableLength - Offset\r