1 |
/* |
/* |
2 |
* Copyright (C) 2005 Anders Gavare. All rights reserved. |
* Copyright (C) 2005-2007 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_lpt.c,v 1.5 2005/11/13 00:14:09 debug Exp $ |
* $Id: dev_lpt.c,v 1.11 2007/04/20 11:17:24 debug Exp $ |
29 |
* |
* |
30 |
* LPT (parallel printer) controller. |
* LPT (parallel printer) controller. |
31 |
*/ |
*/ |
50 |
#define DEV_LPT_LENGTH 3 |
#define DEV_LPT_LENGTH 3 |
51 |
|
|
52 |
struct lpt_data { |
struct lpt_data { |
|
int in_use; |
|
53 |
int irqnr; |
int irqnr; |
54 |
char *name; |
char *name; |
55 |
int console_handle; |
int console_handle; |
59 |
}; |
}; |
60 |
|
|
61 |
|
|
62 |
/* |
DEVICE_TICK(lpt) |
|
* dev_lpt_tick(): |
|
|
*/ |
|
|
void dev_lpt_tick(struct cpu *cpu, void *extra) |
|
63 |
{ |
{ |
64 |
/* struct lpt_data *d = extra; */ |
/* struct lpt_data *d = extra; */ |
65 |
|
|
67 |
} |
} |
68 |
|
|
69 |
|
|
70 |
/* |
DEVICE_ACCESS(lpt) |
|
* dev_lpt_access(): |
|
|
*/ |
|
|
int dev_lpt_access(struct cpu *cpu, struct memory *mem, |
|
|
uint64_t relative_addr, unsigned char *data, size_t len, |
|
|
int writeflag, void *extra) |
|
71 |
{ |
{ |
72 |
uint64_t idata = 0, odata=0; |
uint64_t idata = 0, odata=0; |
73 |
struct lpt_data *d = extra; |
struct lpt_data *d = extra; |
109 |
} |
} |
110 |
|
|
111 |
|
|
112 |
/* |
DEVINIT(lpt) |
|
* devinit_lpt(): |
|
|
*/ |
|
|
int devinit_lpt(struct devinit *devinit) |
|
113 |
{ |
{ |
114 |
struct lpt_data *d = malloc(sizeof(struct lpt_data)); |
struct lpt_data *d = malloc(sizeof(struct lpt_data)); |
115 |
size_t nlen; |
size_t nlen; |
121 |
} |
} |
122 |
memset(d, 0, sizeof(struct lpt_data)); |
memset(d, 0, sizeof(struct lpt_data)); |
123 |
d->irqnr = devinit->irq_nr; |
d->irqnr = devinit->irq_nr; |
|
d->in_use = devinit->in_use; |
|
124 |
d->name = devinit->name2 != NULL? devinit->name2 : ""; |
d->name = devinit->name2 != NULL? devinit->name2 : ""; |
125 |
d->console_handle = |
d->console_handle = console_start_slave(devinit->machine, devinit->name, |
126 |
console_start_slave(devinit->machine, devinit->name); |
CONSOLE_OUTPUT_ONLY); |
127 |
|
|
128 |
nlen = strlen(devinit->name) + 10; |
nlen = strlen(devinit->name) + 10; |
129 |
if (devinit->name2 != NULL) |
if (devinit->name2 != NULL) |
140 |
|
|
141 |
memory_device_register(devinit->machine->memory, name, devinit->addr, |
memory_device_register(devinit->machine->memory, name, devinit->addr, |
142 |
DEV_LPT_LENGTH, dev_lpt_access, d, DM_DEFAULT, NULL); |
DEV_LPT_LENGTH, dev_lpt_access, d, DM_DEFAULT, NULL); |
143 |
machine_add_tickfunction(devinit->machine, dev_lpt_tick, d, TICK_SHIFT); |
machine_add_tickfunction(devinit->machine, dev_lpt_tick, d, |
144 |
|
TICK_SHIFT, 0.0); |
145 |
|
|
146 |
/* |
/* |
147 |
* NOTE: Ugly cast into a pointer, because this is a convenient way |
* NOTE: Ugly cast into a pointer, because this is a convenient way |