1 |
/* |
/* |
2 |
* Copyright (C) 2003-2005 Anders Gavare. All rights reserved. |
* Copyright (C) 2003-2006 Anders Gavare. All rights reserved. |
3 |
* |
* |
4 |
* Redistribution and use in source and binary forms, with or without |
* Redistribution and use in source and binary forms, with or without |
5 |
* modification, are permitted provided that the following conditions are met: |
* modification, are permitted provided that the following conditions are met: |
25 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
26 |
* |
* |
27 |
* |
* |
28 |
* $Id: dev_cons.c,v 1.28 2005/11/13 00:14:08 debug Exp $ |
* $Id: dev_cons.c,v 1.33 2006/02/09 20:02:59 debug Exp $ |
29 |
* |
* |
30 |
* A simple console device, useful for simple tests. |
* A simple console device, useful for simple tests. |
31 |
* |
* |
69 |
/* |
/* |
70 |
* dev_cons_access(): |
* dev_cons_access(): |
71 |
*/ |
*/ |
72 |
int dev_cons_access(struct cpu *cpu, struct memory *mem, |
DEVICE_ACCESS(cons) |
|
uint64_t relative_addr, unsigned char *data, size_t len, |
|
|
int writeflag, void *extra) |
|
73 |
{ |
{ |
74 |
struct cons_data *d = extra; |
struct cons_data *d = extra; |
75 |
int i; |
unsigned int i; |
76 |
|
|
77 |
/* Exit the emulator: */ |
/* Exit the emulator: */ |
78 |
if (relative_addr == DEV_CONS_HALT) { |
if (relative_addr == DEV_CONS_HALT) { |
110 |
} |
} |
111 |
|
|
112 |
|
|
113 |
/* |
DEVINIT(cons) |
|
* devinit_cons(): |
|
|
*/ |
|
|
int devinit_cons(struct devinit *devinit) |
|
114 |
{ |
{ |
115 |
struct cons_data *d; |
struct cons_data *d; |
116 |
char *name3; |
char *name3; |
137 |
snprintf(name3, nlen, "%s", devinit->name); |
snprintf(name3, nlen, "%s", devinit->name); |
138 |
|
|
139 |
d->irq_nr = devinit->irq_nr; |
d->irq_nr = devinit->irq_nr; |
140 |
d->console_handle = console_start_slave(devinit->machine, name3); |
d->in_use = devinit->in_use; |
141 |
|
d->console_handle = console_start_slave(devinit->machine, name3, |
142 |
|
d->in_use); |
143 |
|
|
144 |
memory_device_register(devinit->machine->memory, name3, |
memory_device_register(devinit->machine->memory, name3, |
145 |
devinit->addr, DEV_CONS_LENGTH, dev_cons_access, d, |
devinit->addr, DEV_CONS_LENGTH, dev_cons_access, d, |
147 |
machine_add_tickfunction(devinit->machine, dev_cons_tick, |
machine_add_tickfunction(devinit->machine, dev_cons_tick, |
148 |
d, CONS_TICK_SHIFT); |
d, CONS_TICK_SHIFT); |
149 |
|
|
150 |
devinit->return_ptr = d; |
/* NOTE: Ugly cast into pointer */ |
151 |
|
devinit->return_ptr = (void *)(size_t)d->console_handle; |
152 |
return 1; |
return 1; |
153 |
} |
} |
154 |
|
|