/[gxemul]/upstream/0.3.8/src/devices/dev_algor.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

Contents of /upstream/0.3.8/src/devices/dev_algor.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 23 - (show annotations)
Mon Oct 8 16:19:43 2007 UTC (16 years, 8 months ago) by dpavlin
File MIME type: text/plain
File size: 3298 byte(s)
0.3.8
1 /*
2 * Copyright (C) 2005-2006 Anders Gavare. All rights reserved.
3 *
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 * $Id: dev_algor.c,v 1.1 2006/02/18 17:55:25 debug Exp $
29 *
30 * Algor misc. stuff.
31 *
32 * TODO: This is hardcoded for P5064 right now. Generalize it to P40xx etc.
33 */
34
35 #include <stdio.h>
36 #include <stdlib.h>
37 #include <string.h>
38
39 #include "cpu.h"
40 #include "device.h"
41 #include "devices.h"
42 #include "machine.h"
43 #include "memory.h"
44 #include "misc.h"
45
46 #include "algor_p5064reg.h"
47
48
49 DEVICE_ACCESS(algor)
50 {
51 struct algor_data *d = extra;
52 uint64_t idata = 0, odata = 0;
53 char *n = NULL;
54
55 if (writeflag == MEM_WRITE)
56 idata = memory_readmax64(cpu, data, len);
57
58 relative_addr += d->base_addr;
59
60 switch (relative_addr) {
61
62 case P5064_LOCINT:
63 {
64 static int x = 0;
65 x ++;
66 odata = LOCINT_PCIBR;
67 if ((x & 0xffff) == 0)
68 odata |= LOCINT_RTC;
69 }
70 break;
71
72 default:if (writeflag == MEM_READ) {
73 fatal("[ algor: read from 0x%x ]\n",
74 (int)relative_addr);
75 } else {
76 fatal("[ algor: write to 0x%x: 0x%llx ]\n",
77 (int)relative_addr, (long long)idata);
78 }
79 }
80
81 if (n != NULL) {
82 if (writeflag == MEM_READ) {
83 debug("[ algor: read from %s ]\n", n);
84 } else {
85 debug("[ algor: write to %s: 0x%llx ]\n",
86 n, (long long)idata);
87 }
88 }
89
90 if (writeflag == MEM_READ)
91 memory_writemax64(cpu, data, len, odata);
92
93 return 1;
94 }
95
96
97 DEVINIT(algor)
98 {
99 struct algor_data *d = malloc(sizeof(struct algor_data));
100 if (d == NULL) {
101 fprintf(stderr, "out of memory\n");
102 exit(1);
103 }
104 memset(d, 0, sizeof(struct algor_data));
105
106 if (devinit->addr != 0x1ff00000) {
107 fatal("The Algor base address should be 0x1ff00000.\n");
108 exit(1);
109 }
110
111 memory_device_register(devinit->machine->memory, devinit->name,
112 devinit->addr, 0x100000, dev_algor_access, d, DM_DEFAULT, NULL);
113
114 d->base_addr = devinit->addr;
115
116 devinit->return_ptr = d;
117
118 return 1;
119 }
120

  ViewVC Help
Powered by ViewVC 1.1.26