-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Jonas Bonn <jonas@southpole.se> Reviewed-by: Arnd Bergmann <arnd@arndb.de>
- Loading branch information
Jonas Bonn
committed
Jul 22, 2011
1 parent
4f246ba
commit 61e85e3
Showing
15 changed files
with
2,279 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* OpenRISC Linux | ||
* | ||
* Linux architectural port borrowing liberally from similar works of | ||
* others. All original copyrights apply as per the original source | ||
* declaration. | ||
* | ||
* OpenRISC implementation: | ||
* Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com> | ||
* Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se> | ||
* et al. | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
*/ | ||
|
||
#ifndef __ASM_OPENRISC_CACHE_H | ||
#define __ASM_OPENRISC_CACHE_H | ||
|
||
/* FIXME: How can we replace these with values from the CPU... | ||
* they shouldn't be hard-coded! | ||
*/ | ||
|
||
#define L1_CACHE_BYTES 16 | ||
#define L1_CACHE_SHIFT 4 | ||
|
||
#endif /* __ASM_OPENRISC_CACHE_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* | ||
* OpenRISC Linux | ||
* | ||
* Linux architectural port borrowing liberally from similar works of | ||
* others. All original copyrights apply as per the original source | ||
* declaration. | ||
* | ||
* OpenRISC implementation: | ||
* Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com> | ||
* Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se> | ||
* et al. | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
*/ | ||
|
||
#ifndef __ASM_OPENRISC_FIXMAP_H | ||
#define __ASM_OPENRISC_FIXMAP_H | ||
|
||
/* Why exactly do we need 2 empty pages between the top of the fixed | ||
* addresses and the top of virtual memory? Something is using that | ||
* memory space but not sure what right now... If you find it, leave | ||
* a comment here. | ||
*/ | ||
#define FIXADDR_TOP ((unsigned long) (-2*PAGE_SIZE)) | ||
|
||
#include <linux/kernel.h> | ||
#include <asm/page.h> | ||
|
||
/* | ||
* On OpenRISC we use these special fixed_addresses for doing ioremap | ||
* early in the boot process before memory initialization is complete. | ||
* This is used, in particular, by the early serial console code. | ||
* | ||
* It's not really 'fixmap', per se, but fits loosely into the same | ||
* paradigm. | ||
*/ | ||
enum fixed_addresses { | ||
/* | ||
* FIX_IOREMAP entries are useful for mapping physical address | ||
* space before ioremap() is useable, e.g. really early in boot | ||
* before kmalloc() is working. | ||
*/ | ||
#define FIX_N_IOREMAPS 32 | ||
FIX_IOREMAP_BEGIN, | ||
FIX_IOREMAP_END = FIX_IOREMAP_BEGIN + FIX_N_IOREMAPS - 1, | ||
__end_of_fixed_addresses | ||
}; | ||
|
||
#define FIXADDR_SIZE (__end_of_fixed_addresses << PAGE_SHIFT) | ||
/* FIXADDR_BOTTOM might be a better name here... */ | ||
#define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE) | ||
|
||
#define __fix_to_virt(x) (FIXADDR_TOP - ((x) << PAGE_SHIFT)) | ||
#define __virt_to_fix(x) ((FIXADDR_TOP - ((x)&PAGE_MASK)) >> PAGE_SHIFT) | ||
|
||
/* | ||
* 'index to address' translation. If anyone tries to use the idx | ||
* directly without tranlation, we catch the bug with a NULL-deference | ||
* kernel oops. Illegal ranges of incoming indices are caught too. | ||
*/ | ||
static __always_inline unsigned long fix_to_virt(const unsigned int idx) | ||
{ | ||
/* | ||
* this branch gets completely eliminated after inlining, | ||
* except when someone tries to use fixaddr indices in an | ||
* illegal way. (such as mixing up address types or using | ||
* out-of-range indices). | ||
* | ||
* If it doesn't get removed, the linker will complain | ||
* loudly with a reasonably clear error message.. | ||
*/ | ||
if (idx >= __end_of_fixed_addresses) | ||
BUG(); | ||
|
||
return __fix_to_virt(idx); | ||
} | ||
|
||
static inline unsigned long virt_to_fix(const unsigned long vaddr) | ||
{ | ||
BUG_ON(vaddr >= FIXADDR_TOP || vaddr < FIXADDR_START); | ||
return __virt_to_fix(vaddr); | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* OpenRISC Linux | ||
* | ||
* Linux architectural port borrowing liberally from similar works of | ||
* others. All original copyrights apply as per the original source | ||
* declaration. | ||
* | ||
* OpenRISC implementation: | ||
* Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com> | ||
* Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se> | ||
* et al. | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
*/ | ||
|
||
#ifndef __ASM_OPENRISC_MEMBLOCK_H | ||
#define __ASM_OPENRISC_MEMBLOCK_H | ||
|
||
/* empty */ | ||
|
||
#endif /* __ASM_OPENRISC_MEMBLOCK_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* OpenRISC Linux | ||
* | ||
* Linux architectural port borrowing liberally from similar works of | ||
* others. All original copyrights apply as per the original source | ||
* declaration. | ||
* | ||
* OpenRISC implementation: | ||
* Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com> | ||
* Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se> | ||
* et al. | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
*/ | ||
|
||
#ifndef __ASM_OPENRISC_MMU_H | ||
#define __ASM_OPENRISC_MMU_H | ||
|
||
#ifndef __ASSEMBLY__ | ||
typedef unsigned long mm_context_t; | ||
#endif | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* OpenRISC Linux | ||
* | ||
* Linux architectural port borrowing liberally from similar works of | ||
* others. All original copyrights apply as per the original source | ||
* declaration. | ||
* | ||
* OpenRISC implementation: | ||
* Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com> | ||
* Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se> | ||
* et al. | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
*/ | ||
|
||
#ifndef __ASM_OPENRISC_MMU_CONTEXT_H | ||
#define __ASM_OPENRISC_MMU_CONTEXT_H | ||
|
||
#include <asm-generic/mm_hooks.h> | ||
|
||
extern int init_new_context(struct task_struct *tsk, struct mm_struct *mm); | ||
extern void destroy_context(struct mm_struct *mm); | ||
extern void switch_mm(struct mm_struct *prev, struct mm_struct *next, | ||
struct task_struct *tsk); | ||
|
||
#define deactivate_mm(tsk, mm) do { } while (0) | ||
|
||
#define activate_mm(prev, next) switch_mm((prev), (next), NULL) | ||
|
||
/* current active pgd - this is similar to other processors pgd | ||
* registers like cr3 on the i386 | ||
*/ | ||
|
||
extern volatile pgd_t *current_pgd; /* defined in arch/openrisc/mm/fault.c */ | ||
|
||
static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk) | ||
{ | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
/* | ||
* OpenRISC Linux | ||
* | ||
* Linux architectural port borrowing liberally from similar works of | ||
* others. All original copyrights apply as per the original source | ||
* declaration. | ||
* | ||
* OpenRISC implementation: | ||
* Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com> | ||
* Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se> | ||
* et al. | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
*/ | ||
|
||
#ifndef __ASM_OPENRISC_PAGE_H | ||
#define __ASM_OPENRISC_PAGE_H | ||
|
||
|
||
/* PAGE_SHIFT determines the page size */ | ||
|
||
#define PAGE_SHIFT 13 | ||
#ifdef __ASSEMBLY__ | ||
#define PAGE_SIZE (1 << PAGE_SHIFT) | ||
#else | ||
#define PAGE_SIZE (1UL << PAGE_SHIFT) | ||
#endif | ||
#define PAGE_MASK (~(PAGE_SIZE-1)) | ||
|
||
#define PAGE_OFFSET 0xc0000000 | ||
#define KERNELBASE PAGE_OFFSET | ||
|
||
/* This is not necessarily the right place for this, but it's needed by | ||
* drivers/of/fdt.c | ||
*/ | ||
#include <asm/setup.h> | ||
|
||
#ifndef __ASSEMBLY__ | ||
|
||
#define get_user_page(vaddr) __get_free_page(GFP_KERNEL) | ||
#define free_user_page(page, addr) free_page(addr) | ||
|
||
#define clear_page(page) memset((page), 0, PAGE_SIZE) | ||
#define copy_page(to, from) memcpy((to), (from), PAGE_SIZE) | ||
|
||
#define clear_user_page(page, vaddr, pg) clear_page(page) | ||
#define copy_user_page(to, from, vaddr, pg) copy_page(to, from) | ||
|
||
/* | ||
* These are used to make use of C type-checking.. | ||
*/ | ||
typedef struct { | ||
unsigned long pte; | ||
} pte_t; | ||
typedef struct { | ||
unsigned long pgd; | ||
} pgd_t; | ||
typedef struct { | ||
unsigned long pgprot; | ||
} pgprot_t; | ||
typedef struct page *pgtable_t; | ||
|
||
#define pte_val(x) ((x).pte) | ||
#define pgd_val(x) ((x).pgd) | ||
#define pgprot_val(x) ((x).pgprot) | ||
|
||
#define __pte(x) ((pte_t) { (x) }) | ||
#define __pgd(x) ((pgd_t) { (x) }) | ||
#define __pgprot(x) ((pgprot_t) { (x) }) | ||
|
||
extern unsigned long memory_start; | ||
extern unsigned long memory_end; | ||
|
||
#endif /* !__ASSEMBLY__ */ | ||
|
||
|
||
#ifndef __ASSEMBLY__ | ||
|
||
#define __va(x) ((void *)((unsigned long)(x) + PAGE_OFFSET)) | ||
#define __pa(x) ((unsigned long) (x) - PAGE_OFFSET) | ||
|
||
#define virt_to_pfn(kaddr) (__pa(kaddr) >> PAGE_SHIFT) | ||
#define pfn_to_virt(pfn) __va((pfn) << PAGE_SHIFT) | ||
|
||
#define virt_to_page(addr) \ | ||
(mem_map + (((unsigned long)(addr)-PAGE_OFFSET) >> PAGE_SHIFT)) | ||
#define page_to_virt(page) \ | ||
((((page) - mem_map) << PAGE_SHIFT) + PAGE_OFFSET) | ||
|
||
#define page_to_phys(page) ((dma_addr_t)page_to_pfn(page) << PAGE_SHIFT) | ||
|
||
#define pfn_valid(pfn) ((pfn) < max_mapnr) | ||
|
||
#define virt_addr_valid(kaddr) (((void *)(kaddr) >= (void *)PAGE_OFFSET) && \ | ||
((void *)(kaddr) < (void *)memory_end)) | ||
|
||
#endif /* __ASSEMBLY__ */ | ||
|
||
|
||
#define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \ | ||
VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) | ||
|
||
|
||
#include <asm-generic/memory_model.h> | ||
#include <asm-generic/getorder.h> | ||
|
||
#endif /* __ASM_OPENRISC_PAGE_H */ |
Oops, something went wrong.