ETRAX-SER: qdevify.
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
This commit is contained in:
parent
73cfd29fb3
commit
4b816985b8
@ -21,15 +21,12 @@
|
|||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
* THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
#include <time.h>
|
|
||||||
#include <sys/time.h>
|
#include "sysbus.h"
|
||||||
#include "hw.h"
|
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
#include "flash.h"
|
#include "flash.h"
|
||||||
#include "sysemu.h"
|
|
||||||
#include "devices.h"
|
|
||||||
#include "boards.h"
|
#include "boards.h"
|
||||||
|
#include "sysemu.h"
|
||||||
#include "etraxfs.h"
|
#include "etraxfs.h"
|
||||||
|
|
||||||
#define D(x)
|
#define D(x)
|
||||||
@ -323,10 +320,8 @@ void axisdev88_init (ram_addr_t ram_size,
|
|||||||
etraxfs_timer_init(env, irq + 0x1b, nmi + 1, 0x3005e000);
|
etraxfs_timer_init(env, irq + 0x1b, nmi + 1, 0x3005e000);
|
||||||
|
|
||||||
for (i = 0; i < 4; i++) {
|
for (i = 0; i < 4; i++) {
|
||||||
if (serial_hds[i]) {
|
sysbus_create_simple("etraxfs,serial", 0x30026000 + i * 0x2000,
|
||||||
etraxfs_ser_init(env, irq + 0x14 + i,
|
irq[0x14 + i]);
|
||||||
serial_hds[i], 0x30026000 + i * 0x2000);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kernel_filename) {
|
if (kernel_filename) {
|
||||||
|
18
hw/etraxfs.c
18
hw/etraxfs.c
@ -21,15 +21,11 @@
|
|||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
* THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
#include <time.h>
|
|
||||||
#include <sys/time.h>
|
|
||||||
#include "hw.h"
|
|
||||||
#include "net.h"
|
|
||||||
#include "flash.h"
|
|
||||||
#include "sysemu.h"
|
|
||||||
#include "devices.h"
|
|
||||||
#include "boards.h"
|
|
||||||
|
|
||||||
|
#include "sysbus.h"
|
||||||
|
#include "boards.h"
|
||||||
|
#include "sysemu.h"
|
||||||
|
#include "net.h"
|
||||||
#include "etraxfs.h"
|
#include "etraxfs.h"
|
||||||
|
|
||||||
#define FLASH_SIZE 0x2000000
|
#define FLASH_SIZE 0x2000000
|
||||||
@ -114,10 +110,8 @@ void bareetraxfs_init (ram_addr_t ram_size,
|
|||||||
etraxfs_timer_init(env, irq + 0x1b, nmi + 1, 0x3005e000);
|
etraxfs_timer_init(env, irq + 0x1b, nmi + 1, 0x3005e000);
|
||||||
|
|
||||||
for (i = 0; i < 4; i++) {
|
for (i = 0; i < 4; i++) {
|
||||||
if (serial_hds[i]) {
|
sysbus_create_simple("etraxfs,serial", 0x30026000 + i * 0x2000,
|
||||||
etraxfs_ser_init(env, irq + 0x14 + i,
|
irq[0x14 + i]);
|
||||||
serial_hds[i], 0x30026000 + i * 0x2000);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kernel_filename) {
|
if (kernel_filename) {
|
||||||
|
@ -29,5 +29,5 @@ void etraxfs_timer_init(CPUState *env, qemu_irq *irqs, qemu_irq *nmi,
|
|||||||
target_phys_addr_t base);
|
target_phys_addr_t base);
|
||||||
void *etraxfs_eth_init(NICInfo *nd, CPUState *env,
|
void *etraxfs_eth_init(NICInfo *nd, CPUState *env,
|
||||||
qemu_irq *irq, target_phys_addr_t base, int phyaddr);
|
qemu_irq *irq, target_phys_addr_t base, int phyaddr);
|
||||||
void etraxfs_ser_init(CPUState *env, qemu_irq *irq, CharDriverState *chr,
|
//void etraxfs_ser_init(CPUState *env, qemu_irq *irq, CharDriverState *chr,
|
||||||
target_phys_addr_t base);
|
// target_phys_addr_t base);
|
||||||
|
@ -22,11 +22,8 @@
|
|||||||
* THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include "sysbus.h"
|
||||||
#include <ctype.h>
|
|
||||||
#include "hw.h"
|
|
||||||
#include "qemu-char.h"
|
#include "qemu-char.h"
|
||||||
#include "etraxfs.h"
|
|
||||||
|
|
||||||
#define D(x)
|
#define D(x)
|
||||||
|
|
||||||
@ -48,9 +45,9 @@
|
|||||||
|
|
||||||
struct etrax_serial
|
struct etrax_serial
|
||||||
{
|
{
|
||||||
CPUState *env;
|
SysBusDevice busdev;
|
||||||
CharDriverState *chr;
|
CharDriverState *chr;
|
||||||
qemu_irq *irq;
|
qemu_irq irq;
|
||||||
|
|
||||||
/* This pending thing is a hack. */
|
/* This pending thing is a hack. */
|
||||||
int pending_tx;
|
int pending_tx;
|
||||||
@ -64,7 +61,7 @@ static void ser_update_irq(struct etrax_serial *s)
|
|||||||
s->regs[R_INTR] &= ~(s->regs[RW_ACK_INTR]);
|
s->regs[R_INTR] &= ~(s->regs[RW_ACK_INTR]);
|
||||||
s->regs[R_MASKED_INTR] = s->regs[R_INTR] & s->regs[RW_INTR_MASK];
|
s->regs[R_MASKED_INTR] = s->regs[R_INTR] & s->regs[RW_INTR_MASK];
|
||||||
|
|
||||||
qemu_set_irq(s->irq[0], !!s->regs[R_MASKED_INTR]);
|
qemu_set_irq(s->irq, !!s->regs[R_MASKED_INTR]);
|
||||||
s->regs[RW_ACK_INTR] = 0;
|
s->regs[RW_ACK_INTR] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,25 +161,29 @@ static void serial_event(void *opaque, int event)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void etraxfs_ser_init(CPUState *env, qemu_irq *irq, CharDriverState *chr,
|
static void etraxfs_ser_init(SysBusDevice *dev)
|
||||||
target_phys_addr_t base)
|
|
||||||
{
|
{
|
||||||
struct etrax_serial *s;
|
struct etrax_serial *s = FROM_SYSBUS(typeof (*s), dev);
|
||||||
int ser_regs;
|
int ser_regs;
|
||||||
|
|
||||||
s = qemu_mallocz(sizeof *s);
|
|
||||||
|
|
||||||
s->env = env;
|
|
||||||
s->irq = irq;
|
|
||||||
s->chr = chr;
|
|
||||||
|
|
||||||
/* transmitter begins ready and idle. */
|
/* transmitter begins ready and idle. */
|
||||||
s->regs[RS_STAT_DIN] |= (1 << STAT_TR_RDY);
|
s->regs[RS_STAT_DIN] |= (1 << STAT_TR_RDY);
|
||||||
s->regs[RS_STAT_DIN] |= (1 << STAT_TR_IDLE);
|
s->regs[RS_STAT_DIN] |= (1 << STAT_TR_IDLE);
|
||||||
|
|
||||||
qemu_chr_add_handlers(chr, serial_can_receive, serial_receive,
|
sysbus_init_irq(dev, &s->irq);
|
||||||
serial_event, s);
|
|
||||||
|
|
||||||
ser_regs = cpu_register_io_memory(0, ser_read, ser_write, s);
|
ser_regs = cpu_register_io_memory(0, ser_read, ser_write, s);
|
||||||
cpu_register_physical_memory (base, R_MAX * 4, ser_regs);
|
sysbus_init_mmio(dev, R_MAX * 4, ser_regs);
|
||||||
|
s->chr = qdev_init_chardev(&dev->qdev);
|
||||||
|
if (s->chr)
|
||||||
|
qemu_chr_add_handlers(s->chr,
|
||||||
|
serial_can_receive, serial_receive,
|
||||||
|
serial_event, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void etraxfs_serial_register(void)
|
||||||
|
{
|
||||||
|
sysbus_register_dev("etraxfs,serial", sizeof (struct etrax_serial),
|
||||||
|
etraxfs_ser_init);
|
||||||
|
}
|
||||||
|
|
||||||
|
device_init(etraxfs_serial_register)
|
||||||
|
Loading…
Reference in New Issue
Block a user