[ros-diffs] [greatlrd] 25117: commit the patch from bug 1874 even it does not use the RDMSR and WRMSR measure methood, we need use the RDMSR and WRMSR for dual core and CPU support it see Intel documentations AP-485, who u should do it. The patch is from HTO Bugfix detections of RTSC support for single and dual core by me, adding check if the CPU support RDMSR and WRMSR and send a true or false value to GetCpuSpeed, so we known which method we should use. HTO patch should be use when it is false. other wise we should use the RDMSR and WRMSR measure method See issue #1874 for more details.
greatlrd at svn.reactos.org
greatlrd at svn.reactos.org
Sun Dec 10 18:39:02 CET 2006
- Previous message: [ros-diffs] [peterw] 25116: - Added -x1 option to output the number of CPUs + 1.
- Next message: [ros-diffs] [ion] 25118: - Fix SleepEx. - Put volatile statements in EX_RUNDOWN_REF, IRP, DEVICE_OBJECT, ERESOURCE, FILE_OBJECT, IO_REMOVE_LOCK, WORK_QUEUE_ITEM where required (thanks to Microsoft's changes in the WDK to mark the fields properly). - Update FILE_OBJECT definition. - Add some asserts to some I/O functions. - Add stub support for File Objects created by XP+ Drivers which have File Object Extensions. - Add some fixes to IopDeleteFile, including proper reference counting for the DO and VPB, as well as cleanup when the file is closed without a handle. - Fix a bug in IopSecurityFile. - Queue and unqueue IRPs in all I/O functions. - Fully support IRP cancellation now. - Fix critical bugs in NtDeviceIoControlFile and NtDeviceFsControlFile which were causing double queueing of IRPs and freeing of invalid memory, as well as invalid paramter checking for user-mode buffers. - Add exhaustive validation checks to IoCreateFile, add more failure cases, and validate the EA buffer. Also support IO_ATTACH_DEVICE_API flag. - Implement IoCreateStreamFileObjectEx and IoCreateStreamFileObjectLite and fix several bugs in the original implementation of IoCreateStreamFileObject. - Fix a bug in RtlRaiseException. - Update Io*ShareAccess routines to support XP+ style semantics related to special File Object flags which disable their use. - Add validation to all Query/Set routines so that information clasess, lengths, buffers and alignment are properly checked. - Also add an array for the proper acess rights that each query/set operation requires. - Check backup/restore privileges during I/O File operations. - Check traverse access during I/O File Operations. - Check access privileges to the device during I/O file operations. - Rename IopReferenceDeviceObject and also verify if an exclusive DO is trying to be invalidly opened. - Support various extra security checks during I/O File/Device Parse Routine. - Fix a bug during IopCleanupIrp so that we don't dereference the File OBject if this was a create operation. - Fix some bogus asserts in IofCompleteRequest, and save the IRP Flags before signalling it's event, since the driver might've freed it behind our back. - Fix a large bug in ObInsertObject which affected the insert of unnamed objects with forced security options (Such as process/threads). - Fix the creation of the Process/Thread/Job Obejct Types to that security information is forced. - Remove "Fix PS!!!" messages since the bug is now fixed and these objects now get proper security descriptors. - Fix another bug in ObInsertObjet which wasn't properly validating user-mode objects and always assumed kernel mode. - Silence multiple trace/checkpoint messages that have accumulated throughout time for various debugging purposes.
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Author: greatlrd
Date: Sun Dec 10 20:39:01 2006
New Revision: 25117
URL: http://svn.reactos.org/svn/reactos?rev=25117&view=rev
Log:
commit the patch from bug 1874 even it does not use the RDMSR and WRMSR measure methood, we need use the RDMSR and WRMSR for dual core and CPU support it see Intel documentations AP-485, who u should do it. The patch is from HTO Bugfix detections of RTSC support for single and dual core by me, adding check if the CPU support RDMSR and WRMSR and send a true or false value to GetCpuSpeed, so we known which method we should use. HTO patch should be use when it is false. other wise we should use the RDMSR and WRMSR measure method
See issue #1874 for more details.
Modified:
trunk/reactos/boot/freeldr/freeldr/arch/i386/hwcpu.c
Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/hwcpu.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/i386/hwcpu.c?rev=25117&r1=25116&r2=25117&view=diff
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/arch/i386/hwcpu.c (original)
+++ trunk/reactos/boot/freeldr/freeldr/arch/i386/hwcpu.c Sun Dec 10 20:39:01 2006
@@ -24,6 +24,12 @@
#define NDEBUG
#include <debug.h>
+#define HZ (100)
+#define CLOCK_TICK_RATE (1193182)
+#define LATCH (CLOCK_TICK_RATE / HZ)
+#define CALIBRATE_LATCH (5 * LATCH)
+#define CALIBRATE_TIME (5 * 1000020/HZ)
+
#define MP_FP_SIGNATURE 0x5F504D5F /* "_MP_" */
#define MP_CT_SIGNATURE 0x504D4350 /* "PCMP" */
@@ -73,17 +79,44 @@
/* FUNCTIONS ****************************************************************/
static ULONG
-GetCpuSpeed(VOID)
+GetCpuSpeed(BOOLEAN DualCoreSpeedMesure)
{
ULONGLONG Timestamp1;
ULONGLONG Timestamp2;
ULONGLONG Diff;
+ ULONG Count = 0;
+
+ /*
+ FIXME
+ if the DualCoreSpeedMesure is true we need
+ use the wrmsr and rdmsr to mesure the speed
+
+ The rdtc are outdate to use if cpu support
+ the wrmsr and rdmsr, see intel doc AP-485
+ for more informations and how to use it.
+
+ Follow code is good on cpu that does not
+ support dual core or have a mmx unit or
+ more.
+ */
+
+
+ /* Initialise timer channel 2 */
+ /* Set the Gate high, disable speaker */
+ WRITE_PORT_UCHAR((PUCHAR)0x61, (READ_PORT_UCHAR((PUCHAR)0x61) & ~0x02) | 0x01);
+ WRITE_PORT_UCHAR((PUCHAR)0x43, 0xB0); /* binary, mode 0, LSB/MSB, ch 2 */
+ WRITE_PORT_UCHAR((PUCHAR)0x42, CALIBRATE_LATCH & 0xff); /* LSB */
+ WRITE_PORT_UCHAR((PUCHAR)0x42, CALIBRATE_LATCH >> 8); /* MSB */
/* Read TSC (Time Stamp Counter) */
Timestamp1 = RDTSC();
- /* Wait for 0.1 seconds (= 100 milliseconds = 100000 microseconds)*/
- StallExecutionProcessor(100000);
+ /* Wait */
+ do
+ {
+ Count++;
+ }
+ while ((READ_PORT_UCHAR((PUCHAR)0x61) & 0x20) == 0);
/* Read TSC (Time Stamp Counter) again */
Timestamp2 = RDTSC();
@@ -98,7 +131,7 @@
Diff = Timestamp2 + (((ULONGLONG)-1) - Timestamp1);
}
- return (ULONG)(Diff / 100000);
+ return (ULONG)(Diff / CALIBRATE_TIME);
}
@@ -123,7 +156,7 @@
LONG Error;
BOOLEAN SupportTSC = FALSE;
ULONG CpuSpeed;
-
+ BOOLEAN DualCoreSpeedMesure = FALSE;
/* Create the CPU instance key */
Error = RegCreateKey(CpuKey,
@@ -169,8 +202,12 @@
(unsigned int)((eax >> 4) & 0x0F),
(unsigned int)(eax & 0x0F));
FeatureSet = edx;
- if (((eax >> 8) & 0x0F) >= 5)
+
+ if ((FeatureSet & 0x10) == 0x10)
SupportTSC = TRUE;
+
+ if ((FeatureSet & 0x20) == 0x20)
+ DualCoreSpeedMesure = TRUE;
/* Check if Extended CPUID information is supported */
GetCpuid(0x80000000, &eax, &ebx, &ecx, &edx);
@@ -283,7 +320,7 @@
/* Set '~MHz' value (CPU only) */
if (SupportTSC)
{
- CpuSpeed = GetCpuSpeed();
+ CpuSpeed = GetCpuSpeed(DualCoreSpeedMesure);
Error = RegSetValue(CpuInstKey,
L"~MHz",
@@ -467,9 +504,19 @@
/* FIXME: Set 'Update Status' value (CPU only) */
/* Set '~MHz' value (CPU only) */
- if (((CpuEntry->CpuSignature >> 8) & 0x0F) >= 5)
- {
- CpuSpeed = GetCpuSpeed();
+
+
+ if ((CpuEntry->FeatureFlags & 0x10) == 0x10)
+ {
+ if ((CpuEntry->FeatureFlags & 0x20) == 0x20)
+ {
+ CpuSpeed = GetCpuSpeed(TRUE);
+ }
+ else
+ {
+ DbgPrint((DPRINT_HWDETECT, "Does not support MSR that are need for mesure the speed correct\n", (int)Error));
+ CpuSpeed = GetCpuSpeed(FALSE);
+ }
Error = RegSetValue(CpuInstKey,
L"~MHz",
@@ -477,10 +524,11 @@
(PCHAR)&CpuSpeed,
sizeof(ULONG));
if (Error != ERROR_SUCCESS)
- {
- DbgPrint((DPRINT_HWDETECT, "RegSetValue() failed (Error %u)\n", (int)Error));
- }
- }
+ {
+
+ DbgPrint((DPRINT_HWDETECT, "RegSetValue() failed (Error %u)\n", (int)Error));
+ }
+ }
}
- Previous message: [ros-diffs] [peterw] 25116: - Added -x1 option to output the number of CPUs + 1.
- Next message: [ros-diffs] [ion] 25118: - Fix SleepEx. - Put volatile statements in EX_RUNDOWN_REF, IRP, DEVICE_OBJECT, ERESOURCE, FILE_OBJECT, IO_REMOVE_LOCK, WORK_QUEUE_ITEM where required (thanks to Microsoft's changes in the WDK to mark the fields properly). - Update FILE_OBJECT definition. - Add some asserts to some I/O functions. - Add stub support for File Objects created by XP+ Drivers which have File Object Extensions. - Add some fixes to IopDeleteFile, including proper reference counting for the DO and VPB, as well as cleanup when the file is closed without a handle. - Fix a bug in IopSecurityFile. - Queue and unqueue IRPs in all I/O functions. - Fully support IRP cancellation now. - Fix critical bugs in NtDeviceIoControlFile and NtDeviceFsControlFile which were causing double queueing of IRPs and freeing of invalid memory, as well as invalid paramter checking for user-mode buffers. - Add exhaustive validation checks to IoCreateFile, add more failure cases, and validate the EA buffer. Also support IO_ATTACH_DEVICE_API flag. - Implement IoCreateStreamFileObjectEx and IoCreateStreamFileObjectLite and fix several bugs in the original implementation of IoCreateStreamFileObject. - Fix a bug in RtlRaiseException. - Update Io*ShareAccess routines to support XP+ style semantics related to special File Object flags which disable their use. - Add validation to all Query/Set routines so that information clasess, lengths, buffers and alignment are properly checked. - Also add an array for the proper acess rights that each query/set operation requires. - Check backup/restore privileges during I/O File operations. - Check traverse access during I/O File Operations. - Check access privileges to the device during I/O file operations. - Rename IopReferenceDeviceObject and also verify if an exclusive DO is trying to be invalidly opened. - Support various extra security checks during I/O File/Device Parse Routine. - Fix a bug during IopCleanupIrp so that we don't dereference the File OBject if this was a create operation. - Fix some bogus asserts in IofCompleteRequest, and save the IRP Flags before signalling it's event, since the driver might've freed it behind our back. - Fix a large bug in ObInsertObject which affected the insert of unnamed objects with forced security options (Such as process/threads). - Fix the creation of the Process/Thread/Job Obejct Types to that security information is forced. - Remove "Fix PS!!!" messages since the bug is now fixed and these objects now get proper security descriptors. - Fix another bug in ObInsertObjet which wasn't properly validating user-mode objects and always assumed kernel mode. - Silence multiple trace/checkpoint messages that have accumulated throughout time for various debugging purposes.
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Ros-diffs
mailing list