Skip to content

Commit e5083a6

Browse files
Johannes Weinerczankel
authored andcommitted
xtensa: nommu support
Add support for !CONFIG_MMU setups. Signed-off-by: Johannes Weiner <jw@emlix.com> Signed-off-by: Chris Zankel <chris@zankel.net>
1 parent 7789f89 commit e5083a6

19 files changed

Lines changed: 169 additions & 75 deletions

File tree

‎arch/xtensa/include/asm/cacheflush.h‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,17 @@ extern void __flush_invalidate_dcache_range(unsigned long, unsigned long);
6565
# define __flush_invalidate_dcache_range(p,s) __invalidate_dcache_range(p,s)
6666
#endif
6767

68-
#if (DCACHE_WAY_SIZE > PAGE_SIZE)
68+
#if defined(CONFIG_MMU) && (DCACHE_WAY_SIZE > PAGE_SIZE)
6969
extern void __flush_invalidate_dcache_page_alias(unsigned long, unsigned long);
70+
#else
71+
static inline void __flush_invalidate_dcache_page_alias(unsigned long virt,
72+
unsigned long phys) { }
7073
#endif
71-
#if (ICACHE_WAY_SIZE > PAGE_SIZE)
74+
#if defined(CONFIG_MMU) && (ICACHE_WAY_SIZE > PAGE_SIZE)
7275
extern void __invalidate_icache_page_alias(unsigned long, unsigned long);
7376
#else
74-
# define __invalidate_icache_page_alias(v,p) do { } while(0)
77+
static inline void __invalidate_icache_page_alias(unsigned long virt,
78+
unsigned long phys) { }
7579
#endif
7680

7781
/*

‎arch/xtensa/include/asm/dma.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@
4444
* the value desired).
4545
*/
4646

47+
#ifndef MAX_DMA_ADDRESS
4748
#define MAX_DMA_ADDRESS (PAGE_OFFSET + XCHAL_KIO_SIZE - 1)
48-
49+
#endif
4950

5051
/* Reserve and release a DMA channel */
5152
extern int request_dma(unsigned int dmanr, const char * device_id);

‎arch/xtensa/include/asm/io.h‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,21 +69,28 @@ static inline void * phys_to_virt(unsigned long address)
6969

7070
static inline void *ioremap(unsigned long offset, unsigned long size)
7171
{
72+
#ifdef CONFIG_MMU
7273
if (offset >= XCHAL_KIO_PADDR
7374
&& offset < XCHAL_KIO_PADDR + XCHAL_KIO_SIZE)
7475
return (void*)(offset-XCHAL_KIO_PADDR+XCHAL_KIO_BYPASS_VADDR);
75-
7676
else
7777
BUG();
78+
#else
79+
return (void *)offset;
80+
#endif
7881
}
7982

8083
static inline void *ioremap_nocache(unsigned long offset, unsigned long size)
8184
{
85+
#ifdef CONFIG_MMU
8286
if (offset >= XCHAL_KIO_PADDR
8387
&& offset < XCHAL_KIO_PADDR + XCHAL_KIO_SIZE)
8488
return (void*)(offset-XCHAL_KIO_PADDR+XCHAL_KIO_CACHED_VADDR);
8589
else
8690
BUG();
91+
#else
92+
return (void *)offset;
93+
#endif
8794
}
8895

8996
static inline void iounmap(void *addr)

‎arch/xtensa/include/asm/mmu.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@
1111
#ifndef _XTENSA_MMU_H
1212
#define _XTENSA_MMU_H
1313

14+
#ifndef CONFIG_MMU
15+
#include <asm/nommu.h>
16+
#else
17+
1418
/* Default "unsigned long" context */
1519
typedef unsigned long mm_context_t;
1620

21+
#endif /* CONFIG_MMU */
1722
#endif /* _XTENSA_MMU_H */

‎arch/xtensa/include/asm/mmu_context.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
#ifndef _XTENSA_MMU_CONTEXT_H
1414
#define _XTENSA_MMU_CONTEXT_H
1515

16+
#ifndef CONFIG_MMU
17+
#include <asm/nommu_context.h>
18+
#else
19+
1620
#include <linux/stringify.h>
1721
#include <linux/sched.h>
1822

@@ -133,4 +137,5 @@ static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
133137

134138
}
135139

140+
#endif /* CONFIG_MMU */
136141
#endif /* _XTENSA_MMU_CONTEXT_H */

‎arch/xtensa/include/asm/nommu.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
typedef struct {
2+
unsigned long end_brk;
3+
} mm_context_t;
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
2+
{
3+
}
4+
5+
static inline int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
6+
{
7+
return 0;
8+
}
9+
10+
static inline void destroy_context(struct mm_struct *mm)
11+
{
12+
}
13+
14+
static inline void activate_mm(struct mm_struct *prev, struct mm_struct *next)
15+
{
16+
}
17+
18+
static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
19+
struct task_struct *tsk)
20+
{
21+
}
22+
23+
static inline void deactivate_mm(struct task_struct *tsk, struct mm_struct *mm)
24+
{
25+
}

‎arch/xtensa/include/asm/page.h‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,14 @@
3333
#define PAGE_SIZE (__XTENSA_UL_CONST(1) << PAGE_SHIFT)
3434
#define PAGE_MASK (~(PAGE_SIZE-1))
3535

36+
#ifdef CONFIG_MMU
3637
#define PAGE_OFFSET XCHAL_KSEG_CACHED_VADDR
3738
#define MAX_MEM_PFN XCHAL_KSEG_SIZE
39+
#else
40+
#define PAGE_OFFSET 0
41+
#define MAX_MEM_PFN (PLATFORM_DEFAULT_MEM_START + PLATFORM_DEFAULT_MEM_SIZE)
42+
#endif
43+
3844
#define PGTABLE_START 0x80000000
3945

4046
/*
@@ -165,8 +171,9 @@ extern void copy_user_page(void*, void*, unsigned long, struct page*);
165171
#define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
166172
#define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT)
167173

174+
#ifdef CONFIG_MMU
168175
#define WANT_PAGE_VIRTUAL
169-
176+
#endif
170177

171178
#endif /* __ASSEMBLY__ */
172179

‎arch/xtensa/include/asm/pgtable.h‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,15 @@ extern unsigned long empty_zero_page[1024];
183183

184184
#define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))
185185

186+
#ifdef CONFIG_MMU
186187
extern pgd_t swapper_pg_dir[PAGE_SIZE/sizeof(pgd_t)];
188+
extern void paging_init(void);
189+
extern void pgtable_cache_init(void);
190+
#else
191+
# define swapper_pg_dir NULL
192+
static inline void paging_init(void) { }
193+
static inline void pgtable_cache_init(void) { }
194+
#endif
187195

188196
/*
189197
* The pmd contains the kernel virtual address of the pte page.
@@ -383,8 +391,6 @@ ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
383391

384392
#else
385393

386-
extern void paging_init(void);
387-
388394
#define kern_addr_valid(addr) (1)
389395

390396
extern void update_mmu_cache(struct vm_area_struct * vma,
@@ -398,9 +404,6 @@ extern void update_mmu_cache(struct vm_area_struct * vma,
398404
#define io_remap_pfn_range(vma,from,pfn,size,prot) \
399405
remap_pfn_range(vma, from, pfn, size, prot)
400406

401-
402-
extern void pgtable_cache_init(void);
403-
404407
typedef pte_t *pte_addr_t;
405408

406409
#endif /* !defined (__ASSEMBLY__) */

‎arch/xtensa/include/asm/processor.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
#include <variant/core.h>
1515
#include <asm/coprocessor.h>
16+
#include <platform/hardware.h>
1617

1718
#include <linux/compiler.h>
1819
#include <asm/ptrace.h>
@@ -35,7 +36,12 @@
3536
* the 1 GB requirement applies to the stack as well.
3637
*/
3738

39+
#ifdef CONFIG_MMU
3840
#define TASK_SIZE __XTENSA_UL_CONST(0x40000000)
41+
#else
42+
#define TASK_SIZE (PLATFORM_DEFAULT_MEM_START + PLATFORM_DEFAULT_MEM_SIZE)
43+
#endif
44+
3945
#define STACK_TOP TASK_SIZE
4046
#define STACK_TOP_MAX STACK_TOP
4147

0 commit comments

Comments
 (0)