Thu Dec 20 21:38:23 2018 UTC ()
set base_year_is_2k on dsrtc so we're compatible with RISC OS


(macallan)
diff -r1.16 -r1.17 src/sys/arch/iyonix/iyonix/autoconf.c

cvs diff -r1.16 -r1.17 src/sys/arch/iyonix/iyonix/autoconf.c (switch to unified diff)

--- src/sys/arch/iyonix/iyonix/autoconf.c 2018/11/21 20:36:41 1.16
+++ src/sys/arch/iyonix/iyonix/autoconf.c 2018/12/20 21:38:23 1.17
@@ -1,190 +1,194 @@ @@ -1,190 +1,194 @@
1/* $NetBSD: autoconf.c,v 1.16 2018/11/21 20:36:41 macallan Exp $ */ 1/* $NetBSD: autoconf.c,v 1.17 2018/12/20 21:38:23 macallan Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2001 The NetBSD Foundation, Inc. 4 * Copyright (c) 2001 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Matt Thomas <matt@3am-software.com>. 8 * by Matt Thomas <matt@3am-software.com>.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright 15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the 16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution. 17 * documentation and/or other materials provided with the distribution.
18 * 18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.16 2018/11/21 20:36:41 macallan Exp $"); 33__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.17 2018/12/20 21:38:23 macallan Exp $");
34 34
35#include "opt_md.h" 35#include "opt_md.h"
36 36
37#include <sys/param.h> 37#include <sys/param.h>
38#include <sys/systm.h> 38#include <sys/systm.h>
39#include <sys/reboot.h> 39#include <sys/reboot.h>
40#include <sys/disklabel.h> 40#include <sys/disklabel.h>
41#include <sys/device.h> 41#include <sys/device.h>
42#include <sys/conf.h> 42#include <sys/conf.h>
43#include <sys/kernel.h> 43#include <sys/kernel.h>
44#include <sys/malloc.h> 44#include <sys/malloc.h>
45 45
46#include <net/if.h> 46#include <net/if.h>
47#include <net/if_ether.h> 47#include <net/if_ether.h>
48 48
49#include <machine/autoconf.h> 49#include <machine/autoconf.h>
50#include <machine/intr.h> 50#include <machine/intr.h>
51 51
52#include <iyonix/iyonix/iyonixvar.h> 52#include <iyonix/iyonix/iyonixvar.h>
53 53
54#include <acorn32/include/bootconfig.h> 54#include <acorn32/include/bootconfig.h>
55 55
56extern struct bootconfig bootconfig; 56extern struct bootconfig bootconfig;
57 57
58/* 58/*
59 * Set up the root device from the boot args 59 * Set up the root device from the boot args
60 */ 60 */
61void 61void
62cpu_rootconf(void) 62cpu_rootconf(void)
63{ 63{
64 aprint_normal("boot device: %s\n", 64 aprint_normal("boot device: %s\n",
65 booted_device != NULL ? device_xname(booted_device) : "<unknown>"); 65 booted_device != NULL ? device_xname(booted_device) : "<unknown>");
66 rootconf(); 66 rootconf();
67} 67}
68 68
69 69
70/* 70/*
71 * void cpu_configure() 71 * void cpu_configure()
72 * 72 *
73 * Configure all the root devices 73 * Configure all the root devices
74 * The root devices are expected to configure their own children 74 * The root devices are expected to configure their own children
75 */ 75 */
76void 76void
77cpu_configure(void) 77cpu_configure(void)
78{ 78{
79 struct mainbus_attach_args maa; 79 struct mainbus_attach_args maa;
80 80
81 (void) splhigh(); 81 (void) splhigh();
82 (void) splserial(); /* XXX need an splextreme() */ 82 (void) splserial(); /* XXX need an splextreme() */
83 83
84 maa.ma_name = "mainbus"; 84 maa.ma_name = "mainbus";
85 85
86 config_rootfound("mainbus", &maa); 86 config_rootfound("mainbus", &maa);
87 87
88 /* Time to start taking interrupts so lets open the flood gates .... */ 88 /* Time to start taking interrupts so lets open the flood gates .... */
89 spl0(); 89 spl0();
90} 90}
91 91
92#define BUILTIN_ETHERNET_P(pa) \ 92#define BUILTIN_ETHERNET_P(pa) \
93 ((pa)->pa_bus == 0 && (pa)->pa_device == 4 && (pa)->pa_function == 0) 93 ((pa)->pa_bus == 0 && (pa)->pa_device == 4 && (pa)->pa_function == 0)
94 94
95#define SETPROP(x, y) \ 95#define SETPROP(x, y) \
96 do { \ 96 do { \
97 if (prop_dictionary_set(device_properties(dev), \ 97 if (prop_dictionary_set(device_properties(dev), \
98 x, y) == false) { \ 98 x, y) == false) { \
99 printf("WARNING: unable to set " x " " \ 99 printf("WARNING: unable to set " x " " \
100 "property for %s\n", device_xname(dev)); \ 100 "property for %s\n", device_xname(dev)); \
101 } \ 101 } \
102 prop_object_release(y); \ 102 prop_object_release(y); \
103 } while (/*CONSTCOND*/0) 103 } while (/*CONSTCOND*/0)
104 104
105void 105void
106device_register(device_t dev, void *aux) 106device_register(device_t dev, void *aux)
107{ 107{
108 device_t pdev; 108 device_t pdev;
109 109
110 if ((pdev = device_parent(dev)) != NULL && 110 if ((pdev = device_parent(dev)) != NULL &&
111 device_is_a(pdev, "pci")) { 111 device_is_a(pdev, "pci")) {
112 struct pci_attach_args *pa = aux; 112 struct pci_attach_args *pa = aux;
113 113
114 if (BUILTIN_ETHERNET_P(pa)) { 114 if (BUILTIN_ETHERNET_P(pa)) {
115 prop_number_t cfg1, cfg2, swdpin; 115 prop_number_t cfg1, cfg2, swdpin;
116 prop_data_t mac; 116 prop_data_t mac;
117 117
118 /* 118 /*
119 * We set these configuration registers to 0, 119 * We set these configuration registers to 0,
120 * because it's the closest we have to "leave them 120 * because it's the closest we have to "leave them
121 * alone". That and, it works. 121 * alone". That and, it works.
122 */ 122 */
123 cfg1 = prop_number_create_integer(0); 123 cfg1 = prop_number_create_integer(0);
124 KASSERT(cfg1 != NULL); 124 KASSERT(cfg1 != NULL);
125 cfg2 = prop_number_create_integer(0); 125 cfg2 = prop_number_create_integer(0);
126 KASSERT(cfg2 != NULL); 126 KASSERT(cfg2 != NULL);
127 swdpin = prop_number_create_integer(0); 127 swdpin = prop_number_create_integer(0);
128 KASSERT(swdpin != NULL); 128 KASSERT(swdpin != NULL);
129 129
130 mac = prop_data_create_data_nocopy(iyonix_macaddr, 130 mac = prop_data_create_data_nocopy(iyonix_macaddr,
131 ETHER_ADDR_LEN); 131 ETHER_ADDR_LEN);
132 KASSERT(mac != NULL); 132 KASSERT(mac != NULL);
133 133
134 SETPROP("mac-address", mac); 134 SETPROP("mac-address", mac);
135 SETPROP("i82543-cfg1", cfg1); 135 SETPROP("i82543-cfg1", cfg1);
136 SETPROP("i82543-cfg2", cfg2); 136 SETPROP("i82543-cfg2", cfg2);
137 SETPROP("i82543-swdpin", swdpin); 137 SETPROP("i82543-swdpin", swdpin);
138 } 138 }
139 } 139 }
140 140
141 if ((device_is_a(dev, "genfb") || device_is_a(dev, "gffb")) && 141 if ((device_is_a(dev, "genfb") || device_is_a(dev, "gffb")) &&
142 device_is_a(device_parent(dev), "pci") ) { 142 device_is_a(device_parent(dev), "pci") ) {
143 prop_dictionary_t dict = device_properties(dev); 143 prop_dictionary_t dict = device_properties(dev);
144 struct pci_attach_args *pa = aux; 144 struct pci_attach_args *pa = aux;
145 pcireg_t bar0, bar1; 145 pcireg_t bar0, bar1;
146 uint32_t fbaddr; 146 uint32_t fbaddr;
147 bus_space_handle_t vgah; 147 bus_space_handle_t vgah;
148 148
149 bar0 = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_MAPREG_START); 149 bar0 = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_MAPREG_START);
150 bar1 = pci_conf_read(pa->pa_pc, pa->pa_tag, 150 bar1 = pci_conf_read(pa->pa_pc, pa->pa_tag,
151 PCI_MAPREG_START + 0x04); 151 PCI_MAPREG_START + 0x04);
152 152
153 /* 153 /*
154 * We need to prod the VGA card to disable interrupts, since 154 * We need to prod the VGA card to disable interrupts, since
155 * RISC OS has been using them and we don't know how to 155 * RISC OS has been using them and we don't know how to
156 * handle them. This assumes that we have a NVidia 156 * handle them. This assumes that we have a NVidia
157 * GeForce 2 MX card as supplied with the Iyonix and 157 * GeForce 2 MX card as supplied with the Iyonix and
158 * as (probably) required by RISC OS in order to boot. 158 * as (probably) required by RISC OS in order to boot.
159 * If you write your own RISC OS driver for a different card, 159 * If you write your own RISC OS driver for a different card,
160 * you're on your own. 160 * you're on your own.
161 */ 161 */
162 162
163/* We're guessing at the numbers here, guys */ 163/* We're guessing at the numbers here, guys */
164#define VGASIZE 0x1000 164#define VGASIZE 0x1000
165#define IRQENABLE_ADDR 0x140 165#define IRQENABLE_ADDR 0x140
166 166
167 bus_space_map(pa->pa_memt, PCI_MAPREG_MEM_ADDR(bar0),  167 bus_space_map(pa->pa_memt, PCI_MAPREG_MEM_ADDR(bar0),
168 VGASIZE, 0, &vgah); 168 VGASIZE, 0, &vgah);
169 bus_space_write_4(pa->pa_memt, vgah, 0x140, 0); 169 bus_space_write_4(pa->pa_memt, vgah, 0x140, 0);
170 bus_space_unmap(pa->pa_memt, vgah, 0x1000); 170 bus_space_unmap(pa->pa_memt, vgah, 0x1000);
171 171
172 fbaddr = PCI_MAPREG_MEM_ADDR(bar1); 172 fbaddr = PCI_MAPREG_MEM_ADDR(bar1);
173 173
174 prop_dictionary_set_bool(dict, "is_console", 1); 174 prop_dictionary_set_bool(dict, "is_console", 1);
175 prop_dictionary_set_uint32(dict, "width", 175 prop_dictionary_set_uint32(dict, "width",
176 bootconfig.width + 1); 176 bootconfig.width + 1);
177 prop_dictionary_set_uint32(dict, "height", 177 prop_dictionary_set_uint32(dict, "height",
178 bootconfig.height + 1); 178 bootconfig.height + 1);
179 prop_dictionary_set_uint32(dict, "depth", 179 prop_dictionary_set_uint32(dict, "depth",
180 1 << bootconfig.log2_bpp); 180 1 << bootconfig.log2_bpp);
181 /* 181 /*
182 * XXX 182 * XXX
183 * at least RISC OS 5.28 seems to use the graphics hardware in 183 * at least RISC OS 5.28 seems to use the graphics hardware in
184 * BGR mode when in 32bit colour, so take that into account 184 * BGR mode when in 32bit colour, so take that into account
185 */ 185 */
186 if (bootconfig.log2_bpp == 5) 186 if (bootconfig.log2_bpp == 5)
187 prop_dictionary_set_bool(dict, "is_bgr", 1); 187 prop_dictionary_set_bool(dict, "is_bgr", 1);
188 prop_dictionary_set_uint32(dict, "address", fbaddr); 188 prop_dictionary_set_uint32(dict, "address", fbaddr);
189 } 189 }
 190 if (device_is_a(dev, "dsrtc")) {
 191 prop_dictionary_t dict = device_properties(dev);
 192 prop_dictionary_set_bool(dict, "base_year_is_2000", 1);
 193 }
190} 194}