Skip to content

Commit 6dadae6

Browse files
committed
[HAL] Fix BCD conversion macro
- Evaluate macro parameter only once - Remove the stdcall calling convention from private functions for PC-98
1 parent 5a43991 commit 6dadae6

2 files changed

Lines changed: 25 additions & 24 deletions

File tree

hal/halx86/include/halp.h

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,21 @@ VOID
6767
#define HALP_LOW_STUB_SIZE_IN_PAGES 3
6868
#endif
6969

70-
/* Conversion functions */
71-
#define BCD_INT(bcd) \
72-
(((bcd & 0xF0) >> 4) * 10 + (bcd & 0x0F))
73-
#define INT_BCD(int) \
74-
(UCHAR)(((int / 10) << 4) + (int % 10))
70+
FORCEINLINE
71+
UCHAR
72+
BCD_INT(
73+
_In_ UCHAR Bcd)
74+
{
75+
return ((Bcd & 0xF0) >> 4) * 10 + (Bcd & 0x0F);
76+
}
77+
78+
FORCEINLINE
79+
UCHAR
80+
INT_BCD(
81+
_In_ CSHORT Int)
82+
{
83+
return ((Int / 10) << 4) + (Int % 10);
84+
}
7585

7686
typedef
7787
BOOLEAN

hal/halx86/pc98/cmos.c

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,26 +33,17 @@ static ULONG_PTR MappedNvram;
3333

3434
/* PRIVATE FUNCTIONS *********************************************************/
3535

36-
/* Avoid double calls */
37-
#undef BCD_INT
38-
static UCHAR
39-
BCD_INT(
40-
_In_ UCHAR Bcd)
41-
{
42-
return ((Bcd & 0xF0) >> 4) * 10 + (Bcd & 0x0F);
43-
}
44-
45-
static UCHAR
46-
NTAPI
36+
static
37+
UCHAR
4738
HalpReadNvram(
4839
_In_ UCHAR Register)
4940
{
5041
return READ_REGISTER_UCHAR((PUCHAR)(MappedNvram + Register));
5142
}
5243

5344
_Requires_lock_held_(HalpSystemHardwareLock)
54-
static VOID
55-
NTAPI
45+
static
46+
VOID
5647
HalpWriteNvram(
5748
_In_ UCHAR Register,
5849
_In_ UCHAR Value)
@@ -63,8 +54,8 @@ HalpWriteNvram(
6354
}
6455

6556
_Requires_lock_held_(HalpSystemHardwareLock)
66-
static UCHAR
67-
NTAPI
57+
static
58+
UCHAR
6859
HalpRtcReadByte(VOID)
6960
{
7061
UCHAR i;
@@ -86,8 +77,8 @@ HalpRtcReadByte(VOID)
8677
}
8778

8879
_Requires_lock_held_(HalpSystemHardwareLock)
89-
static VOID
90-
NTAPI
80+
static
81+
VOID
9182
HalpRtcWriteBit(
9283
_In_ UCHAR Bit)
9384
{
@@ -101,8 +92,8 @@ HalpRtcWriteBit(
10192
}
10293

10394
_Requires_lock_held_(HalpSystemHardwareLock)
104-
static VOID
105-
NTAPI
95+
static
96+
VOID
10697
HalpRtcWriteCommand(
10798
_In_ UCHAR Command)
10899
{

0 commit comments

Comments
 (0)