Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/arm26 Add support for using RISC OS podule loaders ...



details:   https://anonhg.NetBSD.org/src/rev/ffec5bfa27ac
branches:  trunk
changeset: 500907:ffec5bfa27ac
user:      bjh21 <bjh21%NetBSD.org@localhost>
date:      Wed Dec 20 10:57:38 2000 +0000

description:
Add support for using RISC OS podule loaders to get at ROM chunks on podules.
By default, they aren't used, since most cards seem to put the non-OS-dependent
stuff in the main chunk directory.  i-cubed cards are a notable exception.

diffstat:

 sys/arch/arm26/conf/files.arm26          |    6 +-
 sys/arch/arm26/podulebus/podloader_asm.S |   61 +++++++++++++
 sys/arch/arm26/podulebus/podulebus.c     |  136 ++++++++++++++++++++++++------
 sys/arch/arm26/podulebus/podulebus.h     |    9 +-
 4 files changed, 180 insertions(+), 32 deletions(-)

diffs (truncated from 348 to 300 lines):

diff -r 3820ca92e8cb -r ffec5bfa27ac sys/arch/arm26/conf/files.arm26
--- a/sys/arch/arm26/conf/files.arm26   Wed Dec 20 10:44:29 2000 +0000
+++ b/sys/arch/arm26/conf/files.arm26   Wed Dec 20 10:57:38 2000 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.arm26,v 1.8 2000/12/09 18:54:01 bjh21 Exp $
+# $NetBSD: files.arm26,v 1.9 2000/12/20 10:57:38 bjh21 Exp $
 
 # Copyright (c) 1997, 1998, 2000 Ben Harris
 # All rights reserved.
@@ -118,7 +118,9 @@
 attach unixbp at ioc
 device podulebus { [slot = -1] }
 attach podulebus at ioc
+define podloader
 file   arch/arm26/podulebus/podulebus.c        podulebus
+file   arch/arm26/podulebus/podloader_asm.S    podloader       needs-flag
 file   arch/arm26/podulebus/unixbp.c           unixbp          needs-flag
 
 # Acorn ST506 interface (usually at bank 5 irq 11, or sometimes on a podule)
@@ -172,7 +174,7 @@
 file   arch/arm26/podulebus/if_ea.c            ea
 
 # i-cubed EtherLAN 100, 200 and 500
-device eh: ether, ifnet, arp, dp8390nic
+device eh: ether, ifnet, arp, dp8390nic, podloader
 attach eh at podulebus
 file   arch/arm26/podulebus/if_eh.c            eh
 
diff -r 3820ca92e8cb -r ffec5bfa27ac sys/arch/arm26/podulebus/podloader_asm.S
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/arm26/podulebus/podloader_asm.S  Wed Dec 20 10:57:38 2000 +0000
@@ -0,0 +1,61 @@
+/*     $NetBSD: podloader_asm.S,v 1.1 2000/12/20 10:57:38 bjh21 Exp $  */
+
+/*-
+ * Copyright (c) 2000 Ben Harris
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+/* This file is part of NetBSD/arm26 -- a port of NetBSD to ARM2/3 machines. */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: podloader_asm.S,v 1.1 2000/12/20 10:57:38 bjh21 Exp $")
+
+#include <sys/errno.h>
+
+/*
+ * register_t podloader_call(register_t r0, register_t r1, register_t r11,
+ *     void *loader, int entry)
+ */
+ENTRY(podloader_call)
+       mov     ip, sp
+       stmfd   sp!, {r4, fp, ip, lr, pc}
+       sub     fp, ip, #4
+       ldr     r4, [fp, #4]            /* fetch entry */
+       bl      _C_LABEL(int_off)
+       stmfd   sp!, {fp}               /* Save FP, since that's R11 */
+       mov     r11, r2
+       mov     lr, pc
+       add     pc, r3, r4, lsl #2      /* Call loader */
+       ldmfd   sp!, {fp}
+       bl      _C_LABEL(int_on)
+       adrvs   r0, Lpodloader_panicmsg
+       blvs    _C_LABEL(panic)
+#ifdef __APCS_26__
+       ldmdb   fp, {r4, fp, sp, pc}^
+#else
+       ldmdb   fp, {r4, fp, sp, pc}
+#endif
+Lpodloader_panicmsg:
+       .asciz  "podloader_call"
diff -r 3820ca92e8cb -r ffec5bfa27ac sys/arch/arm26/podulebus/podulebus.c
--- a/sys/arch/arm26/podulebus/podulebus.c      Wed Dec 20 10:44:29 2000 +0000
+++ b/sys/arch/arm26/podulebus/podulebus.c      Wed Dec 20 10:57:38 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: podulebus.c,v 1.4 2000/12/14 20:40:29 bjh21 Exp $ */
+/* $NetBSD: podulebus.c,v 1.5 2000/12/20 10:57:38 bjh21 Exp $ */
 
 /*-
  * Copyright (c) 2000 Ben Harris
@@ -30,7 +30,7 @@
 
 #include <sys/param.h>
 
-__RCSID("$NetBSD: podulebus.c,v 1.4 2000/12/14 20:40:29 bjh21 Exp $");
+__RCSID("$NetBSD: podulebus.c,v 1.5 2000/12/20 10:57:38 bjh21 Exp $");
 
 #include <sys/device.h>
 #include <sys/malloc.h>
@@ -48,6 +48,7 @@
 
 #include "locators.h"
 
+#include "podloader.h"
 #include "unixbp.h"
 
 #if NUNIXBP > 0
@@ -59,9 +60,14 @@
 static void podulebus_probe_podule(struct device *, int);
 static int podulebus_print(void *, char const *);
 static int podulebus_submatch(struct device *, struct cfdata *, void *);
-static void podulebus_read_chunks(struct device *,
-                                 struct podulebus_attach_args *);
+static void podulebus_read_chunks(struct podulebus_attach_args *, int);
 static u_int8_t *podulebus_get_chunk(struct podulebus_attach_args *pa, int type);
+#if NPODLOADER > 0
+void podloader_read_region(struct podulebus_attach_args *pa, u_int src,
+    u_int8_t *dest, size_t length);
+extern register_t podloader_call(register_t, register_t, register_t,
+    void *, int);
+#endif
 
 struct podulebus_softc {
        struct  device sc_dev;
@@ -104,7 +110,7 @@
        struct podulebus_softc *sc = (struct podulebus_softc *)self;
        bus_space_tag_t id_bst;
        bus_space_handle_t id_bsh;
-       int ecid;
+       int ecid, w;
        u_int8_t extecid[EXTECID_SIZE];
        struct podulebus_attach_args pa;
 
@@ -148,9 +154,17 @@
                                 extecid[EXTECID_PHI] << 8);
                pa.pa_slotnum = slotnum;
                if (pa.pa_flags1 & EXTECID_F1_CD) {
-                       podulebus_read_chunks(self, &pa);
-                       pa.pa_descr = podulebus_get_chunk(&pa,
+                       w = pa.pa_flags1 & EXTECID_F1_W_MASK;
+                       if (w != EXTECID_F1_W_8BIT) {
+                               /* RISC OS 3 can't handle this either. */
+                               printf("%s:%d: ROM is not 8 bits wide; "
+                                   "ignoring it\n",
+                                   self->dv_xname, pa.pa_slotnum);
+                       } else {
+                               podulebus_read_chunks(&pa, 0);
+                               pa.pa_descr = podulebus_get_chunk(&pa,
                                                          CHUNK_DEV_DESCR);
+                       }
                }
                config_found_sm(self, &pa,
                                podulebus_print, podulebus_submatch);
@@ -158,28 +172,31 @@
                        FREE(pa.pa_chunks, M_DEVBUF);
                if (pa.pa_descr)
                        FREE(pa.pa_descr, M_DEVBUF);
+               if (pa.pa_loader)
+                       FREE(pa.pa_loader, M_DEVBUF);
        } else
                printf("%s:%d: non-extended podule ignored.\n",
                       self->dv_xname, slotnum);
 }
 
 static void
-podulebus_read_chunks(struct device *self, struct podulebus_attach_args *pa)
+podulebus_read_chunks(struct podulebus_attach_args *pa, int useloader)
 {
        u_int8_t chunk[8];
-       u_int ptr, w, nchunks, type, length, offset;
+       u_int ptr, nchunks, type, length, offset;
 
-       nchunks = 0;
-       ptr = EXTECID_SIZE + IRQPTR_SIZE;
-       w = pa->pa_flags1 & EXTECID_F1_W_MASK;
-       if (w != EXTECID_F1_W_8BIT) {
-               /* RISC OS 3 can't handle this either. */
-               printf("%s:%d: ROM is not 8 bits wide; ignoring it\n",
-                      self->dv_xname, pa->pa_slotnum);
-               return;
-       }
+       nchunks = pa->pa_nchunks;
+       if (useloader)
+               ptr = 0;
+       else
+               ptr = EXTECID_SIZE + IRQPTR_SIZE;
        for (;;) {
-               bus_space_read_region_1(pa->pa_sync_t, pa->pa_sync_h,
+#if NPODLOADER > 0
+               if (useloader)
+                       podloader_read_region(pa, ptr, chunk, 8);
+               else
+#endif
+                       bus_space_read_region_1(pa->pa_sync_t, pa->pa_sync_h,
                                        ptr, chunk, 8);
                ptr += 8;
                type = chunk[0];
@@ -197,6 +214,7 @@
                pa->pa_chunks[nchunks-1].pc_type = type;
                pa->pa_chunks[nchunks-1].pc_length = length;
                pa->pa_chunks[nchunks-1].pc_offset = offset;
+               pa->pa_chunks[nchunks-1].pc_useloader = useloader;
        }
        pa->pa_nchunks = nchunks;
 }
@@ -205,23 +223,83 @@
 podulebus_get_chunk(struct podulebus_attach_args *pa, int type)
 {
        int i;
+       struct podulebus_chunk *pc;
        u_int8_t *chunk;
 
-       for (i = 0; i < pa->pa_nchunks; i++)
-               if (pa->pa_chunks[i].pc_type == type) {
-                       MALLOC(chunk, u_int8_t *,
-                              pa->pa_chunks[i].pc_length + 1,
-                              M_DEVBUF, M_WAITOK);
-                       bus_space_read_region_1(pa->pa_sync_t, pa->pa_sync_h,
-                                               pa->pa_chunks[i].pc_offset,
-                                               chunk,
-                                               pa->pa_chunks[i].pc_length);
-                       chunk[pa->pa_chunks[i].pc_length] = 0;
+       for (i = 0; i < pa->pa_nchunks; i++) {
+               pc = &pa->pa_chunks[i];
+               if (pc->pc_type == type) {
+                       chunk = malloc( pc->pc_length + 1, M_DEVBUF, M_WAITOK);
+#if NPODLOADER > 0
+                       if (pc->pc_useloader)
+                               podloader_read_region(pa, pc->pc_offset, chunk,
+                                   pc->pc_length);
+                       else
+#endif
+                               bus_space_read_region_1(pa->pa_sync_t,
+                                   pa->pa_sync_h, pc->pc_offset, chunk,
+                                   pc->pc_length);
+                       chunk[pc->pc_length] = 0;
                        return chunk;
                }
+       }
        return NULL;
 }
 
+#if NPODLOADER > 0
+int
+podulebus_initloader(struct podulebus_attach_args *pa)
+{
+
+       pa->pa_loader = podulebus_get_chunk(pa, CHUNK_RISCOS_LOADER);
+       if (pa->pa_loader == NULL)
+               return -1;
+       podulebus_read_chunks(pa, 1);
+       if (pa->pa_descr)
+               FREE(pa->pa_descr, M_DEVBUF);
+       pa->pa_descr = podulebus_get_chunk(pa, CHUNK_DEV_DESCR);
+       return 0;
+}
+
+int
+podloader_readbyte(struct podulebus_attach_args *pa, u_int addr)
+{
+
+       return podloader_call(0, addr, pa->pa_sync_h, pa->pa_loader, 0);
+}
+
+void
+podloader_writebyte(struct podulebus_attach_args *pa, u_int addr, int val)
+{
+
+       podloader_call(val, addr, pa->pa_sync_h, pa->pa_loader, 1);
+}
+
+void
+podloader_reset(struct podulebus_attach_args *pa)
+{
+
+       podloader_call(0, 0, pa->pa_sync_h, pa->pa_loader, 2);
+}
+
+int
+podloader_callloader(struct podulebus_attach_args *pa, u_int r0, u_int r1)
+{
+
+       return podloader_call(r0, r1, pa->pa_sync_h, pa->pa_loader, 3);
+}
+
+void
+podloader_read_region(struct podulebus_attach_args *pa, u_int src,
+    u_int8_t *dest, size_t length)



Home | Main Index | Thread Index | Old Index