Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
qemu
提交
5493e33f
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看板
提交
5493e33f
编写于
5月 14, 2009
作者:
P
Paul Brook
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Stellaris SSI qdev conversion
Signed-off-by:
N
Paul Brook
<
paul@codesourcery.com
>
上级
90d37239
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
95 addition
and
80 deletion
+95
-80
hw/devices.h
hw/devices.h
+0
-4
hw/pl022.c
hw/pl022.c
+18
-14
hw/primecell.h
hw/primecell.h
+0
-5
hw/sd.h
hw/sd.h
+0
-4
hw/ssd0323.c
hw/ssd0323.c
+19
-11
hw/ssi-sd.c
hw/ssi-sd.c
+23
-9
hw/stellaris.c
hw/stellaris.c
+35
-33
未找到文件。
hw/devices.h
浏览文件 @
5493e33f
...
...
@@ -6,10 +6,6 @@
/* smc91c111.c */
void
smc91c111_init
(
NICInfo
*
,
uint32_t
,
qemu_irq
);
/* ssd0323.c */
int
ssd0323_xfer_ssi
(
void
*
opaque
,
int
data
);
void
*
ssd0323_init
(
qemu_irq
*
cmd_p
);
/* ads7846.c */
typedef
struct
ADS7846State
ADS7846State
;
uint32_t
ads7846_read
(
void
*
opaque
);
...
...
hw/pl022.c
浏览文件 @
5493e33f
...
...
@@ -7,7 +7,8 @@
* This code is licenced under the GPL.
*/
#include "hw.h"
#include "sysbus.h"
#include "ssi.h"
#include "primecell.h"
//#define DEBUG_PL022 1
...
...
@@ -40,6 +41,7 @@ do { fprintf(stderr, "pl022: error: " fmt , ## __VA_ARGS__);} while (0)
#define PL022_INT_TX 0x08
typedef
struct
{
SysBusDevice
busdev
;
uint32_t
cr0
;
uint32_t
cr1
;
uint32_t
bitmask
;
...
...
@@ -55,8 +57,7 @@ typedef struct {
uint16_t
tx_fifo
[
8
];
uint16_t
rx_fifo
[
8
];
qemu_irq
irq
;
int
(
*
xfer_cb
)(
void
*
,
int
);
void
*
opaque
;
SSIBus
*
ssi
;
}
pl022_state
;
static
const
unsigned
char
pl022_id
[
8
]
=
...
...
@@ -116,10 +117,8 @@ static void pl022_xfer(pl022_state *s)
val
=
s
->
tx_fifo
[
i
];
if
(
s
->
cr1
&
PL022_CR1_LBM
)
{
/* Loopback mode. */
}
else
if
(
s
->
xfer_cb
)
{
val
=
s
->
xfer_cb
(
s
->
opaque
,
val
);
}
else
{
val
=
0
;
val
=
ssi_transfer
(
s
->
ssi
,
val
)
;
}
s
->
rx_fifo
[
o
]
=
val
&
s
->
bitmask
;
i
=
(
i
+
1
)
&
7
;
...
...
@@ -289,19 +288,24 @@ static int pl022_load(QEMUFile *f, void *opaque, int version_id)
return
0
;
}
void
pl022_init
(
uint32_t
base
,
qemu_irq
irq
,
int
(
*
xfer_cb
)(
void
*
,
int
),
void
*
opaque
)
static
void
pl022_init
(
SysBusDevice
*
dev
)
{
pl022_state
*
s
=
FROM_SYSBUS
(
pl022_state
,
dev
);
int
iomemtype
;
pl022_state
*
s
;
s
=
(
pl022_state
*
)
qemu_mallocz
(
sizeof
(
pl022_state
));
iomemtype
=
cpu_register_io_memory
(
0
,
pl022_readfn
,
pl022_writefn
,
s
);
cpu_register_physical_memory
(
base
,
0x0000
1000
,
iomemtype
);
s
->
irq
=
irq
;
s
->
xfer_cb
=
xfer_cb
;
s
->
opaque
=
opaque
;
sysbus_init_mmio
(
dev
,
0x
1000
,
iomemtype
);
s
ysbus_init_irq
(
dev
,
&
s
->
irq
)
;
s
->
ssi
=
ssi_create_bus
()
;
qdev_attach_child_bus
(
&
dev
->
qdev
,
"ssi"
,
s
->
ssi
)
;
pl022_reset
(
s
);
register_savevm
(
"pl022_ssp"
,
-
1
,
1
,
pl022_save
,
pl022_load
,
s
);
}
static
void
pl022_register_devices
(
void
)
{
sysbus_register_dev
(
"pl022"
,
sizeof
(
pl022_state
),
pl022_init
);
}
device_init
(
pl022_register_devices
)
hw/primecell.h
浏览文件 @
5493e33f
...
...
@@ -5,11 +5,6 @@
/* Also includes some devices that are currently only used by the
ARM boards. */
/* pl022.c */
typedef
int
(
*
ssi_xfer_cb
)(
void
*
,
int
);
void
pl022_init
(
uint32_t
base
,
qemu_irq
irq
,
ssi_xfer_cb
xfer_cb
,
void
*
opaque
);
/* pl061.c */
void
pl061_float_high
(
void
*
opaque
,
uint8_t
mask
);
qemu_irq
*
pl061_init
(
uint32_t
base
,
qemu_irq
irq
,
qemu_irq
**
out
);
...
...
hw/sd.h
浏览文件 @
5493e33f
...
...
@@ -76,8 +76,4 @@ void sd_set_cb(SDState *sd, qemu_irq readonly, qemu_irq insert);
int
sd_data_ready
(
SDState
*
sd
);
void
sd_enable
(
SDState
*
sd
,
int
enable
);
/* ssi-sd.c */
int
ssi_sd_xfer
(
void
*
opaque
,
int
val
);
void
*
ssi_sd_init
(
BlockDriverState
*
bs
);
#endif
/* __hw_sd_h */
hw/ssd0323.c
浏览文件 @
5493e33f
...
...
@@ -10,8 +10,7 @@
/* The controller can support a variety of different displays, but we only
implement one. Most of the commends relating to brightness and geometry
setup are ignored. */
#include "hw.h"
#include "devices.h"
#include "ssi.h"
#include "console.h"
//#define DEBUG_SSD0323 1
...
...
@@ -43,6 +42,7 @@ enum ssd0323_mode
};
typedef
struct
{
SSISlave
ssidev
;
DisplayState
*
ds
;
int
cmd_len
;
...
...
@@ -60,9 +60,10 @@ typedef struct {
uint8_t
framebuffer
[
128
*
80
/
2
];
}
ssd0323_state
;
int
ssd0323_xfer_ssi
(
void
*
opaque
,
in
t
data
)
static
uint32_t
ssd0323_transfer
(
SSISlave
*
dev
,
uint32_
t
data
)
{
ssd0323_state
*
s
=
(
ssd0323_state
*
)
opaque
;
ssd0323_state
*
s
=
FROM_SSI_SLAVE
(
ssd0323_state
,
dev
);
switch
(
s
->
mode
)
{
case
SSD0323_DATA
:
DPRINTF
(
"data 0x%02x
\n
"
,
data
);
...
...
@@ -321,12 +322,10 @@ static int ssd0323_load(QEMUFile *f, void *opaque, int version_id)
return
0
;
}
void
*
ssd0323_init
(
qemu_irq
*
cmd_p
)
static
void
ssd0323_init
(
SSISlave
*
dev
)
{
ssd0323_state
*
s
;
qemu_irq
*
cmd
;
ssd0323_state
*
s
=
FROM_SSI_SLAVE
(
ssd0323_state
,
dev
);
s
=
(
ssd0323_state
*
)
qemu_mallocz
(
sizeof
(
ssd0323_state
));
s
->
col_end
=
63
;
s
->
row_end
=
79
;
s
->
ds
=
graphic_console_init
(
ssd0323_update_display
,
...
...
@@ -334,10 +333,19 @@ void *ssd0323_init(qemu_irq *cmd_p)
NULL
,
NULL
,
s
);
qemu_console_resize
(
s
->
ds
,
128
*
MAGNIFY
,
64
*
MAGNIFY
);
cmd
=
qemu_allocate_irqs
(
ssd0323_cd
,
s
,
1
);
*
cmd_p
=
*
cmd
;
qdev_init_gpio_in
(
&
dev
->
qdev
,
ssd0323_cd
,
1
);
register_savevm
(
"ssd0323_oled"
,
-
1
,
1
,
ssd0323_save
,
ssd0323_load
,
s
);
}
return
s
;
static
SSISlaveInfo
ssd0323_info
=
{
.
init
=
ssd0323_init
,
.
transfer
=
ssd0323_transfer
};
static
void
ssd03232_register_devices
(
void
)
{
ssi_register_slave
(
"ssd0323"
,
sizeof
(
ssd0323_state
),
&
ssd0323_info
);
}
device_init
(
ssd03232_register_devices
)
hw/ssi-sd.c
浏览文件 @
5493e33f
/*
* SSI to SD card adapter.
*
* Copyright (c) 2007 CodeSourcery.
* Copyright (c) 2007
-2009
CodeSourcery.
* Written by Paul Brook
*
* This code is licenced under the G
PL
.
* This code is licenced under the G
NU GPL v2
.
*/
#include "
hw
.h"
#include "
ssi
.h"
#include "sd.h"
#include "sysemu.h"
//#define DEBUG_SSI_SD 1
...
...
@@ -32,6 +33,7 @@ typedef enum {
}
ssi_sd_mode
;
typedef
struct
{
SSISlave
ssidev
;
ssi_sd_mode
mode
;
int
cmd
;
uint8_t
cmdarg
[
4
];
...
...
@@ -59,9 +61,9 @@ typedef struct {
#define SSI_SDR_ADDRESS_ERROR 0x2000
#define SSI_SDR_PARAMETER_ERROR 0x4000
int
ssi_sd_xfer
(
void
*
opaque
,
in
t
val
)
static
uint32_t
ssi_sd_transfer
(
SSISlave
*
dev
,
uint32_
t
val
)
{
ssi_sd_state
*
s
=
(
ssi_sd_state
*
)
opaque
;
ssi_sd_state
*
s
=
FROM_SSI_SLAVE
(
ssi_sd_state
,
dev
)
;
/* Special case: allow CMD12 (STOP TRANSMISSION) while reading data. */
if
(
s
->
mode
==
SSI_SD_DATA_READ
&&
val
==
0x4d
)
{
...
...
@@ -227,13 +229,25 @@ static int ssi_sd_load(QEMUFile *f, void *opaque, int version_id)
return
0
;
}
void
*
ssi_sd_init
(
BlockDriverState
*
bs
)
static
void
ssi_sd_init
(
SSISlave
*
dev
)
{
ssi_sd_state
*
s
;
ssi_sd_state
*
s
=
FROM_SSI_SLAVE
(
ssi_sd_state
,
dev
);
BlockDriverState
*
bs
;
s
=
(
ssi_sd_state
*
)
qemu_mallocz
(
sizeof
(
ssi_sd_state
));
s
->
mode
=
SSI_SD_CMD
;
bs
=
qdev_init_bdrv
(
&
dev
->
qdev
,
IF_SD
);
s
->
sd
=
sd_init
(
bs
,
1
);
register_savevm
(
"ssi_sd"
,
-
1
,
1
,
ssi_sd_save
,
ssi_sd_load
,
s
);
return
s
;
}
static
SSISlaveInfo
ssi_sd_info
=
{
.
init
=
ssi_sd_init
,
.
transfer
=
ssi_sd_transfer
};
static
void
ssi_sd_register_devices
(
void
)
{
ssi_register_slave
(
"ssi-sd"
,
sizeof
(
ssi_sd_state
),
&
ssi_sd_info
);
}
device_init
(
ssi_sd_register_devices
)
hw/stellaris.c
浏览文件 @
5493e33f
...
...
@@ -8,13 +8,13 @@
*/
#include "sysbus.h"
#include "ssi.h"
#include "arm-misc.h"
#include "primecell.h"
#include "devices.h"
#include "qemu-timer.h"
#include "i2c.h"
#include "net.h"
#include "sd.h"
#include "sysemu.h"
#include "boards.h"
...
...
@@ -1196,10 +1196,10 @@ static qemu_irq stellaris_adc_init(uint32_t base, qemu_irq irq)
0xff commands that occur when deselecting the SD card. */
typedef
struct
{
ssi_xfer_cb
xfer_cb
[
2
];
void
*
opaque
[
2
];
SSISlave
ssidev
;
qemu_irq
irq
;
int
current_dev
;
SSIBus
*
bus
[
2
];
}
stellaris_ssi_bus_state
;
static
void
stellaris_ssi_bus_select
(
void
*
opaque
,
int
irq
,
int
level
)
...
...
@@ -1209,11 +1209,11 @@ static void stellaris_ssi_bus_select(void *opaque, int irq, int level)
s
->
current_dev
=
level
;
}
static
int
stellaris_ssi_bus_xfer
(
void
*
opaque
,
in
t
val
)
static
uint32_t
stellaris_ssi_bus_transfer
(
SSISlave
*
dev
,
uint32_
t
val
)
{
stellaris_ssi_bus_state
*
s
=
(
stellaris_ssi_bus_state
*
)
opaque
;
stellaris_ssi_bus_state
*
s
=
FROM_SSI_SLAVE
(
stellaris_ssi_bus_state
,
dev
)
;
return
s
->
xfer_cb
[
s
->
current_dev
](
s
->
opaque
[
s
->
current_dev
],
val
);
return
s
si_transfer
(
s
->
bus
[
s
->
current_dev
],
val
);
}
static
void
stellaris_ssi_bus_save
(
QEMUFile
*
f
,
void
*
opaque
)
...
...
@@ -1235,23 +1235,18 @@ static int stellaris_ssi_bus_load(QEMUFile *f, void *opaque, int version_id)
return
0
;
}
static
void
*
stellaris_ssi_bus_init
(
qemu_irq
*
irqp
,
ssi_xfer_cb
cb0
,
void
*
opaque0
,
ssi_xfer_cb
cb1
,
void
*
opaque1
)
static
void
stellaris_ssi_bus_init
(
SSISlave
*
dev
)
{
qemu_irq
*
qi
;
stellaris_ssi_bus_state
*
s
;
s
=
(
stellaris_ssi_bus_state
*
)
qemu_mallocz
(
sizeof
(
stellaris_ssi_bus_state
));
s
->
xfer_cb
[
0
]
=
cb0
;
s
->
opaque
[
0
]
=
opaque0
;
s
->
xfer_cb
[
1
]
=
cb1
;
s
->
opaque
[
1
]
=
opaque1
;
qi
=
qemu_allocate_irqs
(
stellaris_ssi_bus_select
,
s
,
1
);
*
irqp
=
*
qi
;
stellaris_ssi_bus_state
*
s
=
FROM_SSI_SLAVE
(
stellaris_ssi_bus_state
,
dev
);
s
->
bus
[
0
]
=
ssi_create_bus
();
qdev_attach_child_bus
(
&
dev
->
qdev
,
"ssi0"
,
s
->
bus
[
0
]);
s
->
bus
[
1
]
=
ssi_create_bus
();
qdev_attach_child_bus
(
&
dev
->
qdev
,
"ssi1"
,
s
->
bus
[
1
]);
qdev_init_gpio_in
(
&
dev
->
qdev
,
stellaris_ssi_bus_select
,
1
);
register_savevm
(
"stellaris_ssi_bus"
,
-
1
,
1
,
stellaris_ssi_bus_save
,
stellaris_ssi_bus_load
,
s
);
return
s
;
}
/* Board init. */
...
...
@@ -1338,25 +1333,25 @@ static void stellaris_init(const char *kernel_filename, const char *cpu_model,
}
}
if
(
board
->
dc2
&
(
1
<<
4
))
{
DeviceState
*
dev
;
dev
=
sysbus_create_simple
(
"pl022"
,
0x40008000
,
pic
[
7
]);
if
(
board
->
peripherals
&
BP_OLED_SSI
)
{
void
*
oled
;
void
*
sd
;
void
*
ssi_bus
;
int
index
;
DeviceState
*
mux
;
void
*
bus
;
oled
=
ssd0323_init
(
&
gpio_out
[
GPIO_C
][
7
]
);
index
=
drive_get_index
(
IF_SD
,
0
,
0
);
sd
=
ssi_sd_init
(
drives_table
[
index
].
bdrv
);
bus
=
qdev_get_child_bus
(
dev
,
"ssi"
);
mux
=
ssi_create_slave
(
bus
,
"evb6965-ssi"
);
gpio_out
[
GPIO_D
][
0
]
=
qdev_get_gpio_in
(
mux
,
0
);
ssi_bus
=
stellaris_ssi_bus_init
(
&
gpio_out
[
GPIO_D
][
0
],
ssi_sd_xfer
,
sd
,
ssd0323_xfer_ssi
,
oled
);
bus
=
qdev_get_child_bus
(
mux
,
"ssi0"
);
dev
=
ssi_create_slave
(
bus
,
"ssi-sd"
);
bus
=
qdev_get_child_bus
(
mux
,
"ssi1"
);
dev
=
ssi_create_slave
(
bus
,
"ssd0323"
);
gpio_out
[
GPIO_C
][
7
]
=
qdev_get_gpio_in
(
dev
,
0
);
pl022_init
(
0x40008000
,
pic
[
7
],
stellaris_ssi_bus_xfer
,
ssi_bus
);
/* Make sure the select pin is high. */
qemu_irq_raise
(
gpio_out
[
GPIO_D
][
0
]);
}
else
{
pl022_init
(
0x40008000
,
pic
[
7
],
NULL
,
NULL
);
}
}
if
(
board
->
dc4
&
(
1
<<
28
))
{
...
...
@@ -1413,10 +1408,17 @@ QEMUMachine lm3s6965evb_machine = {
.
init
=
lm3s6965evb_init
,
};
static
SSISlaveInfo
stellaris_ssi_bus_info
=
{
.
init
=
stellaris_ssi_bus_init
,
.
transfer
=
stellaris_ssi_bus_transfer
};
static
void
stellaris_register_devices
(
void
)
{
sysbus_register_dev
(
"stellaris-i2c"
,
sizeof
(
stellaris_i2c_state
),
stellaris_i2c_init
);
ssi_register_slave
(
"evb6965-ssi"
,
sizeof
(
stellaris_ssi_bus_state
),
&
stellaris_ssi_bus_info
);
}
device_init
(
stellaris_register_devices
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录