⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 r4xx0.c

📁 移植到2410开发板上的源代码
💻 C
📖 第 1 页 / 共 4 页
字号:
		goto out;	/* Doing flushes for another ASID than the current one is	 * too difficult since stupid R4k caches do a TLB translation	 * for every cache flush operation.  So we do indexed flushes	 * in that case, which doesn't overly flush the cache too much.	 */	if (CPU_CONTEXT(smp_processor_id(), mm) !=	    CPU_CONTEXT(smp_processor_id(), current->mm)) {		/* Do indexed flush, too much work to get the (possible)		 * tlb refills to work correctly.		 */		page = (KSEG0 + (page & (scache_size - 1)));		blast_dcache16_page_indexed(page);		blast_scache16_page_indexed(page);	} else		blast_scache16_page(page);out:	__restore_flags(flags);}static void r4k_flush_cache_page_s32d16i16(struct vm_area_struct *vma,					   unsigned long page){	struct mm_struct *mm = vma->vm_mm;	unsigned long flags;	pgd_t *pgdp;	pmd_t *pmdp;	pte_t *ptep;	/*	 * If ownes no valid ASID yet, cannot possibly have gotten	 * this page into the cache.	 */	if (CPU_CONTEXT(smp_processor_id(), mm) == 0)		return;#ifdef DEBUG_CACHE	printk("cpage[%d,%08lx]", (int)mm->context, page);#endif	__save_and_cli(flags);	page &= PAGE_MASK;	pgdp = pgd_offset(mm, page);	pmdp = pmd_offset(pgdp, page);	ptep = pte_offset(pmdp, page);	/* If the page isn't marked valid, the page cannot possibly be	 * in the cache.	 */	if(!(pte_val(*ptep) & _PAGE_VALID))		goto out;	/* Doing flushes for another ASID than the current one is	 * too difficult since stupid R4k caches do a TLB translation	 * for every cache flush operation.  So we do indexed flushes	 * in that case, which doesn't overly flush the cache too much.	 */	if (CPU_CONTEXT(smp_processor_id(), mm) !=	    CPU_CONTEXT(smp_processor_id(), current->mm)) {		/* Do indexed flush, too much work to get the (possible)		 * tlb refills to work correctly.		 */		page = (KSEG0 + (page & (scache_size - 1)));		blast_dcache16_page_indexed(page);		blast_scache32_page_indexed(page);	} else		blast_scache32_page(page);out:	__restore_flags(flags);}static void r4k_flush_cache_page_s64d16i16(struct vm_area_struct *vma,					   unsigned long page){	struct mm_struct *mm = vma->vm_mm;	unsigned long flags;	pgd_t *pgdp;	pmd_t *pmdp;	pte_t *ptep;	/*	 * If ownes no valid ASID yet, cannot possibly have gotten	 * this page into the cache.	 */	if (CPU_CONTEXT(smp_processor_id(), mm) == 0)		return;#ifdef DEBUG_CACHE	printk("cpage[%d,%08lx]", (int)mm->context, page);#endif	__save_and_cli(flags);	page &= PAGE_MASK;	pgdp = pgd_offset(mm, page);	pmdp = pmd_offset(pgdp, page);	ptep = pte_offset(pmdp, page);	/* If the page isn't marked valid, the page cannot possibly be	 * in the cache.	 */	if(!(pte_val(*ptep) & _PAGE_VALID))		goto out;	/*	 * Doing flushes for another ASID than the current one is	 * too difficult since stupid R4k caches do a TLB translation	 * for every cache flush operation.  So we do indexed flushes	 * in that case, which doesn't overly flush the cache too much.	 */	if (CPU_CONTEXT(smp_processor_id(), mm) != 	    CPU_CONTEXT(smp_processor_id(), current->mm)) {		/* Do indexed flush, too much work to get the (possible)		 * tlb refills to work correctly.		 */		page = (KSEG0 + (page & (scache_size - 1)));		blast_dcache16_page_indexed(page);		blast_scache64_page_indexed(page);	} else		blast_scache64_page(page);out:	__restore_flags(flags);}static void r4k_flush_cache_page_s128d16i16(struct vm_area_struct *vma,					    unsigned long page){	struct mm_struct *mm = vma->vm_mm;	unsigned long flags;	pgd_t *pgdp;	pmd_t *pmdp;	pte_t *ptep;	/*	 * If ownes no valid ASID yet, cannot possibly have gotten	 * this page into the cache.	 */	if (CPU_CONTEXT(smp_processor_id(), mm) == 0)		return;#ifdef DEBUG_CACHE	printk("cpage[%d,%08lx]", (int)mm->context, page);#endif	__save_and_cli(flags);	page &= PAGE_MASK;	pgdp = pgd_offset(mm, page);	pmdp = pmd_offset(pgdp, page);	ptep = pte_offset(pmdp, page);	/*	 * If the page isn't marked valid, the page cannot possibly be	 * in the cache.	 */	if(!(pte_val(*ptep) & _PAGE_VALID))		goto out;	/* Doing flushes for another ASID than the current one is	 * too difficult since stupid R4k caches do a TLB translation	 * for every cache flush operation.  So we do indexed flushes	 * in that case, which doesn't overly flush the cache too much.	 */	if (CPU_CONTEXT(smp_processor_id(), mm) != 	    CPU_CONTEXT(smp_processor_id(), current->mm)) {		/*		 * Do indexed flush, too much work to get the (possible)		 * tlb refills to work correctly.		 */		page = (KSEG0 + (page & (scache_size - 1)));		blast_dcache16_page_indexed(page);		blast_scache128_page_indexed(page);	} else		blast_scache128_page(page);out:	__restore_flags(flags);}static void r4k_flush_cache_page_s32d32i32(struct vm_area_struct *vma,					   unsigned long page){	struct mm_struct *mm = vma->vm_mm;	unsigned long flags;	pgd_t *pgdp;	pmd_t *pmdp;	pte_t *ptep;	/*	 * If ownes no valid ASID yet, cannot possibly have gotten	 * this page into the cache.	 */	if (CPU_CONTEXT(smp_processor_id(), mm) == 0)		return;#ifdef DEBUG_CACHE	printk("cpage[%d,%08lx]", (int)mm->context, page);#endif	__save_and_cli(flags);	page &= PAGE_MASK;	pgdp = pgd_offset(mm, page);	pmdp = pmd_offset(pgdp, page);	ptep = pte_offset(pmdp, page);	/*	 * If the page isn't marked valid, the page cannot possibly be	 * in the cache.	 */	if(!(pte_val(*ptep) & _PAGE_VALID))		goto out;	/*	 * Doing flushes for another ASID than the current one is	 * too difficult since stupid R4k caches do a TLB translation	 * for every cache flush operation.  So we do indexed flushes	 * in that case, which doesn't overly flush the cache too much.	 */	if (CPU_CONTEXT(smp_processor_id(), mm) != 	    CPU_CONTEXT(smp_processor_id(), current->mm)) {		/*		 * Do indexed flush, too much work to get the (possible)		 * tlb refills to work correctly.		 */		page = (KSEG0 + (page & (scache_size - 1)));		blast_dcache32_page_indexed(page);		blast_scache32_page_indexed(page);	} else		blast_scache32_page(page);out:	__restore_flags(flags);}static void r4k_flush_cache_page_s64d32i32(struct vm_area_struct *vma,					   unsigned long page){	struct mm_struct *mm = vma->vm_mm;	unsigned long flags;	pgd_t *pgdp;	pmd_t *pmdp;	pte_t *ptep;	/*	 * If ownes no valid ASID yet, cannot possibly have gotten	 * this page into the cache.	 */	if (CPU_CONTEXT(smp_processor_id(), mm) == 0)		return;#ifdef DEBUG_CACHE	printk("cpage[%d,%08lx]", (int)mm->context, page);#endif	__save_and_cli(flags);	page &= PAGE_MASK;	pgdp = pgd_offset(mm, page);	pmdp = pmd_offset(pgdp, page);	ptep = pte_offset(pmdp, page);	/*	 * If the page isn't marked valid, the page cannot possibly be	 * in the cache.	 */	if(!(pte_val(*ptep) & _PAGE_VALID))		goto out;	/*	 * Doing flushes for another ASID than the current one is	 * too difficult since stupid R4k caches do a TLB translation	 * for every cache flush operation.  So we do indexed flushes	 * in that case, which doesn't overly flush the cache too much.	 */	if (CPU_CONTEXT(smp_processor_id(), mm) != 	    CPU_CONTEXT(smp_processor_id(), current->mm)) {		/*		 * Do indexed flush, too much work to get the (possible)		 * tlb refills to work correctly.		 */		page = (KSEG0 + (page & (scache_size - 1)));		blast_dcache32_page_indexed(page);		blast_scache64_page_indexed(page);	} else		blast_scache64_page(page);out:	__restore_flags(flags);}static void r4k_flush_cache_page_s128d32i32(struct vm_area_struct *vma,					    unsigned long page){	struct mm_struct *mm = vma->vm_mm;	unsigned long flags;	pgd_t *pgdp;	pmd_t *pmdp;	pte_t *ptep;	/*	 * If ownes no valid ASID yet, cannot possibly have gotten	 * this page into the cache.	 */	if (CPU_CONTEXT(smp_processor_id(), mm) == 0)		return;#ifdef DEBUG_CACHE	printk("cpage[%d,%08lx]", (int)mm->context, page);#endif	__save_and_cli(flags);	page &= PAGE_MASK;	pgdp = pgd_offset(mm, page);	pmdp = pmd_offset(pgdp, page);	ptep = pte_offset(pmdp, page);	/* If the page isn't marked valid, the page cannot possibly be	 * in the cache.	 */	if(!(pte_val(*ptep) & _PAGE_VALID))		goto out;	/*	 * Doing flushes for another ASID than the current one is	 * too difficult since stupid R4k caches do a TLB translation	 * for every cache flush operation.  So we do indexed flushes	 * in that case, which doesn't overly flush the cache too much.	 */	if (CPU_CONTEXT(smp_processor_id(), mm) != 	    CPU_CONTEXT(smp_processor_id(), current->mm)) {		/* Do indexed flush, too much work to get the (possible)		 * tlb refills to work correctly.		 */		page = (KSEG0 + (page & (scache_size - 1)));		blast_dcache32_page_indexed(page);		blast_scache128_page_indexed(page);	} else		blast_scache128_page(page);out:	__restore_flags(flags);}static void r4k_flush_cache_page_d16i16(struct vm_area_struct *vma,					unsigned long page){	struct mm_struct *mm = vma->vm_mm;	unsigned long flags;	pgd_t *pgdp;	pmd_t *pmdp;	pte_t *ptep;	/*	 * If ownes no valid ASID yet, cannot possibly have gotten	 * this page into the cache.	 */	if (CPU_CONTEXT(smp_processor_id(), mm) == 0)		return;#ifdef DEBUG_CACHE	printk("cpage[%d,%08lx]", (int)mm->context, page);#endif	__save_and_cli(flags);	page &= PAGE_MASK;	pgdp = pgd_offset(mm, page);	pmdp = pmd_offset(pgdp, page);	ptep = pte_offset(pmdp, page);	/* If the page isn't marked valid, the page cannot possibly be	 * in the cache.	 */	if(!(pte_val(*ptep) & _PAGE_VALID))		goto out;	/*	 * Doing flushes for another ASID than the current one is	 * too difficult since stupid R4k caches do a TLB translation	 * for every cache flush operation.  So we do indexed flushes	 * in that case, which doesn't overly flush the cache too much.	 */	if(mm == current->mm) {		blast_dcache16_page(page);	} else {		/* Do indexed flush, too much work to get the (possible)		 * tlb refills to work correctly.		 */		page = (KSEG0 + (page & (dcache_size - 1)));		blast_dcache16_page_indexed(page);	}out:	__restore_flags(flags);}static void r4k_flush_cache_page_d32i32(struct vm_area_struct *vma,					unsigned long page){	struct mm_struct *mm = vma->vm_mm;	unsigned long flags;	pgd_t *pgdp;	pmd_t *pmdp;	pte_t *ptep;	/*	 * If ownes no valid ASID yet, cannot possibly have gotten	 * this page into the cache.	 */	if (CPU_CONTEXT(smp_processor_id(), mm) == 0)		return;#ifdef DEBUG_CACHE	printk("cpage[%d,%08lx]", (int)mm->context, page);#endif	__save_and_cli(flags);	page &= PAGE_MASK;	pgdp = pgd_offset(mm, page);	pmdp = pmd_offset(pgdp, page);	ptep = pte_offset(pmdp, page);	/*	 * If the page isn't marked valid, the page cannot possibly be	 * in the cache.	 */	if(!(pte_val(*ptep) & _PAGE_PRESENT))		goto out;	/*	 * Doing flushes for another ASID than the current one is	 * too difficult since stupid R4k caches do a TLB translation	 * for every cache flush operation.  So we do indexed flushes	 * in that case, which doesn't overly flush the cache too much.	 */	if((mm == current->mm) && (pte_val(*ptep) & _PAGE_VALID)) {		blast_dcache32_page(page);	} else {		/*		 * Do indexed flush, too much work to get the (possible)		 * tlb refills to work correctly.		 */		page = (KSEG0 + (page & (dcache_size - 1)));		blast_dcache32_page_indexed(page);	}out:	__restore_flags(flags);}static void r4k_flush_cache_page_d32i32_r4600(struct vm_area_struct *vma,					      unsigned long page){	struct mm_struct *mm = vma->vm_mm;	unsigned long flags;	pgd_t *pgdp;	pmd_t *pmdp;	pte_t *ptep;	/*	 * If ownes no valid ASID yet, cannot possibly have gotten	 * this page into the cache.	 */	if (CPU_CONTEXT(smp_processor_id(), mm) == 0)		return;#ifdef DEBUG_CACHE	printk("cpage[%d,%08lx]", (int)mm->context, page);#endif	__save_and_cli(flags);	page &= PAGE_MASK;	pgdp = pgd_offset(mm, page);	pmdp = pmd_offset(pgdp, page);	ptep = pte_offset(pmdp, page);	/*	 * If the page isn't marked valid, the page cannot possibly be	 * in the cache.	 */	if(!(pte_val(*ptep) & _PAGE_PRESENT))		goto out;	/*	 * Doing flushes for another ASID than the current one is	 * too difficult since stupid R4k caches do a TLB translation	 * for every cache flush operation.  So we do indexed flushes	 * in that case, which doesn't overly flush the cache too much.	 */	if((mm == current->mm) && (pte_val(*ptep) & _PAGE_VALID)) {		blast_dcache32_page(page);	} else {		/* Do indexed flush, too much work to get the (possible)		 * tlb refills to work correctly.		 */		page = (KSEG0 + (page & (dcache_size - 1)));		blast_dcache32_page_indexed(page);		blast_dcache32_page_indexed(page ^ dcache_waybit);	}out:	__restore_flags(flags);}static void r4k_flush_page_to_ram_s16(struct page *page){	blast_scache16_page((unsigned long)page_address(page));}static void r4k_flush_page_to_ram_s32(struct page *page){	blast_scache32_page((unsigned long)page_address(page));}static void r4k_flush_page_to_ram_s64(struct page *page){	blast_scache64_page((unsigned long)page_address(page));}static void r4k_flush_page_to_ram_s128(struct page *page){	blast_scache128_page((unsigned long)page_address(page));}static void r4k_flush_page_to_ram_d16(struct page *page){	unsigned long flags;	__save_and_cli(flags);	blast_dcache16_page((unsigned long)page_address(page));	__restore_flags(flags);}static void r4k_flush_page_to_ram_d32(struct page *page){	unsigned long flags;	__save_and_cli(flags);	blast_dcache32_page((unsigned long)page_address(page));	__restore_flags(flags);}/* * Writeback and invalidate the primary cache dcache before DMA. * * R4600 v2.0 bug: "The CACHE instructions Hit_Writeback_Inv_D, * Hit_Writeback_D, Hit_Invalidate_D and Create_Dirty_Exclusive_D will only * operate correctly if the internal data cache refill buffer is empty.  These * CACHE instructions should be separated from any potential data cache miss * by a load instruction to an uncached address to empty the response buffer." * (Revision 2.0 device errata from IDT available on http://www.idt.com/ * in .pdf format.) */static void r4k_dma_cache_wback_inv_pc(unsigned long addr, unsigned long size){	unsigned long end, a;	unsigned int flags;	if (size >= (unsigned long)dcache_size) {		flush_cache_l1();	} else {		/* Workaround for R4600 bug.  See comment above. */		__save_and_cli(flags);		*(volatile unsigned long *)KSEG1;		a = addr & ~((unsigned long)dc_lsize - 1);		end = (addr + size) & ~((unsigned long)dc_lsize - 1);		while (1) {			flush_dcache_line(a); /* Hit_Writeback_Inv_D */			if (a == end) break;			a += dc_lsize;		}		__restore_flags(flags);	}	bc_wback_inv(addr, size);}static void r4k_dma_cache_wback_inv_sc(unsigned long addr, unsigned long size){	unsigned long end, a;	if (size >= (unsigned long)scache_size) {		flush_cache_l1();		return;	}	a = addr & ~((unsigned long)sc_lsize - 1);	end = (addr + size) & ~((unsigned long)sc_lsize - 1);	while (1) {		flush_scache_line(a);	/* Hit_Writeback_Inv_SD */		if (a == end) break;		a += sc_lsize;	}}static void r4k_dma_cache_inv_pc(unsigned long addr, unsigned long size){	unsigned long end, a;	unsigned int flags;	if (size >= (unsigned long)dcache_size) {		flush_cache_l1();	} else {		/* Workaround for R4600 bug.  See comment above. */		__save_and_cli(flags);		*(volatile unsigned long *)KSEG1;		a = addr & ~((unsigned long)dc_lsize - 1);		end = (addr + size) & ~((unsigned long)dc_lsize - 1);		while (1) {			flush_dcache_line(a); /* Hit_Writeback_Inv_D */			if (a == end) break;			a += dc_lsize;		}		__restore_flags(flags);	}	bc_inv(addr, size);}static void r4k_dma_cache_inv_sc(unsigned long addr, unsigned long size){	unsigned long end, a;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -