···2121#ifndef __S3C2440_H__
2222#define __S3C2440_H__
23232424+#define CACHEALIGN_BITS (5)
2525+2426#define LCD_BUFFER_SIZE (320*240*2)
2527#define TTB_SIZE (0x4000)
2628/* must be 16Kb (0x4000) aligned */
+26-12
firmware/target/arm/mmu-arm.S
···2222#include "cpu.h"
23232424/* Used by ARMv4 & ARMv5 CPUs with cp15 register and MMU */
2525-/* WARNING : assume size of a data cache line == 32 bytes */
26252726#if CONFIG_CPU == TCC7801 || CONFIG_CPU == AT91SAM9260
2827/* MMU present but unused */
···4039#define USE_MMU
4140#define CACHE_SIZE 16
42414242+#elif CONFIG_CPU == S5L8701
4343+/* MMU not present */
4444+#define CACHE_SIZE 4
4545+4346#else
4447#error Cache settings unknown for this CPU !
45484649#endif /* CPU specific configuration */
47504851@ Index format: 31:26 = index, N:5 = segment, remainder = SBZ
4949-@ assume 64-way set associative separate I/D caches, 32B (2^5) cache line size
5252+@ assume 64-way set associative separate I/D caches
5053@ CACHE_SIZE = N (kB) = N*2^10 B
5151-@ number of lines = N*2^(10-5) = N*2^(5)
5454+@ number of lines = N*2^(10-CACHEALIGN_BITS)
5255@ Index bits = 6
5353-@ Segment loops = N*2^(5-6) = N*2^(-1) = N/2
5656+@ Segment loops = N*2^(10-CACHEALIGN_BITS-6) = N*2^(4-CACHEALIGN_BITS)
5757+@ Segment loops = N/2^(CACHEALIGN_BITS - 4)
5858+@ Segment loops = N/(1<<(CACHEALIGN_BITS - 4))
54596060+#ifdef CACHE_SIZE
6161+6262+#if CACHEALIGN_BITS == 4
6363+#define INDEX_STEPS CACHE_SIZE
6464+#elif CACHEALIGN_BITS == 5
5565#define INDEX_STEPS (CACHE_SIZE/2)
6666+#endif /* CACHEALIGN_BITS */
6767+6868+@ assume 64-way set associative separate I/D caches (log2(64) == 6)
6969+@ Index format: 31:26 = index, M:N = segment, remainder = SBZ
7070+@ Segment bits = log2(cache size in bytes / cache line size in byte) - Index bits (== 6)
7171+@ N = CACHEALIGN_BITS
7272+7373+#endif /* CACHE_SIZE */
567457755876#ifdef USE_MMU
···318336 bne clean_dcache
319337 mov r1, #0
320338#else
321321- @ Index format: 31:26 = index, N:5 = segment, remainder = SBZ, assume 64-way set associative separate I/D caches
322322- @ N = log2(cache size in bytes / cache line size in bytes == 32) - 6 /* index bits */ + 4 /* start offset */
323339 mov r1, #0x00000000 @
3243401: @ clean_start @
325341 mcr p15, 0, r1, c7, c10, 2 @ Clean entry by index
326326- add r0, r1, #0x00000020 @
342342+ add r0, r1, #(1<<CACHEALIGN_BITS)
327343 mcr p15, 0, r0, c7, c10, 2 @ Clean entry by index
328344.rept INDEX_STEPS - 2 /* 2 steps already executed */
329329- add r0, r0, #0x00000020 @
345345+ add r0, r0, #(1<<CACHEALIGN_BITS)
330346 mcr p15, 0, r0, c7, c10, 2 @ Clean entry by index
331347.endr
332348 adds r1, r1, #0x04000000 @ will wrap to zero at loop end
···351367 bne invalidate_dcache
352368 mov r1, #0
353369#else
354354- @ Index format: 31:26 = index, N:5 = segment, remainder = SBZ, assume 64-way set associative separate I/D caches
355355- @ N = log2(cache size in bytes / cache line size in bytes == 32) - 6 /* index bits */ + 4 /* start offset */
356370 mov r1, #0x00000000 @
3573711: @ inv_start @
358372 mcr p15, 0, r1, c7, c14, 2 @ Clean and invalidate entry by index
359359- add r0, r1, #0x00000020 @
373373+ add r0, r1, #(1<<CACHEALIGN_BITS)
360374 mcr p15, 0, r0, c7, c14, 2 @ Clean and invalidate entry by index
361375.rept INDEX_STEPS - 2 /* 2 steps already executed */
362362- add r0, r0, #0x00000020 @
376376+ add r0, r0, #(1<<CACHEALIGN_BITS)
363377 mcr p15, 0, r0, c7, c14, 2 @ Clean and invalidate entry by index
364378.endr
365379 adds r1, r1, #0x04000000 @ will wrap to zero at loop end
-95
firmware/target/arm/s5l8700/mmu-s5l8700.S
···11-/***************************************************************************
22- * __________ __ ___.
33- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
44- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
55- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
66- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
77- * \/ \/ \/ \/ \/
88- * $Id$
99- *
1010- * Copyright (C) 2006,2007 by Greg White
1111- *
1212- * This program is free software; you can redistribute it and/or
1313- * modify it under the terms of the GNU General Public License
1414- * as published by the Free Software Foundation; either version 2
1515- * of the License, or (at your option) any later version.
1616- *
1717- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
1818- * KIND, either express or implied.
1919- *
2020- ****************************************************************************/
2121-#include "config.h"
2222-#include "cpu.h"
2323-2424-/** Cache coherency **/
2525-2626-/*
2727- * Cleans entire DCache
2828- * void clean_dcache(void);
2929- */
3030- .section .icode, "ax", %progbits
3131- .align 2
3232- .global clean_dcache
3333- .type clean_dcache, %function
3434- .global cpucache_flush @ Alias
3535-clean_dcache:
3636-cpucache_flush:
3737- @ Index format: 31:26 = index, 5:4 = segment, remainder = SBZ
3838- mov r1, #0x00000000 @
3939-1: @ clean_start @
4040- mcr p15, 0, r1, c7, c10, 2 @ Clean entry by index
4141- add r0, r1, #0x00000010 @
4242- mcr p15, 0, r0, c7, c10, 2 @ Clean entry by index
4343- add r0, r0, #0x00000010 @
4444- mcr p15, 0, r0, c7, c10, 2 @ Clean entry by index
4545- add r0, r0, #0x00000010 @
4646- mcr p15, 0, r0, c7, c10, 2 @ Clean entry by index
4747- adds r1, r1, #0x04000000 @ will wrap to zero at loop end
4848- bne 1b @ clean_start @
4949- mcr p15, 0, r1, c7, c10, 4 @ Drain write buffer
5050- bx lr @
5151- .size clean_dcache, .-clean_dcache
5252-5353-/*
5454- * Invalidate entire DCache
5555- * will do writeback
5656- * void invalidate_dcache(void);
5757- */
5858- .section .icode, "ax", %progbits
5959- .align 2
6060- .global invalidate_dcache
6161- .type invalidate_dcache, %function
6262-invalidate_dcache:
6363- @ Index format: 31:26 = index, 5:4 = segment, remainder = SBZ
6464- mov r1, #0x00000000 @
6565-1: @ inv_start @
6666- mcr p15, 0, r1, c7, c14, 2 @ Clean and invalidate entry by index
6767- add r0, r1, #0x00000010 @
6868- mcr p15, 0, r0, c7, c14, 2 @ Clean and invalidate entry by index
6969- add r0, r0, #0x00000010 @
7070- mcr p15, 0, r0, c7, c14, 2 @ Clean and invalidate entry by index
7171- add r0, r0, #0x00000010 @
7272- mcr p15, 0, r0, c7, c14, 2 @ Clean and invalidate entry by index
7373- adds r1, r1, #0x04000000 @ will wrap to zero at loop end
7474- bne 1b @ inv_start @
7575- mcr p15, 0, r1, c7, c10, 4 @ Drain write buffer
7676- bx lr @
7777- .size invalidate_dcache, .-invalidate_dcache
7878-7979-/*
8080- * Invalidate entire ICache and DCache
8181- * will do writeback
8282- * void invalidate_idcache(void);
8383- */
8484- .section .icode, "ax", %progbits
8585- .align 2
8686- .global invalidate_idcache
8787- .type invalidate_idcache, %function
8888- .global cpucache_invalidate @ Alias
8989-invalidate_idcache:
9090-cpucache_invalidate:
9191- mov r2, lr @ save lr to r2, call uses r0 and r1 only
9292- bl invalidate_dcache @ Clean and invalidate entire DCache
9393- mcr p15, 0, r1, c7, c5, 0 @ Invalidate ICache (r1=0 from call)
9494- mov pc, r2 @
9595- .size invalidate_idcache, .-invalidate_idcache
-43
firmware/target/arm/s5l8700/mmu-target.h
···11-/***************************************************************************
22- * __________ __ ___.
33- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
44- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
55- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
66- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
77- * \/ \/ \/ \/ \/
88- * $Id$
99- *
1010- * Copyright (C) 2006,2007 by Greg White
1111- *
1212- * This program is free software; you can redistribute it and/or
1313- * modify it under the terms of the GNU General Public License
1414- * as published by the Free Software Foundation; either version 2
1515- * of the License, or (at your option) any later version.
1616- *
1717- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
1818- * KIND, either express or implied.
1919- *
2020- ****************************************************************************/
2121-2222-/* This file MUST be included in your system-target.h file if you want arm
2323- * cache coherence functions to be called (I.E. during codec load, etc).
2424- */
2525-2626-#ifndef MMU_S5L8700_H
2727-#define MMU_S5L8700_H
2828-2929-/* Cleans entire DCache */
3030-void clean_dcache(void) ICODE_ATTR;
3131-3232-/* Invalidate entire DCache */
3333-/* will do writeback */
3434-void invalidate_dcache(void) ICODE_ATTR;
3535-3636-/* Invalidate entire ICache and DCache */
3737-/* will do writeback */
3838-void invalidate_idcache(void) ICODE_ATTR;
3939-4040-#define HAVE_CPUCACHE_INVALIDATE
4141-#define HAVE_CPUCACHE_FLUSH
4242-4343-#endif /* MMU_S5L8700_H */