Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
qemu
提交
abd0c6bd
Q
qemu
项目概览
openeuler
/
qemu
通知
10
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Q
qemu
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
abd0c6bd
编写于
11月 20, 2009
作者:
P
Paul Brook
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
BCD cleanup
Combine multiple BCD implementations. Signed-off-by:
N
Paul Brook
<
paul@codesourcery.com
>
上级
a992fe3d
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
79 addition
and
98 deletion
+79
-98
hw/m48t59.c
hw/m48t59.c
+20
-30
hw/mc146818rtc.c
hw/mc146818rtc.c
+18
-18
hw/omap1.c
hw/omap1.c
+30
-40
hw/twl92230.c
hw/twl92230.c
+0
-10
qemu-common.h
qemu-common.h
+11
-0
未找到文件。
hw/m48t59.c
浏览文件 @
abd0c6bd
...
...
@@ -80,16 +80,6 @@ typedef struct M48t59SysBusState {
}
M48t59SysBusState
;
/* Fake timer functions */
/* Generic helpers for BCD */
static
inline
uint8_t
toBCD
(
uint8_t
value
)
{
return
(((
value
/
10
)
%
10
)
<<
4
)
|
(
value
%
10
);
}
static
inline
uint8_t
fromBCD
(
uint8_t
BCD
)
{
return
((
BCD
>>
4
)
*
10
)
+
(
BCD
&
0x0F
);
}
/* Alarm management */
static
void
alarm_cb
(
void
*
opaque
)
...
...
@@ -219,7 +209,7 @@ void m48t59_write (void *opaque, uint32_t addr, uint32_t val)
break
;
case
0x1FF2
:
/* alarm seconds */
tmp
=
from
BCD
(
val
&
0x7F
);
tmp
=
from
_bcd
(
val
&
0x7F
);
if
(
tmp
>=
0
&&
tmp
<=
59
)
{
NVRAM
->
alarm
.
tm_sec
=
tmp
;
NVRAM
->
buffer
[
0x1FF2
]
=
val
;
...
...
@@ -228,7 +218,7 @@ void m48t59_write (void *opaque, uint32_t addr, uint32_t val)
break
;
case
0x1FF3
:
/* alarm minutes */
tmp
=
from
BCD
(
val
&
0x7F
);
tmp
=
from
_bcd
(
val
&
0x7F
);
if
(
tmp
>=
0
&&
tmp
<=
59
)
{
NVRAM
->
alarm
.
tm_min
=
tmp
;
NVRAM
->
buffer
[
0x1FF3
]
=
val
;
...
...
@@ -237,7 +227,7 @@ void m48t59_write (void *opaque, uint32_t addr, uint32_t val)
break
;
case
0x1FF4
:
/* alarm hours */
tmp
=
from
BCD
(
val
&
0x3F
);
tmp
=
from
_bcd
(
val
&
0x3F
);
if
(
tmp
>=
0
&&
tmp
<=
23
)
{
NVRAM
->
alarm
.
tm_hour
=
tmp
;
NVRAM
->
buffer
[
0x1FF4
]
=
val
;
...
...
@@ -246,7 +236,7 @@ void m48t59_write (void *opaque, uint32_t addr, uint32_t val)
break
;
case
0x1FF5
:
/* alarm date */
tmp
=
from
BCD
(
val
&
0x1F
);
tmp
=
from
_bcd
(
val
&
0x1F
);
if
(
tmp
!=
0
)
{
NVRAM
->
alarm
.
tm_mday
=
tmp
;
NVRAM
->
buffer
[
0x1FF5
]
=
val
;
...
...
@@ -270,7 +260,7 @@ void m48t59_write (void *opaque, uint32_t addr, uint32_t val)
case
0x1FF9
:
case
0x07F9
:
/* seconds (BCD) */
tmp
=
from
BCD
(
val
&
0x7F
);
tmp
=
from
_bcd
(
val
&
0x7F
);
if
(
tmp
>=
0
&&
tmp
<=
59
)
{
get_time
(
NVRAM
,
&
tm
);
tm
.
tm_sec
=
tmp
;
...
...
@@ -289,7 +279,7 @@ void m48t59_write (void *opaque, uint32_t addr, uint32_t val)
case
0x1FFA
:
case
0x07FA
:
/* minutes (BCD) */
tmp
=
from
BCD
(
val
&
0x7F
);
tmp
=
from
_bcd
(
val
&
0x7F
);
if
(
tmp
>=
0
&&
tmp
<=
59
)
{
get_time
(
NVRAM
,
&
tm
);
tm
.
tm_min
=
tmp
;
...
...
@@ -299,7 +289,7 @@ void m48t59_write (void *opaque, uint32_t addr, uint32_t val)
case
0x1FFB
:
case
0x07FB
:
/* hours (BCD) */
tmp
=
from
BCD
(
val
&
0x3F
);
tmp
=
from
_bcd
(
val
&
0x3F
);
if
(
tmp
>=
0
&&
tmp
<=
23
)
{
get_time
(
NVRAM
,
&
tm
);
tm
.
tm_hour
=
tmp
;
...
...
@@ -309,7 +299,7 @@ void m48t59_write (void *opaque, uint32_t addr, uint32_t val)
case
0x1FFC
:
case
0x07FC
:
/* day of the week / century */
tmp
=
from
BCD
(
val
&
0x07
);
tmp
=
from
_bcd
(
val
&
0x07
);
get_time
(
NVRAM
,
&
tm
);
tm
.
tm_wday
=
tmp
;
set_time
(
NVRAM
,
&
tm
);
...
...
@@ -318,7 +308,7 @@ void m48t59_write (void *opaque, uint32_t addr, uint32_t val)
case
0x1FFD
:
case
0x07FD
:
/* date */
tmp
=
from
BCD
(
val
&
0x1F
);
tmp
=
from
_bcd
(
val
&
0x1F
);
if
(
tmp
!=
0
)
{
get_time
(
NVRAM
,
&
tm
);
tm
.
tm_mday
=
tmp
;
...
...
@@ -328,7 +318,7 @@ void m48t59_write (void *opaque, uint32_t addr, uint32_t val)
case
0x1FFE
:
case
0x07FE
:
/* month */
tmp
=
from
BCD
(
val
&
0x1F
);
tmp
=
from
_bcd
(
val
&
0x1F
);
if
(
tmp
>=
1
&&
tmp
<=
12
)
{
get_time
(
NVRAM
,
&
tm
);
tm
.
tm_mon
=
tmp
-
1
;
...
...
@@ -338,13 +328,13 @@ void m48t59_write (void *opaque, uint32_t addr, uint32_t val)
case
0x1FFF
:
case
0x07FF
:
/* year */
tmp
=
from
BCD
(
val
);
tmp
=
from
_bcd
(
val
);
if
(
tmp
>=
0
&&
tmp
<=
99
)
{
get_time
(
NVRAM
,
&
tm
);
if
(
NVRAM
->
type
==
8
)
tm
.
tm_year
=
from
BCD
(
val
)
+
68
;
// Base year is 1968
tm
.
tm_year
=
from
_bcd
(
val
)
+
68
;
// Base year is 1968
else
tm
.
tm_year
=
from
BCD
(
val
);
tm
.
tm_year
=
from
_bcd
(
val
);
set_time
(
NVRAM
,
&
tm
);
}
break
;
...
...
@@ -410,19 +400,19 @@ uint32_t m48t59_read (void *opaque, uint32_t addr)
case
0x07F9
:
/* seconds (BCD) */
get_time
(
NVRAM
,
&
tm
);
retval
=
(
NVRAM
->
buffer
[
addr
]
&
0x80
)
|
to
BCD
(
tm
.
tm_sec
);
retval
=
(
NVRAM
->
buffer
[
addr
]
&
0x80
)
|
to
_bcd
(
tm
.
tm_sec
);
break
;
case
0x1FFA
:
case
0x07FA
:
/* minutes (BCD) */
get_time
(
NVRAM
,
&
tm
);
retval
=
to
BCD
(
tm
.
tm_min
);
retval
=
to
_bcd
(
tm
.
tm_min
);
break
;
case
0x1FFB
:
case
0x07FB
:
/* hours (BCD) */
get_time
(
NVRAM
,
&
tm
);
retval
=
to
BCD
(
tm
.
tm_hour
);
retval
=
to
_bcd
(
tm
.
tm_hour
);
break
;
case
0x1FFC
:
case
0x07FC
:
...
...
@@ -434,22 +424,22 @@ uint32_t m48t59_read (void *opaque, uint32_t addr)
case
0x07FD
:
/* date */
get_time
(
NVRAM
,
&
tm
);
retval
=
to
BCD
(
tm
.
tm_mday
);
retval
=
to
_bcd
(
tm
.
tm_mday
);
break
;
case
0x1FFE
:
case
0x07FE
:
/* month */
get_time
(
NVRAM
,
&
tm
);
retval
=
to
BCD
(
tm
.
tm_mon
+
1
);
retval
=
to
_bcd
(
tm
.
tm_mon
+
1
);
break
;
case
0x1FFF
:
case
0x07FF
:
/* year */
get_time
(
NVRAM
,
&
tm
);
if
(
NVRAM
->
type
==
8
)
retval
=
to
BCD
(
tm
.
tm_year
-
68
);
// Base year is 1968
retval
=
to
_bcd
(
tm
.
tm_year
-
68
);
// Base year is 1968
else
retval
=
to
BCD
(
tm
.
tm_year
);
retval
=
to
_bcd
(
tm
.
tm_year
);
break
;
default:
/* Check lock registers state */
...
...
hw/mc146818rtc.c
浏览文件 @
abd0c6bd
...
...
@@ -259,7 +259,7 @@ static void cmos_ioport_write(void *opaque, uint32_t addr, uint32_t data)
}
}
static
inline
int
to_bcd
(
RTCState
*
s
,
int
a
)
static
inline
int
rtc_
to_bcd
(
RTCState
*
s
,
int
a
)
{
if
(
s
->
cmos_data
[
RTC_REG_B
]
&
REG_B_DM
)
{
return
a
;
...
...
@@ -268,7 +268,7 @@ static inline int to_bcd(RTCState *s, int a)
}
}
static
inline
int
from_bcd
(
RTCState
*
s
,
int
a
)
static
inline
int
rtc_
from_bcd
(
RTCState
*
s
,
int
a
)
{
if
(
s
->
cmos_data
[
RTC_REG_B
]
&
REG_B_DM
)
{
return
a
;
...
...
@@ -281,17 +281,17 @@ static void rtc_set_time(RTCState *s)
{
struct
tm
*
tm
=
&
s
->
current_tm
;
tm
->
tm_sec
=
from_bcd
(
s
,
s
->
cmos_data
[
RTC_SECONDS
]);
tm
->
tm_min
=
from_bcd
(
s
,
s
->
cmos_data
[
RTC_MINUTES
]);
tm
->
tm_hour
=
from_bcd
(
s
,
s
->
cmos_data
[
RTC_HOURS
]
&
0x7f
);
tm
->
tm_sec
=
rtc_
from_bcd
(
s
,
s
->
cmos_data
[
RTC_SECONDS
]);
tm
->
tm_min
=
rtc_
from_bcd
(
s
,
s
->
cmos_data
[
RTC_MINUTES
]);
tm
->
tm_hour
=
rtc_
from_bcd
(
s
,
s
->
cmos_data
[
RTC_HOURS
]
&
0x7f
);
if
(
!
(
s
->
cmos_data
[
RTC_REG_B
]
&
0x02
)
&&
(
s
->
cmos_data
[
RTC_HOURS
]
&
0x80
))
{
tm
->
tm_hour
+=
12
;
}
tm
->
tm_wday
=
from_bcd
(
s
,
s
->
cmos_data
[
RTC_DAY_OF_WEEK
])
-
1
;
tm
->
tm_mday
=
from_bcd
(
s
,
s
->
cmos_data
[
RTC_DAY_OF_MONTH
]);
tm
->
tm_mon
=
from_bcd
(
s
,
s
->
cmos_data
[
RTC_MONTH
])
-
1
;
tm
->
tm_year
=
from_bcd
(
s
,
s
->
cmos_data
[
RTC_YEAR
])
+
s
->
base_year
-
1900
;
tm
->
tm_wday
=
rtc_
from_bcd
(
s
,
s
->
cmos_data
[
RTC_DAY_OF_WEEK
])
-
1
;
tm
->
tm_mday
=
rtc_
from_bcd
(
s
,
s
->
cmos_data
[
RTC_DAY_OF_MONTH
]);
tm
->
tm_mon
=
rtc_
from_bcd
(
s
,
s
->
cmos_data
[
RTC_MONTH
])
-
1
;
tm
->
tm_year
=
rtc_
from_bcd
(
s
,
s
->
cmos_data
[
RTC_YEAR
])
+
s
->
base_year
-
1900
;
}
static
void
rtc_copy_date
(
RTCState
*
s
)
...
...
@@ -299,24 +299,24 @@ static void rtc_copy_date(RTCState *s)
const
struct
tm
*
tm
=
&
s
->
current_tm
;
int
year
;
s
->
cmos_data
[
RTC_SECONDS
]
=
to_bcd
(
s
,
tm
->
tm_sec
);
s
->
cmos_data
[
RTC_MINUTES
]
=
to_bcd
(
s
,
tm
->
tm_min
);
s
->
cmos_data
[
RTC_SECONDS
]
=
rtc_
to_bcd
(
s
,
tm
->
tm_sec
);
s
->
cmos_data
[
RTC_MINUTES
]
=
rtc_
to_bcd
(
s
,
tm
->
tm_min
);
if
(
s
->
cmos_data
[
RTC_REG_B
]
&
0x02
)
{
/* 24 hour format */
s
->
cmos_data
[
RTC_HOURS
]
=
to_bcd
(
s
,
tm
->
tm_hour
);
s
->
cmos_data
[
RTC_HOURS
]
=
rtc_
to_bcd
(
s
,
tm
->
tm_hour
);
}
else
{
/* 12 hour format */
s
->
cmos_data
[
RTC_HOURS
]
=
to_bcd
(
s
,
tm
->
tm_hour
%
12
);
s
->
cmos_data
[
RTC_HOURS
]
=
rtc_
to_bcd
(
s
,
tm
->
tm_hour
%
12
);
if
(
tm
->
tm_hour
>=
12
)
s
->
cmos_data
[
RTC_HOURS
]
|=
0x80
;
}
s
->
cmos_data
[
RTC_DAY_OF_WEEK
]
=
to_bcd
(
s
,
tm
->
tm_wday
+
1
);
s
->
cmos_data
[
RTC_DAY_OF_MONTH
]
=
to_bcd
(
s
,
tm
->
tm_mday
);
s
->
cmos_data
[
RTC_MONTH
]
=
to_bcd
(
s
,
tm
->
tm_mon
+
1
);
s
->
cmos_data
[
RTC_DAY_OF_WEEK
]
=
rtc_
to_bcd
(
s
,
tm
->
tm_wday
+
1
);
s
->
cmos_data
[
RTC_DAY_OF_MONTH
]
=
rtc_
to_bcd
(
s
,
tm
->
tm_mday
);
s
->
cmos_data
[
RTC_MONTH
]
=
rtc_
to_bcd
(
s
,
tm
->
tm_mon
+
1
);
year
=
(
tm
->
tm_year
-
s
->
base_year
)
%
100
;
if
(
year
<
0
)
year
+=
100
;
s
->
cmos_data
[
RTC_YEAR
]
=
to_bcd
(
s
,
year
);
s
->
cmos_data
[
RTC_YEAR
]
=
rtc_
to_bcd
(
s
,
year
);
}
/* month is between 0 and 11. */
...
...
@@ -497,7 +497,7 @@ static void rtc_set_date_from_host(RTCState *s)
qemu_get_timedate
(
&
tm
,
0
);
rtc_set_date
(
s
,
&
tm
);
val
=
to_bcd
(
s
,
(
tm
.
tm_year
/
100
)
+
19
);
val
=
rtc_
to_bcd
(
s
,
(
tm
.
tm_year
/
100
)
+
19
);
rtc_set_memory
(
s
,
REG_IBM_CENTURY_BYTE
,
val
);
rtc_set_memory
(
s
,
REG_IBM_PS2_CENTURY_BYTE
,
val
);
}
...
...
hw/omap1.c
浏览文件 @
abd0c6bd
...
...
@@ -3358,16 +3358,6 @@ static void omap_rtc_alarm_update(struct omap_rtc_s *s)
printf
(
"%s: conversion failed
\n
"
,
__FUNCTION__
);
}
static
inline
uint8_t
omap_rtc_bcd
(
int
num
)
{
return
((
num
/
10
)
<<
4
)
|
(
num
%
10
);
}
static
inline
int
omap_rtc_bin
(
uint8_t
num
)
{
return
(
num
&
15
)
+
10
*
(
num
>>
4
);
}
static
uint32_t
omap_rtc_read
(
void
*
opaque
,
target_phys_addr_t
addr
)
{
struct
omap_rtc_s
*
s
=
(
struct
omap_rtc_s
*
)
opaque
;
...
...
@@ -3376,51 +3366,51 @@ static uint32_t omap_rtc_read(void *opaque, target_phys_addr_t addr)
switch
(
offset
)
{
case
0x00
:
/* SECONDS_REG */
return
omap_rtc
_bcd
(
s
->
current_tm
.
tm_sec
);
return
to
_bcd
(
s
->
current_tm
.
tm_sec
);
case
0x04
:
/* MINUTES_REG */
return
omap_rtc
_bcd
(
s
->
current_tm
.
tm_min
);
return
to
_bcd
(
s
->
current_tm
.
tm_min
);
case
0x08
:
/* HOURS_REG */
if
(
s
->
pm_am
)
return
((
s
->
current_tm
.
tm_hour
>
11
)
<<
7
)
|
omap_rtc
_bcd
(((
s
->
current_tm
.
tm_hour
-
1
)
%
12
)
+
1
);
to
_bcd
(((
s
->
current_tm
.
tm_hour
-
1
)
%
12
)
+
1
);
else
return
omap_rtc
_bcd
(
s
->
current_tm
.
tm_hour
);
return
to
_bcd
(
s
->
current_tm
.
tm_hour
);
case
0x0c
:
/* DAYS_REG */
return
omap_rtc
_bcd
(
s
->
current_tm
.
tm_mday
);
return
to
_bcd
(
s
->
current_tm
.
tm_mday
);
case
0x10
:
/* MONTHS_REG */
return
omap_rtc
_bcd
(
s
->
current_tm
.
tm_mon
+
1
);
return
to
_bcd
(
s
->
current_tm
.
tm_mon
+
1
);
case
0x14
:
/* YEARS_REG */
return
omap_rtc
_bcd
(
s
->
current_tm
.
tm_year
%
100
);
return
to
_bcd
(
s
->
current_tm
.
tm_year
%
100
);
case
0x18
:
/* WEEK_REG */
return
s
->
current_tm
.
tm_wday
;
case
0x20
:
/* ALARM_SECONDS_REG */
return
omap_rtc
_bcd
(
s
->
alarm_tm
.
tm_sec
);
return
to
_bcd
(
s
->
alarm_tm
.
tm_sec
);
case
0x24
:
/* ALARM_MINUTES_REG */
return
omap_rtc
_bcd
(
s
->
alarm_tm
.
tm_min
);
return
to
_bcd
(
s
->
alarm_tm
.
tm_min
);
case
0x28
:
/* ALARM_HOURS_REG */
if
(
s
->
pm_am
)
return
((
s
->
alarm_tm
.
tm_hour
>
11
)
<<
7
)
|
omap_rtc
_bcd
(((
s
->
alarm_tm
.
tm_hour
-
1
)
%
12
)
+
1
);
to
_bcd
(((
s
->
alarm_tm
.
tm_hour
-
1
)
%
12
)
+
1
);
else
return
omap_rtc
_bcd
(
s
->
alarm_tm
.
tm_hour
);
return
to
_bcd
(
s
->
alarm_tm
.
tm_hour
);
case
0x2c
:
/* ALARM_DAYS_REG */
return
omap_rtc
_bcd
(
s
->
alarm_tm
.
tm_mday
);
return
to
_bcd
(
s
->
alarm_tm
.
tm_mday
);
case
0x30
:
/* ALARM_MONTHS_REG */
return
omap_rtc
_bcd
(
s
->
alarm_tm
.
tm_mon
+
1
);
return
to
_bcd
(
s
->
alarm_tm
.
tm_mon
+
1
);
case
0x34
:
/* ALARM_YEARS_REG */
return
omap_rtc
_bcd
(
s
->
alarm_tm
.
tm_year
%
100
);
return
to
_bcd
(
s
->
alarm_tm
.
tm_year
%
100
);
case
0x40
:
/* RTC_CTRL_REG */
return
(
s
->
pm_am
<<
3
)
|
(
s
->
auto_comp
<<
2
)
|
...
...
@@ -3459,7 +3449,7 @@ static void omap_rtc_write(void *opaque, target_phys_addr_t addr,
printf
(
"RTC SEC_REG <-- %02x
\n
"
,
value
);
#endif
s
->
ti
-=
s
->
current_tm
.
tm_sec
;
s
->
ti
+=
omap_rtc_bin
(
value
);
s
->
ti
+=
from_bcd
(
value
);
return
;
case
0x04
:
/* MINUTES_REG */
...
...
@@ -3467,7 +3457,7 @@ static void omap_rtc_write(void *opaque, target_phys_addr_t addr,
printf
(
"RTC MIN_REG <-- %02x
\n
"
,
value
);
#endif
s
->
ti
-=
s
->
current_tm
.
tm_min
*
60
;
s
->
ti
+=
omap_rtc_bin
(
value
)
*
60
;
s
->
ti
+=
from_bcd
(
value
)
*
60
;
return
;
case
0x08
:
/* HOURS_REG */
...
...
@@ -3476,10 +3466,10 @@ static void omap_rtc_write(void *opaque, target_phys_addr_t addr,
#endif
s
->
ti
-=
s
->
current_tm
.
tm_hour
*
3600
;
if
(
s
->
pm_am
)
{
s
->
ti
+=
(
omap_rtc_bin
(
value
&
0x3f
)
&
12
)
*
3600
;
s
->
ti
+=
(
from_bcd
(
value
&
0x3f
)
&
12
)
*
3600
;
s
->
ti
+=
((
value
>>
7
)
&
1
)
*
43200
;
}
else
s
->
ti
+=
omap_rtc_bin
(
value
&
0x3f
)
*
3600
;
s
->
ti
+=
from_bcd
(
value
&
0x3f
)
*
3600
;
return
;
case
0x0c
:
/* DAYS_REG */
...
...
@@ -3487,7 +3477,7 @@ static void omap_rtc_write(void *opaque, target_phys_addr_t addr,
printf
(
"RTC DAY_REG <-- %02x
\n
"
,
value
);
#endif
s
->
ti
-=
s
->
current_tm
.
tm_mday
*
86400
;
s
->
ti
+=
omap_rtc_bin
(
value
)
*
86400
;
s
->
ti
+=
from_bcd
(
value
)
*
86400
;
return
;
case
0x10
:
/* MONTHS_REG */
...
...
@@ -3495,7 +3485,7 @@ static void omap_rtc_write(void *opaque, target_phys_addr_t addr,
printf
(
"RTC MTH_REG <-- %02x
\n
"
,
value
);
#endif
memcpy
(
&
new_tm
,
&
s
->
current_tm
,
sizeof
(
new_tm
));
new_tm
.
tm_mon
=
omap_rtc_bin
(
value
);
new_tm
.
tm_mon
=
from_bcd
(
value
);
ti
[
0
]
=
mktimegm
(
&
s
->
current_tm
);
ti
[
1
]
=
mktimegm
(
&
new_tm
);
...
...
@@ -3505,7 +3495,7 @@ static void omap_rtc_write(void *opaque, target_phys_addr_t addr,
}
else
{
/* A less accurate version */
s
->
ti
-=
s
->
current_tm
.
tm_mon
*
2592000
;
s
->
ti
+=
omap_rtc_bin
(
value
)
*
2592000
;
s
->
ti
+=
from_bcd
(
value
)
*
2592000
;
}
return
;
...
...
@@ -3514,7 +3504,7 @@ static void omap_rtc_write(void *opaque, target_phys_addr_t addr,
printf
(
"RTC YRS_REG <-- %02x
\n
"
,
value
);
#endif
memcpy
(
&
new_tm
,
&
s
->
current_tm
,
sizeof
(
new_tm
));
new_tm
.
tm_year
+=
omap_rtc_bin
(
value
)
-
(
new_tm
.
tm_year
%
100
);
new_tm
.
tm_year
+=
from_bcd
(
value
)
-
(
new_tm
.
tm_year
%
100
);
ti
[
0
]
=
mktimegm
(
&
s
->
current_tm
);
ti
[
1
]
=
mktimegm
(
&
new_tm
);
...
...
@@ -3524,7 +3514,7 @@ static void omap_rtc_write(void *opaque, target_phys_addr_t addr,
}
else
{
/* A less accurate version */
s
->
ti
-=
(
s
->
current_tm
.
tm_year
%
100
)
*
31536000
;
s
->
ti
+=
omap_rtc_bin
(
value
)
*
31536000
;
s
->
ti
+=
from_bcd
(
value
)
*
31536000
;
}
return
;
...
...
@@ -3535,7 +3525,7 @@ static void omap_rtc_write(void *opaque, target_phys_addr_t addr,
#ifdef ALMDEBUG
printf
(
"ALM SEC_REG <-- %02x
\n
"
,
value
);
#endif
s
->
alarm_tm
.
tm_sec
=
omap_rtc_bin
(
value
);
s
->
alarm_tm
.
tm_sec
=
from_bcd
(
value
);
omap_rtc_alarm_update
(
s
);
return
;
...
...
@@ -3543,7 +3533,7 @@ static void omap_rtc_write(void *opaque, target_phys_addr_t addr,
#ifdef ALMDEBUG
printf
(
"ALM MIN_REG <-- %02x
\n
"
,
value
);
#endif
s
->
alarm_tm
.
tm_min
=
omap_rtc_bin
(
value
);
s
->
alarm_tm
.
tm_min
=
from_bcd
(
value
);
omap_rtc_alarm_update
(
s
);
return
;
...
...
@@ -3553,10 +3543,10 @@ static void omap_rtc_write(void *opaque, target_phys_addr_t addr,
#endif
if
(
s
->
pm_am
)
s
->
alarm_tm
.
tm_hour
=
((
omap_rtc_bin
(
value
&
0x3f
))
%
12
)
+
((
from_bcd
(
value
&
0x3f
))
%
12
)
+
((
value
>>
7
)
&
1
)
*
12
;
else
s
->
alarm_tm
.
tm_hour
=
omap_rtc_bin
(
value
);
s
->
alarm_tm
.
tm_hour
=
from_bcd
(
value
);
omap_rtc_alarm_update
(
s
);
return
;
...
...
@@ -3564,7 +3554,7 @@ static void omap_rtc_write(void *opaque, target_phys_addr_t addr,
#ifdef ALMDEBUG
printf
(
"ALM DAY_REG <-- %02x
\n
"
,
value
);
#endif
s
->
alarm_tm
.
tm_mday
=
omap_rtc_bin
(
value
);
s
->
alarm_tm
.
tm_mday
=
from_bcd
(
value
);
omap_rtc_alarm_update
(
s
);
return
;
...
...
@@ -3572,7 +3562,7 @@ static void omap_rtc_write(void *opaque, target_phys_addr_t addr,
#ifdef ALMDEBUG
printf
(
"ALM MON_REG <-- %02x
\n
"
,
value
);
#endif
s
->
alarm_tm
.
tm_mon
=
omap_rtc_bin
(
value
);
s
->
alarm_tm
.
tm_mon
=
from_bcd
(
value
);
omap_rtc_alarm_update
(
s
);
return
;
...
...
@@ -3580,7 +3570,7 @@ static void omap_rtc_write(void *opaque, target_phys_addr_t addr,
#ifdef ALMDEBUG
printf
(
"ALM YRS_REG <-- %02x
\n
"
,
value
);
#endif
s
->
alarm_tm
.
tm_year
=
omap_rtc_bin
(
value
);
s
->
alarm_tm
.
tm_year
=
from_bcd
(
value
);
omap_rtc_alarm_update
(
s
);
return
;
...
...
hw/twl92230.c
浏览文件 @
abd0c6bd
...
...
@@ -183,16 +183,6 @@ static void menelaus_reset(i2c_slave *i2c)
menelaus_update
(
s
);
}
static
inline
uint8_t
to_bcd
(
int
val
)
{
return
((
val
/
10
)
<<
4
)
|
(
val
%
10
);
}
static
inline
int
from_bcd
(
uint8_t
val
)
{
return
((
val
>>
4
)
*
10
)
+
(
val
&
0x0f
);
}
static
void
menelaus_gpio_set
(
void
*
opaque
,
int
line
,
int
level
)
{
MenelausState
*
s
=
(
MenelausState
*
)
opaque
;
...
...
qemu-common.h
浏览文件 @
abd0c6bd
...
...
@@ -248,6 +248,17 @@ void qemu_iovec_from_buffer(QEMUIOVector *qiov, const void *buf, size_t count);
struct
Monitor
;
typedef
struct
Monitor
Monitor
;
/* Convert a byte between binary and BCD. */
static
inline
uint8_t
to_bcd
(
uint8_t
val
)
{
return
((
val
/
10
)
<<
4
)
|
(
val
%
10
);
}
static
inline
uint8_t
from_bcd
(
uint8_t
val
)
{
return
((
val
>>
4
)
*
10
)
+
(
val
&
0x0f
);
}
#include "module.h"
#endif
/* dyngen-exec.h hack */
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录