1 /* $OpenBSD: cmmu.h,v 1.26 2011/01/05 22:14:28 miod Exp $ */ 2 /* 3 * Mach Operating System 4 * Copyright (c) 1993-1992 Carnegie Mellon University 5 * All Rights Reserved. 6 * 7 * Permission to use, copy, modify and distribute this software and its 8 * documentation is hereby granted, provided that both the copyright 9 * notice and this permission notice appear in all copies of the 10 * software, derivative works or modified versions, and any portions 11 * thereof, and that both notices appear in supporting documentation. 12 * 13 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 14 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR 15 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 16 * 17 * Carnegie Mellon requests users of this software to return to 18 * 19 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 20 * School of Computer Science 21 * Carnegie Mellon University 22 * Pittsburgh PA 15213-3890 23 * 24 * any improvements or extensions that they make and grant Carnegie Mellon 25 * the rights to redistribute these changes. 26 */ 27 28 #ifndef _M88K_CMMU_H_ 29 #define _M88K_CMMU_H_ 30 31 /* 32 * Prototypes and stuff for cmmu.c. 33 */ 34 #if defined(_KERNEL) && !defined(_LOCORE) 35 36 /* machine dependent cmmu function pointer structure */ 37 struct cmmu_p { 38 cpuid_t (*init)(void); 39 void (*setup_board_config)(void); 40 void (*cpu_configuration_print)(int); 41 void (*shutdown)(void); 42 cpuid_t (*cpu_number)(void); 43 void (*set_sapr)(apr_t); 44 void (*set_uapr)(apr_t); 45 void (*tlb_inv)(cpuid_t, u_int, vaddr_t); 46 void (*tlb_inv_all)(cpuid_t); 47 void (*cache_wbinv)(cpuid_t, paddr_t, psize_t); 48 void (*dcache_wb)(cpuid_t, paddr_t, psize_t); 49 void (*icache_inv)(cpuid_t, paddr_t, psize_t); 50 void (*dma_cachectl)(paddr_t, psize_t, int); 51 #ifdef MULTIPROCESSOR 52 void (*dma_cachectl_local)(paddr_t, psize_t, int); 53 void (*initialize_cpu)(cpuid_t); 54 #endif 55 }; 56 57 extern struct cmmu_p *cmmu; 58 59 #ifdef MULTIPROCESSOR 60 /* 61 * On 8820x-based systems, this lock protects the CMMU SAR and SCR registers; 62 * other registers may be accessed without locking it. 63 * On 88410-based systems, this lock protects accesses to the BusSwitch GCSR 64 * register, which masks or unmasks the 88410 control addresses. 65 */ 66 extern __cpu_simple_lock_t cmmu_cpu_lock; 67 #define CMMU_LOCK __cpu_simple_lock(&cmmu_cpu_lock) 68 #define CMMU_UNLOCK __cpu_simple_unlock(&cmmu_cpu_lock) 69 #else 70 #define CMMU_LOCK do { /* nothing */ } while (0) 71 #define CMMU_UNLOCK do { /* nothing */ } while (0) 72 #endif /* MULTIPROCESSOR */ 73 74 #define cmmu_init (cmmu->init) 75 #define setup_board_config (cmmu->setup_board_config) 76 #define cpu_configuration_print(cpu) (cmmu->cpu_configuration_print)(cpu) 77 #define cmmu_shutdown (cmmu->shutdown) 78 #define cmmu_cpu_number (cmmu->cpu_number) 79 #define cmmu_set_sapr(apr) (cmmu->set_sapr)(apr) 80 #define cmmu_set_uapr(apr) (cmmu->set_uapr)(apr) 81 #define cmmu_tlb_inv(cpu, k, va) (cmmu->tlb_inv)(cpu, k, va) 82 #define cmmu_tlb_inv_all(cpu) (cmmu->tlb_inv_all)(cpu) 83 #define cmmu_cache_wbinv(cpu, pa, s) (cmmu->cache_wbinv)(cpu, pa, s) 84 #define cmmu_dcache_wb(cpu, pa, s) (cmmu->dcache_wb)(cpu, pa, s) 85 #define cmmu_icache_inv(cpu,pa,s) (cmmu->icache_inv)(cpu, pa, s) 86 #define dma_cachectl(pa, s, op) (cmmu->dma_cachectl)(pa, s, op) 87 #define dma_cachectl_local(pa, s, op) (cmmu->dma_cachectl_local)(pa, s, op) 88 #define cmmu_initialize_cpu(cpu) (cmmu->initialize_cpu)(cpu) 89 90 /* 91 * dma_cachectl{,_local}() modes 92 */ 93 #define DMA_CACHE_INV 0x00 94 #define DMA_CACHE_SYNC_INVAL 0x01 95 #define DMA_CACHE_SYNC 0x02 96 97 #endif /* _KERNEL && !_LOCORE */ 98 99 #endif /* _M88K_CMMU_H_ */ 100