Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding external cache support of DayStar PowerCache accelerator #67

Open
ghost opened this issue Jun 20, 2014 · 0 comments
Open

Adding external cache support of DayStar PowerCache accelerator #67

ghost opened this issue Jun 20, 2014 · 0 comments

Comments

@ghost
Copy link

ghost commented Jun 20, 2014

Metadata

Description


    This patch adds ext. cache support of DayStar PowerCache accelerator.

How to repeat


    Turn external cache on within MacOS, boot NetBSD and see it hangs.

Fix


    This patch adds external writeback cache support of DayStar PowerCache
    accelerator.  I've been using this for months without any trouble.

* DayStar PowerCache support.  Original work was done by Kevin Radke, merged
  into 1.2(E?) source by David Condon.  Applying them to 1.3F and adding
  support to handle shutdown properly by me.

Index: locore.s
===================================================================
RCS file: /var/cvsroot/src/sys/arch/mac68k/mac68k/locore.s,v
retrieving revision 1.1.1.1
retrieving revision 1.3
diff -u -u -r1.1.1.1 -r1.3
--- locore.s    1998/07/26 17:28:48 1.1.1.1
+++ locore.s    1998/09/06 15:00:34 1.3
@@ -118,6 +118,9 @@
 GLOBAL(bletch)
    .long   0

+   .globl  _disable_daystar    | in pmap.c /* kmr */
+
+
 BSS(esym,4)

 ASENTRY_NOPROFILE(start)
@@ -150,6 +153,7 @@
    movc    cacr,d0         | read it back
    tstl    d0          | zero?
    jeq Lnot68030       | yes, we have 68020/68040
+   jbsr    _disable_daystar | Disable daystar external cache /* kmr */

    movl    #CACHE_OFF,d0       | disable and clear both caches
    movc    d0,cacr
@@ -314,10 +318,13 @@

 /* flush TLB and turn on caches */
    jbsr    _C_LABEL(TBIA)      | invalidate TLB
+        .globl  _flush_daystar /* kmr */
    cmpl    #MMU_68040,_C_LABEL(mmutype) | 68040?
    jeq Lnocache0       | yes, cache already on
    movl    #CACHE_ON,d0
    movc    d0,cacr         | clear cache(s)
+        jbsr    _flush_daystar          | flush daystar external cache /* kmr */
+
 #ifdef __notyet__
    tstl    _C_LABEL(ectype)
    jeq Lnocache0
@@ -1319,12 +1326,15 @@
    movl    #DC_CLEAR,d0
    movc    d0,cacr         | invalidate on-chip d-cache
 Ltbia851:
+        jbsr    _flush_daystar     | flush daystar external cache /* kmr */
    rts

 /*
  * Invalidate any TLB entry for given VA (TB Invalidate Single)
  */
 ENTRY(TBIS)
+        .globl  _flush_daystar /* kmr */
+
 #ifdef DEBUG
    tstl    _ASM_LABEL(fulltflush)  | being conservative?
    jne _C_LABEL(_TBIA)     | yes, flush entire TLB
@@ -1354,12 +1364,15 @@
    pflush  #0,#0,a0@       | flush address from both sides
    movl    #DC_CLEAR,d0
    movc    d0,cacr         | invalidate on-chip data cache
+        jbsr    _flush_daystar     | flush daystar external cache /* kmr */
    rts

 /*
  * Invalidate supervisor side of TLB
  */
 ENTRY(TBIAS)
+        .globl  _flush_daystar /* kmr */
+
 #ifdef DEBUG
    tstl    _ASM_LABEL(fulltflush)  | being conservative?
    jne _C_LABEL(_TBIA)     | yes, flush everything
@@ -1381,12 +1394,14 @@
    pflush  #4,#4           | flush supervisor TLB entries
    movl    #DC_CLEAR,d0
    movc    d0,cacr         | invalidate on-chip d-cache
+        jbsr    _flush_daystar     | flush daystar external cache /* kmr */
    rts

 /*
  * Invalidate user side of TLB
  */
 ENTRY(TBIAU)
+        .globl  _flush_daystar /* kmr */
 #ifdef DEBUG
    tstl    _ASM_LABEL(fulltflush)  | being conservative?
    jne _C_LABEL(_TBIA)     | yes, flush everything
@@ -1407,6 +1422,7 @@
    pflush  #0,#4           | flush user TLB entries
    movl    #DC_CLEAR,d0
    movc    d0,cacr         | invalidate on-chip d-cache
+        jbsr    _flush_daystar     | flush daystar external cache /* kmr */
    rts

 /*
@@ -1493,6 +1509,7 @@
 #endif /* M68040 */

 ENTRY(PCIA)
+        .globl  _flush_daystar /* kmr */
 #if defined(M68040)
 ENTRY(DCFA)
    cmpl    #MMU_68040,_C_LABEL(mmutype) | 68040?
@@ -1503,6 +1520,7 @@
 #endif
    movl    #DC_CLEAR,d0
    movc    d0,cacr         | invalidate on-chip d-cache
+        jbsr    _flush_daystar     | flush daystar external cache /* kmr */
    rts

 ENTRY(ecacheon)
Index: machdep.c
===================================================================
RCS file: /var/cvsroot/src/sys/arch/mac68k/mac68k/machdep.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -u -r1.1.1.1 -r1.2
--- machdep.c   1998/07/26 17:28:48 1.1.1.1
+++ machdep.c   1998/09/04 00:46:08 1.2
@@ -268,6 +268,10 @@
  */
 cpu_kcore_hdr_t cpu_kcore_hdr;

+#ifdef POWERCACHE_SUPPORT
+extern inline void disable_daystar __P((void));    /* in pmap.c */
+#endif
+
 /*
  * Early initialization, before main() is called.
  */
@@ -725,6 +729,9 @@
 #if __GNUC__   /* XXX work around lame compiler problem (gcc 2.7.2) */
    (void)&howto;
 #endif
+#ifdef POWERCACHE_SUPPORT
+   disable_daystar();  /* disable daystar external cache */
+#endif /* POWERCACHE_SUPPORT */
    /* take a snap shot before clobbering any registers */
    if (curproc && curproc->p_addr)
        savectx(&curproc->p_addr->u_pcb);
Index: pmap.c
===================================================================
RCS file: /var/cvsroot/src/sys/arch/mac68k/mac68k/pmap.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -u -r1.1.1.1 -r1.2
--- pmap.c  1998/07/26 17:28:49 1.1.1.1
+++ pmap.c  1998/09/04 00:46:10 1.2
@@ -282,6 +282,9 @@
 int        page_cnt;   /* number of pages managed by VM system */

 boolean_t  pmap_initialized = FALSE;   /* Has pmap_init completed? */
+#ifdef POWERCACHE_SUPPORT
+boolean_t  daystar_initialized = FALSE; /* Has map_daystar completed? */
+#endif /* POWERCACHE_SUPPORT */
 struct pv_entry    *pv_table;
 char       *pmap_attributes;   /* reference and modify bits */
 TAILQ_HEAD(pv_page_list, pv_page) pv_page_freelist;
@@ -328,6 +331,12 @@
 void   pmap_changebit  __P((vm_offset_t, int, boolean_t));
 void   pmap_enter_ptpage   __P((pmap_t, vm_offset_t));
 void   pmap_collect1   __P((pmap_t, vm_offset_t, vm_offset_t));
+#ifdef POWERCACHE_SUPPORT
+inline void    flush_daystar   __P((void));
+inline void    disable_daystar __P((void));
+inline void    enable_daystar  __P((void));
+inline void    map_daystar __P((void));
+#endif /* POWERCACHE_SUPPORT */

 #ifdef DEBUG
 void   pmap_pvdump          __P((vm_offset_t));
@@ -541,6 +550,13 @@
               atop(s), addr, addr + s);
 #endif

+#ifdef POWERCACHE_SUPPORT
+        /*
+         * Map physical memory addresses used by daystar accelerator
+         */
+        map_daystar();
+#endif /* POWERCACHE_SUPPORT */
+
    /*
     * Allocate the segment table map
     */
@@ -2630,3 +2646,83 @@

    return -1;
 }
+
+#ifdef POWERCACHE_SUPPORT
+/*
+ * DayStar PowerCache support routines
+ *
+ *   This routines are originally written by Kevin Radke for NetBSD-XXX and
+ *   modified to fit NetBSD-XXX by David Condon <david@apk.net>.
+ */
+
+/*
+ * flush_daystar()
+ *
+ *   Flush external cache of DayStar PowerCache
+ */
+
+inline void
+flush_daystar(void)
+{
+   if (daystar_initialized) {
+/*     printf("."); */
+       asm("tstb   0x520f0000 | flush daystar external cache");
+   }
+/* else
+       printf ("***** Flush called before map!\n"); */
+}
+
+/*
+ * disable_daystar()
+ *
+ *   Disable external writeback cache of DayStar PowerCache
+ */
+
+inline void
+disable_daystar(void)
+{
+   asm("tstb   0x52040000 | disable writeback cache");
+   asm("tstb   0x52060000 | disable daystar external cache");
+   asm("tstb   0x520f0000 | flush daystar external cache");
+}
+
+/* 
+ * enable_daystar()
+ *
+ *   Enable external writeback cache of DayStar PowerCache
+ */
+
+inline void
+enable_daystar(void)
+{
+   disable_daystar();
+   printf("Enabling DayStar External Cache...\n");
+   asm("tstb   0x52070000 | enable daystar external cache");
+   asm("tstb   0x52050000 | enable writeback cache");
+   flush_daystar();
+}
+
+/*
+ * map_daystar()
+ *
+ *   Map DayStar PowerCache control registers in pmap
+ */
+
+inline void
+map_daystar(void)
+{
+   printf("Mapping DayStar PowerCache Hardware Addresses...\n");
+   pmap_enter (pmap_kernel(), 0x52040000, 0x52040000,
+           VM_PROT_READ | VM_PROT_WRITE, TRUE);
+   pmap_enter (pmap_kernel(), 0x52050000, 0x52050000,
+           VM_PROT_READ | VM_PROT_WRITE, TRUE);
+   pmap_enter (pmap_kernel(), 0x52060000, 0x52060000,
+           VM_PROT_READ | VM_PROT_WRITE, TRUE);
+   pmap_enter (pmap_kernel(), 0x52070000, 0x52070000,
+           VM_PROT_READ | VM_PROT_WRITE, TRUE);
+   pmap_enter (pmap_kernel(), 0x520f0000, 0x520f0000,
+           VM_PROT_READ | VM_PROT_WRITE, TRUE);
+   daystar_initialized = TRUE;
+   enable_daystar();
+}
+#endif /* POWERCACHE_SUPPORT */
Index: sys_machdep.c
===================================================================
RCS file: /var/cvsroot/src/sys/arch/mac68k/mac68k/sys_machdep.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -u -r1.1.1.1 -r1.2
--- sys_machdep.c   1998/07/26 17:28:50 1.1.1.1
+++ sys_machdep.c   1998/09/04 00:46:13 1.2
@@ -152,6 +152,7 @@
 int    cachectl __P((int, caddr_t, int));
 void   DCIU __P((void));
 void   ICIA __P((void));
+void   PCIA __P((void));

 /*ARGSUSED1*/
 int
@@ -165,11 +166,18 @@
    switch (req) {
    case CC_EXTPURGE|CC_PURGE:
    case CC_EXTPURGE|CC_FLUSH:
+#ifdef POWERCACHE_SUPPORT
+       PCIA(); /* flush daystar external cache */
+#endif /* POWERCACHE_SUPPORT */
+       /* fall into... */
    case CC_PURGE:
    case CC_FLUSH:
        DCIU();
        break;
    case CC_EXTPURGE|CC_IPURGE:
+#ifdef POWERCACHE_SUPPORT
+       PCIA(); /* flush daystar external cache */
+#endif /* POWERCACHE_SUPPORT */
        DCIU();
        /* fall into... */
    case CC_IPURGE:

Audit trail


Responsible-Changed-From-To: gnats-admin->port-mac68k-maintainer 
Responsible-Changed-By: fair 
Responsible-Changed-When: Mon Dec 28 09:38:25 PST 1998 
Responsible-Changed-Why:  
This PR is the responsibility of the portmaster, 
not the GNATS database administrator. 

From: "Erik E. Fair" <fair@clock.org>
To: NetBSD GNATS Problem Report Tracking System <gnats-bugs@gnats.netbsd.org>
Cc:  
Subject: Re: port-mac68k/6112
Date: Thu, 17 Jan 2002 23:06:14 -0800

 Have these changes been comitted to the source repository?

    curious GNATS PR database administrator,

    Erik <fair@netbsd.org>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

0 participants