/[gxemul]/trunk/src/devices/dev_cons.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /trunk/src/devices/dev_cons.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 30 - (hide annotations)
Mon Oct 8 16:20:40 2007 UTC (16 years, 6 months ago) by dpavlin
File MIME type: text/plain
File size: 4393 byte(s)
++ trunk/HISTORY	(local)
$Id: HISTORY,v 1.1325 2006/08/15 15:38:37 debug Exp $
20060723	More Transputer instructions (pfix, nfix, opr, mint, ldl, ldlp,
		eqc, rev, ajw, stl, stlf, sthf, sub, ldnl, ldnlp, ldpi, move,
		wcnt, add, bcnt).
		Adding more SPARC instructions (andcc, addcc, bl, rdpr).
		Progress on the igsfb framebuffer used by NetBSD/netwinder.
		Enabling 8-bit fills in dev_fb.
		NetBSD/netwinder 3.0.1 can now run from a disk image :-)
20060724	Cleanup/performance fix for 64-bit virtual translation table
		updates (by removing the "timestamp" stuff). A full NetBSD/pmax
		3.0.1 install for R4400 has dropped from 667 seconds to 584 :)
		Fixing the igsfb "almost vga" color (it is 24-bit, not 18-bit).
		Adding some MIPS instruction combinations (3*lw, and 3*addu).
		The 8048 keyboard now turns off interrupt enable between the
		KBR_ACK and the KBR_RSTDONE, to work better with Linux 2.6.
		Not causing PPC DEC interrupts if PPC_NO_DEC is set for a
		specific CPU; NetBSD/bebox gets slightly further than before.
		Adding some more SPARC instructions: branches, udiv.
20060725	Refreshing dev_pckbc.c a little.
		Cleanups for the SH emulation mode, and adding the first
		"compact" (16-bit) instructions: various simple movs, nop,
		shll, stc, or, ldc.
20060726	Adding dummy "pcn" (AMD PCnet NIC) PCI glue.
20060727	Various cleanups; removing stuff from cpu.h, such as
		running_translated (not really meaningful anymore), and
		page flags (breaking into the debugger clears all translations
		anyway).
		Minor MIPS instruction combination updates.
20060807	Expanding the 3*sw and 3*lw MIPS instruction combinations to
		work with 2* and 4* too, resulting in a minor performance gain.
		Implementing a usleep hack for the RM52xx/MIPS32/MIPS64 "wait"
		instruction (when emulating 1 cpu).
20060808	Experimenting with some more MIPS instruction combinations.
		Implementing support for showing a (hardcoded 12x22) text
		cursor in igsfb.
20060809	Simplifying the NetBSD/evbmips (Malta) install instructions
		somewhat (by using a NetBSD/pmax ramdisk install kernel).
20060812	Experimenting more with the MIPS 'wait' instruction.
		PCI configuration register writes can now be handled, which
		allow PCI IDE controllers to work with NetBSD/Malta 3.0.1 and
		NetBSD/cobalt 3.0.1. (Previously only NetBSD 2.1 worked.)
20060813	Updating dev_gt.c based on numbers from Alec Voropay, to enable
		Linux 2.6 to use PCI on Malta.
		Continuing on Algor interrupt stuff.
20060814	Adding support for routing ISA interrupts to two different
		interrupts, making it possible to run NetBSD/algor :-)
20060814-15	Testing for the release.

==============  RELEASE 0.4.2  ==============


1 dpavlin 4 /*
2 dpavlin 22 * Copyright (C) 2003-2006 Anders Gavare. All rights reserved.
3 dpavlin 4 *
4     * Redistribution and use in source and binary forms, with or without
5     * modification, are permitted provided that the following conditions are met:
6     *
7     * 1. Redistributions of source code must retain the above copyright
8     * notice, this list of conditions and the following disclaimer.
9     * 2. Redistributions in binary form must reproduce the above copyright
10     * notice, this list of conditions and the following disclaimer in the
11     * documentation and/or other materials provided with the distribution.
12     * 3. The name of the author may not be used to endorse or promote products
13     * derived from this software without specific prior written permission.
14     *
15     * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16     * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17     * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18     * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19     * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20     * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21     * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22     * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23     * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24     * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25     * SUCH DAMAGE.
26     *
27     *
28 dpavlin 30 * $Id: dev_cons.c,v 1.37 2006/07/23 14:37:34 debug Exp $
29 dpavlin 4 *
30 dpavlin 12 * A simple console device, useful for simple tests.
31 dpavlin 4 *
32     * This device provides memory mapped I/O for a simple console supporting
33     * putchar (writing to memory) and getchar (reading from memory), and
34     * support for halting the emulator. (This is useful for regression tests,
35     * Hello World-style test programs, and other simple experiments.)
36     */
37    
38     #include <stdio.h>
39     #include <stdlib.h>
40     #include <string.h>
41    
42     #include "console.h"
43     #include "cpu.h"
44 dpavlin 12 #include "device.h"
45 dpavlin 4 #include "devices.h"
46     #include "machine.h"
47     #include "memory.h"
48     #include "misc.h"
49    
50 dpavlin 24 #include "testmachine/dev_cons.h"
51 dpavlin 4
52 dpavlin 24
53 dpavlin 4 #define CONS_TICK_SHIFT 14
54    
55    
56 dpavlin 30 DEVICE_TICK(cons)
57 dpavlin 4 {
58 dpavlin 8 struct cpu *c = cpu->machine->cpus[0];
59 dpavlin 4 struct cons_data *d = extra;
60    
61 dpavlin 8 cpu_interrupt_ack(c, d->irq_nr);
62 dpavlin 4
63     if (console_charavail(d->console_handle))
64 dpavlin 8 cpu_interrupt(c, d->irq_nr);
65 dpavlin 4 }
66    
67    
68 dpavlin 22 DEVICE_ACCESS(cons)
69 dpavlin 4 {
70     struct cons_data *d = extra;
71 dpavlin 22 unsigned int i;
72 dpavlin 4
73     /* Exit the emulator: */
74     if (relative_addr == DEV_CONS_HALT) {
75 dpavlin 24 /* cpu->running = 0;
76     cpu->machine->exit_without_entering_debugger = 1;
77     return 1; */
78     /* TODO: this doesn't work yet. for now, let's
79     simply use exit() */
80     exit(1);
81 dpavlin 4 }
82    
83     if (writeflag == MEM_WRITE) {
84     for (i=0; i<len; i++) {
85     if (data[i] != 0) {
86     if (cpu->machine->register_dump ||
87     cpu->machine->instruction_trace)
88     debug("putchar '");
89    
90     console_putchar(d->console_handle, data[i]);
91    
92     if (cpu->machine->register_dump ||
93     cpu->machine->instruction_trace)
94     debug("'\n");
95     fflush(stdout);
96     }
97     }
98     } else {
99     int ch = console_readchar(d->console_handle);
100     if (ch < 0)
101     ch = 0;
102     for (i=0; i<len; i++)
103     data[i] = ch;
104     }
105    
106     dev_cons_tick(cpu, extra);
107    
108     return 1;
109     }
110    
111    
112 dpavlin 22 DEVINIT(cons)
113 dpavlin 4 {
114     struct cons_data *d;
115 dpavlin 12 char *name3;
116 dpavlin 10 size_t nlen;
117 dpavlin 4
118     d = malloc(sizeof(struct cons_data));
119     if (d == NULL) {
120     fprintf(stderr, "out of memory\n");
121     exit(1);
122     }
123     memset(d, 0, sizeof(struct cons_data));
124    
125 dpavlin 12 nlen = strlen(devinit->name) + 10;
126     if (devinit->name2 != NULL)
127     nlen += strlen(devinit->name2) + 10;
128     name3 = malloc(nlen);
129     if (name3 == NULL) {
130 dpavlin 4 fprintf(stderr, "out of memory in dev_cons_init()\n");
131     exit(1);
132     }
133 dpavlin 12 if (devinit->name2 != NULL && devinit->name2[0])
134     snprintf(name3, nlen, "%s [%s]", devinit->name, devinit->name2);
135 dpavlin 4 else
136 dpavlin 12 snprintf(name3, nlen, "%s", devinit->name);
137 dpavlin 4
138 dpavlin 12 d->irq_nr = devinit->irq_nr;
139 dpavlin 22 d->in_use = devinit->in_use;
140     d->console_handle = console_start_slave(devinit->machine, name3,
141     d->in_use);
142 dpavlin 4
143 dpavlin 12 memory_device_register(devinit->machine->memory, name3,
144     devinit->addr, DEV_CONS_LENGTH, dev_cons_access, d,
145 dpavlin 20 DM_DEFAULT, NULL);
146 dpavlin 12 machine_add_tickfunction(devinit->machine, dev_cons_tick,
147 dpavlin 24 d, CONS_TICK_SHIFT, 0.0);
148 dpavlin 12
149 dpavlin 22 /* NOTE: Ugly cast into pointer */
150     devinit->return_ptr = (void *)(size_t)d->console_handle;
151 dpavlin 12 return 1;
152 dpavlin 4 }
153    

  ViewVC Help
Powered by ViewVC 1.1.26