]> err.no Git - linux-2.6/blobdiff - arch/blackfin/mach-common/cplbmgr.S
[Blackfin] arch: do not use hard coded addresses
[linux-2.6] / arch / blackfin / mach-common / cplbmgr.S
index e4b47e09cf1311b0123450027ba7a08570cabc8b..f5cf3accef378fadae792b6660edf13eb76c284b 100644 (file)
@@ -73,21 +73,30 @@ ENTRY(_cplb_mgr)
        /* ICPLB Miss Exception. We need to choose one of the
        * currently-installed CPLBs, and replace it with one
        * from the configuration table.
-       */
+       */
+
+       /* A multi-word instruction can cross a page boundary. This means the
+        * first part of the instruction can be in a valid page, but the
+        * second part is not, and hence generates the instruction miss.
+        * However, the fault address is for the start of the instruction,
+        * not the part that's in the bad page. Therefore, we have to check
+        * whether the fault address applies to a page that is already present
+        * in the table.
+        */
 
-       P4.L = (ICPLB_FAULT_ADDR & 0xFFFF);
-       P4.H = (ICPLB_FAULT_ADDR >> 16);
+       P4.L = LO(ICPLB_FAULT_ADDR);
+       P4.H = HI(ICPLB_FAULT_ADDR);
 
        P1 = 16;
        P5.L = _page_size_table;
        P5.H = _page_size_table;
 
-       P0.L = (ICPLB_DATA0 & 0xFFFF);
-       P0.H = (ICPLB_DATA0 >> 16);
+       P0.L = LO(ICPLB_DATA0);
+       P0.H = HI(ICPLB_DATA0);
        R4 = [P4];              /* Get faulting address*/
        R6 = 64;                /* Advance past the fault address, which*/
        R6 = R6 + R4;           /* we'll use if we find a match*/
-       R3 = ((16 << 8) | 2);   /* Extract mask, bits 16 and 17.*/
+       R3 = ((16 << 8) | 2);   /* Extract mask, two bits at posn 16 */
 
        R5 = 0;
 .Lisearch:
@@ -117,15 +126,17 @@ ENTRY(_cplb_mgr)
        I0 = R4;                /* Fault address we'll search for*/
 
        /* set up pointers */
-       P0.L = (ICPLB_DATA0 & 0xFFFF);
-       P0.H = (ICPLB_DATA0 >> 16);
+       P0.L = LO(ICPLB_DATA0);
+       P0.H = HI(ICPLB_DATA0);
 
        /* The replacement procedure for ICPLBs */
 
-       P4.L = (IMEM_CONTROL & 0xFFFF);
-       P4.H = (IMEM_CONTROL >> 16);
+       P4.L = LO(IMEM_CONTROL);
+       P4.H = HI(IMEM_CONTROL);
 
-       /* disable cplbs */
+       /* Turn off CPLBs while we work, necessary according to HRM before
+        * modifying CPLB descriptors
+        */
        R5 = [P4];              /* Control Register*/
        BITCLR(R5,ENICPLB_P);
        CLI R1;
@@ -179,7 +190,14 @@ ENTRY(_cplb_mgr)
        [P0 - 4] = R0;
        R0 = [P0 - 0x100];
        [P0-0x104] = R0;
-.Lie_move:P0+=4;
+.Lie_move:
+       P0+=4;
+
+       /* Clear ICPLB_DATA15, in case we don't find a replacement
+        * otherwise, we would have a duplicate entry, and will crash
+        */
+       R0 = 0;
+       [P0 - 4] = R0;
 
        /* We've made space in the ICPLB table, so that ICPLB15
         * is now free to be overwritten. Next, we have to determine
@@ -222,7 +240,7 @@ ENTRY(_cplb_mgr)
 
        /* See if failed address > start address */
        CC = R4 <= R0(IU);
-       IF !CC JUMP .Linext;
+       IF !CC JUMP .Linext;
 
        /* extract page size (17:16)*/
        R3 = EXTRACT(R2, R1.L) (Z);
@@ -243,8 +261,8 @@ ENTRY(_cplb_mgr)
         * last entry of the table.
         */
 
-       P1.L = (ICPLB_DATA15 & 0xFFFF);         /* ICPLB_DATA15 */
-       P1.H = (ICPLB_DATA15 >> 16);
+       P1.L = LO(ICPLB_DATA15);                /* ICPLB_DATA15 */
+       P1.H = HI(ICPLB_DATA15);
        [P1] = R2;
        [P1-0x100] = R4;
 #ifdef CONFIG_CPLB_INFO
@@ -271,16 +289,27 @@ ENTRY(_cplb_mgr)
 
 /* FAILED CASES*/
 .Lno_page_in_table:
-       ( R7:4,P5:3 ) = [SP++];
        R0 = CPLB_NO_ADDR_MATCH;
-       RTS;
+       JUMP .Lfail_ret;
+
 .Lall_locked:
-       ( R7:4,P5:3 ) = [SP++];
        R0 = CPLB_NO_UNLOCKED;
-       RTS;
+       JUMP .Lfail_ret;
+
 .Lprot_violation:
-       ( R7:4,P5:3 ) = [SP++];
        R0 = CPLB_PROT_VIOL;
+
+.Lfail_ret:
+       /* Make sure we turn protection/cache back on, even in the failing case */
+       BITSET(R5,ENICPLB_P);
+       CLI R2;
+       SSYNC;          /* SSYNC required before writing to IMEM_CONTROL. */
+       .align 8;
+       [P4] = R5;
+       SSYNC;
+       STI R2;
+
+       ( R7:4,P5:3 ) = [SP++];
        RTS;
 
 .Ldcplb_write:
@@ -292,10 +321,10 @@ ENTRY(_cplb_mgr)
         * pending writes associated with the CPLB.
         */
 
-       P4.L = (DCPLB_STATUS & 0xFFFF);
-       P4.H = (DCPLB_STATUS >> 16);
-       P3.L = (DCPLB_DATA0 & 0xFFFF);
-       P3.H = (DCPLB_DATA0 >> 16);
+       P4.L = LO(DCPLB_STATUS);
+       P4.H = HI(DCPLB_STATUS);
+       P3.L = LO(DCPLB_DATA0);
+       P3.H = HI(DCPLB_DATA0);
        R5 = [P4];
 
        /* A protection violation can be caused by more than just writes
@@ -355,11 +384,11 @@ ENTRY(_cplb_mgr)
         * config table, that covers the faulting address.
         */
 
-       P1.L = (DCPLB_DATA15 & 0xFFFF);
-       P1.H = (DCPLB_DATA15 >> 16);
+       P1.L = LO(DCPLB_DATA15);
+       P1.H = HI(DCPLB_DATA15);
 
-       P4.L = (DCPLB_FAULT_ADDR & 0xFFFF);
-       P4.H = (DCPLB_FAULT_ADDR >> 16);
+       P4.L = LO(DCPLB_FAULT_ADDR);
+       P4.H = HI(DCPLB_FAULT_ADDR);
        R4 = [P4];
        I0 = R4;
 
@@ -368,8 +397,8 @@ ENTRY(_cplb_mgr)
        R6 = R1;        /* Save for later*/
 
        /* Turn off CPLBs while we work.*/
-       P4.L = (DMEM_CONTROL & 0xFFFF);
-       P4.H = (DMEM_CONTROL >> 16);
+       P4.L = LO(DMEM_CONTROL);
+       P4.H = HI(DMEM_CONTROL);
        R5 = [P4];
        BITCLR(R5,ENDCPLB_P);
        CLI R0;
@@ -384,8 +413,8 @@ ENTRY(_cplb_mgr)
         * are no good.
         */
 
-       I1.L = (DCPLB_DATA0 & 0xFFFF);
-       I1.H = (DCPLB_DATA0 >> 16);
+       I1.L = LO(DCPLB_DATA0);
+       I1.H = HI(DCPLB_DATA0);
        P1 = 2;
        P2 = 16;
        I2.L = _dcplb_preference;
@@ -405,7 +434,7 @@ ENTRY(_cplb_mgr)
        P3.L = _page_size_table; /* retrieve end address */
        P3.H = _page_size_table; /* retrieve end address */
        R3 = 0x1002;            /* 16th - position, 2 bits -length */
-#ifdef ANOMALY_05000209
+#if ANOMALY_05000209
        nop;                    /* Anomaly 05000209 */
 #endif
        R7 = EXTRACT(R1,R3.l);
@@ -475,8 +504,8 @@ ENTRY(_cplb_mgr)
         * one space closer to the start.
         */
 
-       R1.L = (DCPLB_DATA16 & 0xFFFF);         /* DCPLB_DATA15 + 4 */
-       R1.H = (DCPLB_DATA16 >> 16);
+       R1.L = LO(DCPLB_DATA16);                /* DCPLB_DATA15 + 4 */
+       R1.H = HI(DCPLB_DATA16);
        R0 = P0;
 
        /* If the victim happens to be in DCPLB15,
@@ -493,14 +522,23 @@ ENTRY(_cplb_mgr)
        R0 = [P0++];    /* move data */
        [P0 - 8] = R0;
        R0 = [P0-0x104] /* move address */
-.Lde_move: [P0-0x108] = R0;
+.Lde_move:
+        [P0-0x108] = R0;
+
+.Lde_moved:
+       NOP;
+
+       /* Clear DCPLB_DATA15, in case we don't find a replacement
+        * otherwise, we would have a duplicate entry, and will crash
+        */
+       R0 = 0;
+       [P0 - 0x4] = R0;
 
        /* We've now made space in DCPLB15 for the new CPLB to be
         * installed. The next stage is to locate a CPLB in the
         * config table that covers the faulting address.
         */
 
-.Lde_moved:NOP;
        R0 = I0;                /* Our faulting address */
 
        P2.L = _dpdt_table;
@@ -549,8 +587,8 @@ ENTRY(_cplb_mgr)
         * if necessary.
         */
 
-       P1.L = (DCPLB_DATA15 & 0xFFFF);
-       P1.H = (DCPLB_DATA15 >> 16);
+       P1.L = LO(DCPLB_DATA15);
+       P1.H = HI(DCPLB_DATA15);
 
        /* If the DCPLB has cache bits set, but caching hasn't
         * been enabled, then we want to mask off the cache-in-L1
@@ -565,7 +603,7 @@ ENTRY(_cplb_mgr)
         * cost of first-write exceptions to mark the page as dirty.
         */
 
-#ifdef CONFIG_BLKFIN_WT
+#ifdef CONFIG_BFIN_WT
        BITSET(R6, 14);         /* Set WT*/
 #endif