/SPARTAN/trunk/include/arch.h |
---|
36,12 → 36,10 |
#include <arch/cpu.h> |
#include <arch/asm.h> |
#include <proc/thread.h> |
#include <proc/task.h> |
#define CPU THE->cpu |
#define THREAD THE->thread |
#define TASK THE->task |
#define VM THE->vm |
#define PREEMPTION_DISABLED THE->preemption_disabled |
#ifndef early_mapping |
58,6 → 56,7 |
thread_t *thread; /* current thread */ |
task_t *task; /* current task */ |
cpu_t *cpu; /* executing cpu */ |
vm_t *vm; /* current vm */ |
}; |
#define THE ((the_t *)(get_stack_base())) |
/SPARTAN/trunk/include/mm/page.h |
---|
108,6 → 108,7 |
extern void page_init(void); |
extern void map_page_to_frame(__address page, __address frame, int flags, __address root); |
extern pte_t *find_mapping(__address page, __address root); |
extern void map_structure(__address s, size_t size); |
#endif |
/SPARTAN/trunk/include/mm/vm.h |
---|
31,6 → 31,7 |
#include <arch/mm/page.h> |
#include <arch/mm/vm.h> |
#include <arch/mm/asid.h> |
#include <arch/types.h> |
#include <typedefs.h> |
#include <synch/spinlock.h> |
74,6 → 75,7 |
spinlock_t lock; |
link_t vm_area_head; |
pte_t *ptl0; |
asid_t asid; |
}; |
extern vm_t * vm_create(pte_t *ptl0); |
/SPARTAN/trunk/src/proc/the.c |
---|
43,6 → 43,7 |
the->cpu = NULL; |
the->thread = NULL; |
the->task = NULL; |
the->vm = NULL; |
} |
/** Copy THE structure |
/SPARTAN/trunk/src/main/kinit.c |
---|
54,6 → 54,8 |
#include <test.h> |
#endif /* __TEST__ */ |
#include <mm/frame.h> |
void kinit(void *arg) |
{ |
vm_t *m; |
/SPARTAN/trunk/src/mm/vm.c |
---|
32,6 → 32,8 |
#include <mm/tlb.h> |
#include <mm/heap.h> |
#include <arch/mm/page.h> |
#include <arch/mm/asid.h> |
#include <arch/mm/vm.h> |
#include <arch/types.h> |
#include <typedefs.h> |
#include <synch/spinlock.h> |
56,6 → 58,8 |
spinlock_initialize(&m->lock); |
list_initialize(&m->vm_area_head); |
m->asid = asid_get(); |
/* |
* Each vm_t is supposed to have its own page table. |
* It is either passed one or it has to allocate and set one up. |
199,4 → 203,8 |
tlb_shootdown_finalize(); |
cpu_priority_restore(pri); |
vm_install_arch(m); |
VM = m; |
} |
/SPARTAN/trunk/src/mm/page.c |
---|
34,7 → 34,6 |
#include <arch/asm.h> |
#include <memstr.h> |
void page_init(void) |
{ |
page_arch_init(); |
109,3 → 108,36 |
SET_FRAME_ADDRESS(ptl3, PTL3_INDEX(page), frame); |
SET_FRAME_FLAGS(ptl3, PTL3_INDEX(page), flags); |
} |
/** Find mapping for virtual page |
* |
* Find mapping for virtual page. |
* |
* @param page Virtual page. |
* @param root PTL0 address if non-zero. |
* |
* @return NULL if there is no such mapping; entry from PTL3 describing the mapping otherwise. |
*/ |
pte_t *find_mapping(__address page, __address root) |
{ |
pte_t *ptl0, *ptl1, *ptl2, *ptl3; |
ptl0 = (pte_t *) PA2KA(root ? root : (__address) GET_PTL0_ADDRESS()); |
if (GET_PTL1_FLAGS(ptl0, PTL0_INDEX(page)) & PAGE_NOT_PRESENT) |
return NULL; |
ptl1 = (pte_t *) PA2KA(GET_PTL1_ADDRESS(ptl0, PTL0_INDEX(page))); |
if (GET_PTL2_FLAGS(ptl1, PTL1_INDEX(page)) & PAGE_NOT_PRESENT) |
return NULL; |
ptl2 = (pte_t *) PA2KA(GET_PTL2_ADDRESS(ptl1, PTL1_INDEX(page))); |
if (GET_PTL3_FLAGS(ptl2, PTL2_INDEX(page)) & PAGE_NOT_PRESENT) |
return NULL; |
ptl3 = (pte_t *) PA2KA(GET_PTL3_ADDRESS(ptl2, PTL2_INDEX(page))); |
return &ptl3[PTL3_INDEX(page)]; |
} |
/SPARTAN/trunk/src/time/clock.c |
---|
39,6 → 39,7 |
#include <arch.h> |
#include <list.h> |
#include <arch/atomic.h> |
#include <proc/thread.h> |
/** Clock routine |
* |
/SPARTAN/trunk/arch/ia64/include/types.h |
---|
44,4 → 44,6 |
typedef __u64 __native; |
typedef __u64 pte_t; |
#endif |
/SPARTAN/trunk/arch/ia64/include/mm/page.h |
---|
70,6 → 70,4 |
#define SET_PTL3_FLAGS_ARCH(ptl2, i, x) |
#define SET_FRAME_FLAGS_ARCH(ptl3, i, x) |
typedef __u64 pte_t; |
#endif |
/SPARTAN/trunk/arch/ia64/include/mm/asid.h |
---|
0,0 → 1,36 |
/* |
* Copyright (C) 2005 Jakub Jermar |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
#ifndef __ia64_ASID_H__ |
#define __ia64_ASID_H__ |
typedef int asid_t; |
#define asid_get() 0 |
#endif |
/SPARTAN/trunk/arch/ia64/include/mm/vm.h |
---|
40,4 → 40,6 |
#define USTACK_ADDRESS_ARCH (0x7fffffffffffffff-(PAGE_SIZE-1)) |
#define UDATA_ADDRESS_ARCH 0x0000000001001000 |
#define vm_install_arch(vm) |
#endif |
/SPARTAN/trunk/arch/ppc32/include/types.h |
---|
44,4 → 44,6 |
typedef __u32 __native; |
typedef __u32 pte_t; |
#endif |
/SPARTAN/trunk/arch/ppc32/include/mm/page.h |
---|
68,6 → 68,4 |
extern void page_arch_init(void); |
typedef __u32 pte_t; |
#endif |
/SPARTAN/trunk/arch/ppc32/include/mm/asid.h |
---|
0,0 → 1,36 |
/* |
* Copyright (C) 2005 Jakub Jermar |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
#ifndef __ppc32_ASID_H__ |
#define __ppc32_ASID_H__ |
typedef int asid_t; |
#define asid_get() 0 |
#endif |
/SPARTAN/trunk/arch/ppc32/include/mm/vm.h |
---|
40,4 → 40,6 |
#define USTACK_ADDRESS_ARCH (0x7fffffff-(PAGE_SIZE-1)) |
#define UDATA_ADDRESS_ARCH 0x21000000 |
#define vm_install_arch(vm) |
#endif |
/SPARTAN/trunk/arch/amd64/include/mm/page.h |
---|
74,8 → 74,6 |
#ifndef __ASM__ |
typedef struct page_specifier pte_t; |
struct page_specifier { |
unsigned present : 1; |
unsigned writeable : 1; |
/SPARTAN/trunk/arch/amd64/include/mm/asid.h |
---|
0,0 → 1,36 |
/* |
* Copyright (C) 2005 Jakub Jermar |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
#ifndef __amd64_ASID_H__ |
#define __amd64_ASID_H__ |
typedef int asid_t; |
#define asid_get() 0 |
#endif |
/SPARTAN/trunk/arch/amd64/include/mm/vm.h |
---|
40,4 → 40,6 |
#define USTACK_ADDRESS_ARCH (USER_ADDRESS_SPACE_END_ARCH-(PAGE_SIZE-1)) |
#define UDATA_ADDRESS_ARCH 0x21000000 |
#define vm_install_arch(vm) |
#endif |
/SPARTAN/trunk/arch/amd64/include/types.h |
---|
45,4 → 45,6 |
typedef __u64 __native; |
typedef struct page_specifier pte_t; |
#endif |
/SPARTAN/trunk/arch/amd64/src/cpu/cpu.c |
---|
34,6 → 34,7 |
#include <arch/types.h> |
#include <print.h> |
#include <typedefs.h> |
#include <fpu_context.h> |
/* |
* Identification of CPUs. |
/SPARTAN/trunk/arch/amd64/src/interrupt.c |
---|
39,6 → 39,7 |
#include <symtab.h> |
#include <arch/asm.h> |
#include <proc/scheduler.h> |
#include <proc/thread.h> |
static void messy_stack_trace(__native *stack) |
/SPARTAN/trunk/arch/mips32/include/types.h |
---|
49,4 → 49,6 |
typedef __u32 __native; |
typedef struct entry_lo pte_t; |
#endif |
/SPARTAN/trunk/arch/mips32/include/cp0.h |
---|
30,6 → 30,7 |
#define __mips32_CP0_H__ |
#include <arch/types.h> |
#include <arch/mm/tlb.h> |
#define cp0_status_ie_enabled_bit (1<<0) |
#define cp0_status_exl_exception_bit (1<<1) |
/SPARTAN/trunk/arch/mips32/include/mm/page.h |
---|
56,20 → 56,20 |
#define PTL0_INDEX_ARCH(vaddr) ((vaddr)>>26) |
#define PTL1_INDEX_ARCH(vaddr) 0 |
#define PTL2_INDEX_ARCH(vaddr) 0 |
#define PTL3_INDEX_ARCH(vaddr) (((vaddr)>>14)&0xfff) |
#define PTL3_INDEX_ARCH(vaddr) (((vaddr)>>12)&0xfff) |
#define GET_PTL0_ADDRESS_ARCH() (PTL0) |
#define SET_PTL0_ADDRESS_ARCH(ptl0) (PTL0 = (pte_t *)(ptl0)) |
#define GET_PTL1_ADDRESS_ARCH(ptl0, i) (((pte_t *)(ptl0))[(i)].pfn<<14) |
#define GET_PTL1_ADDRESS_ARCH(ptl0, i) (((pte_t *)(ptl0))[(i)].pfn<<12) |
#define GET_PTL2_ADDRESS_ARCH(ptl1, i) (ptl1) |
#define GET_PTL3_ADDRESS_ARCH(ptl2, i) (ptl2) |
#define GET_FRAME_ADDRESS_ARCH(ptl3, i) (((pte_t *)(ptl3))[(i)].pfn<<14) |
#define GET_FRAME_ADDRESS_ARCH(ptl3, i) (((pte_t *)(ptl3))[(i)].pfn<<12) |
#define SET_PTL1_ADDRESS_ARCH(ptl0, i, a) (((pte_t *)(ptl0))[(i)].pfn = (a)>>14) |
#define SET_PTL1_ADDRESS_ARCH(ptl0, i, a) (((pte_t *)(ptl0))[(i)].pfn = (a)>>12) |
#define SET_PTL2_ADDRESS_ARCH(ptl1, i, a) |
#define SET_PTL3_ADDRESS_ARCH(ptl2, i, a) |
#define SET_FRAME_ADDRESS_ARCH(ptl3, i, a) (((pte_t *)(ptl3))[(i)].pfn = (a)>>14) |
#define SET_FRAME_ADDRESS_ARCH(ptl3, i, a) (((pte_t *)(ptl3))[(i)].pfn = (a)>>12) |
#define GET_PTL1_FLAGS_ARCH(ptl0, i) get_pt_flags((pte_t *)(ptl0), (index_t)(i)) |
#define GET_PTL2_FLAGS_ARCH(ptl1, i) PAGE_PRESENT |
/SPARTAN/trunk/arch/mips32/include/mm/asid.h |
---|
1,5 → 1,5 |
/* |
* Copyright (C) 2005 Matrin Decky |
* Copyright (C) 2005 Martin Decky |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
29,6 → 29,11 |
#ifndef __mips32_ASID_H__ |
#define __mips32_ASID_H__ |
extern void asid_bitmap_reset(void); |
#include <arch/types.h> |
typedef __u8 asid_t; |
extern asid_t asid_get(void); |
extern void asid_put(asid_t asid); |
#endif |
/SPARTAN/trunk/arch/mips32/include/mm/tlb.h |
---|
52,8 → 52,7 |
struct entry_hi { |
unsigned asid : 8; |
unsigned : 4; |
unsigned g : 1; |
unsigned : 5; |
unsigned vpn2 : 19; |
} __attribute__ ((packed)); |
70,7 → 69,6 |
struct page_mask mask; |
} __attribute__ ((packed)); |
typedef struct entry_lo pte_t; |
/** Read Indexed TLB Entry |
* |
/SPARTAN/trunk/arch/mips32/include/mm/vm.h |
---|
30,6 → 30,7 |
#define __mips32_VM_H__ |
#include <arch/types.h> |
#include <typedefs.h> |
#define KERNEL_ADDRESS_SPACE_START_ARCH (__address) 0x80000000 |
#define KERNEL_ADDRESS_SPACE_END_ARCH (__address) 0xffffffff |
40,4 → 41,6 |
#define USTACK_ADDRESS_ARCH (0x80000000-PAGE_SIZE) |
#define UDATA_ADDRESS_ARCH 0x01001000 |
extern void vm_install_arch(vm_t *vm); |
#endif |
/SPARTAN/trunk/arch/mips32/Makefile.inc |
---|
11,7 → 11,7 |
DEFS=-DARCH=$(ARCH) -DMACHINE=${MACHINE} -DKERNEL_LOAD_ADDRESS=${KERNEL_LOAD_ADDRESS} |
CFLAGS=$(DEFS) -mno-abicalls -G 0 -nostdlib -fno-builtin -O2 -fno-zero-initialized-in-bss |
LFLAGS=-M -N |
LFLAGS= |
BFD_ARCH=mips |
# GCC 4.0.1 compiled for mipsEL has problems compiling in |
86,9 → 86,11 |
src/arch/interrupt.c \ |
src/arch/cache.c \ |
src/arch/cpu/cpu.c \ |
src/arch/mm/asid.c \ |
src/arch/mm/frame.c \ |
src/arch/mm/page.c \ |
src/arch/mm/tlb.c \ |
src/arch/mm/vm.c \ |
src/arch/fpu_context.c \ |
src/arch/fmath.c \ |
src/arch/drivers/arc.c |
/SPARTAN/trunk/arch/mips32/src/exception.c |
---|
33,6 → 33,7 |
#include <arch/types.h> |
#include <arch.h> |
#include <debug.h> |
#include <proc/thread.h> |
void exception(struct exception_regdump *pstate) |
{ |
/SPARTAN/trunk/arch/mips32/src/mm/asid.c |
---|
26,31 → 26,66 |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
#include <arch/mm/asid.h> |
#include <synch/spinlock.h> |
#include <arch.h> |
#include <memstr.h> |
#include <debug.h> |
/**< Array of threads that have currently some ASID assigned, |
NULL means no thread have ASID with number of that index assigned */ |
struct thread * asids[256]; |
int last_asid; /**< The number of last assigned ASID */ |
int asid_bitmap[32]; /**< Bitmap of ASIDs currently in TLB */ |
#define ASIDS 256 |
static spinlock_t asid_usage_lock; |
static count_t asid_usage[ASIDS]; /**< Usage tracking array for ASIDs */ |
/** Cleanup asid_bitmap |
/** Get ASID |
* |
* Get the least used ASID. |
* |
* @return ASID |
*/ |
void asid_bitmap_reset(void) |
asid_t asid_get(void) |
{ |
memsetb(asid_bitmap, sizeof(asid_bitmap), 0); |
pri_t pri; |
int i, j; |
count_t min; |
min = (unsigned) -1; |
pri = cpu_priority_high(); |
spinlock_lock(&asid_usage_lock); |
for (i=0, j = 0; (i<ASIDS); i++) { |
if (asid_usage[i] < min) { |
j = i; |
min = asid_usage[i]; |
if (!min) |
break; |
} |
} |
asid_usage[i]++; |
/** Initialize manipulating with ASIDs |
spinlock_unlock(&asid_usage_lock); |
cpu_priority_restore(pri); |
return i; |
} |
/** Release ASID |
* |
* Release ASID by decrementing its usage count. |
* |
* @param asid ASID. |
*/ |
void init_asids(void) |
void asid_put(asid_t asid) |
{ |
memsetb(asids, sizeof(asids), 0); |
asid_bitmap_reset(); |
last_asid = 0; |
pri_t pri; |
pri = cpu_priority_high(); |
spinlock_lock(&asid_usage_lock); |
ASSERT(asid_usage[asid] > 0); |
asid_usage[asid]--; |
spinlock_unlock(&asid_usage_lock); |
cpu_priority_restore(pri); |
} |
/SPARTAN/trunk/arch/mips32/src/mm/tlb.c |
---|
29,11 → 29,24 |
#include <arch/mm/tlb.h> |
#include <arch/mm/asid.h> |
#include <mm/tlb.h> |
#include <mm/page.h> |
#include <mm/vm.h> |
#include <arch/cp0.h> |
#include <panic.h> |
#include <arch.h> |
#include <symtab.h> |
#include <synch/spinlock.h> |
#include <print.h> |
static void tlb_refill_fail(struct exception_regdump *pstate); |
static void tlb_invalid_fail(struct exception_regdump *pstate); |
static void tlb_modified_fail(struct exception_regdump *pstate); |
/** Initialize TLB |
* |
* Initialize TLB. |
* Invalidate all entries and mark wired entries. |
*/ |
void tlb_init_arch(void) |
{ |
int i; |
47,19 → 60,88 |
* Invalidate all entries. |
*/ |
for (i = 0; i < TLB_SIZE; i++) { |
cp0_index_write(0); |
cp0_index_write(i); |
tlbwi(); |
} |
/* |
* The kernel is going to make use of some wired |
* entries (e.g. mapping kernel stacks). |
* entries (e.g. mapping kernel stacks in kseg3). |
*/ |
cp0_wired_write(TLB_WIRED); |
} |
/** Process TLB Refill Exception |
* |
* Process TLB Refill Exception. |
* |
* @param pstate Interrupted register context. |
*/ |
void tlb_refill(struct exception_regdump *pstate) |
{ |
struct entry_hi hi; |
__address badvaddr; |
pte_t *pte; |
*((__u32 *) &hi) = cp0_entry_hi_read(); |
badvaddr = cp0_badvaddr_read(); |
spinlock_lock(&VM->lock); |
/* |
* Refill cannot succeed if the ASIDs don't match. |
*/ |
if (hi.asid != VM->asid) |
goto fail; |
/* |
* Refill cannot succeed if badvaddr is not |
* associated with any mapping. |
*/ |
pte = find_mapping(badvaddr, 0); |
if (!pte) |
goto fail; |
/* |
* Refill cannot succeed if the mapping is marked as invalid. |
*/ |
if (!pte->v) |
goto fail; |
/* |
* New entry is to be inserted into TLB |
*/ |
cp0_pagemask_write(TLB_PAGE_MASK_16K); |
if ((badvaddr/PAGE_SIZE) % 2 == 0) { |
cp0_entry_lo0_write(*((__u32 *) pte)); |
cp0_entry_lo1_write(0); |
} |
else { |
cp0_entry_lo0_write(0); |
cp0_entry_lo1_write(*((__u32 *) pte)); |
} |
tlbwr(); |
spinlock_unlock(&VM->lock); |
return; |
fail: |
spinlock_unlock(&VM->lock); |
tlb_refill_fail(pstate); |
} |
void tlb_invalid(struct exception_regdump *pstate) |
{ |
tlb_invalid_fail(pstate); |
} |
void tlb_modified(struct exception_regdump *pstate) |
{ |
tlb_modified_fail(pstate); |
} |
void tlb_refill_fail(struct exception_regdump *pstate) |
{ |
char *symbol = ""; |
char *sym2 = ""; |
69,11 → 151,11 |
s = get_symtab_entry(pstate->ra); |
if (s) |
sym2 = s; |
panic("%X: TLB Refill Exception at %X(%s<-%s)\n", cp0_badvaddr_read(), |
pstate->epc, symbol, sym2); |
panic("%X: TLB Refill Exception at %X(%s<-%s)\n", cp0_badvaddr_read(), pstate->epc, symbol, sym2); |
} |
void tlb_invalid(struct exception_regdump *pstate) |
void tlb_invalid_fail(struct exception_regdump *pstate) |
{ |
char *symbol = ""; |
84,7 → 166,7 |
pstate->epc, symbol); |
} |
void tlb_modified(struct exception_regdump *pstate) |
void tlb_modified_fail(struct exception_regdump *pstate) |
{ |
char *symbol = ""; |
102,8 → 184,6 |
pri = cpu_priority_high(); |
// asid_bitmap_reset(); |
// TODO |
cpu_priority_restore(pri); |
/SPARTAN/trunk/arch/mips32/src/mm/vm.c |
---|
0,0 → 1,55 |
/* |
* Copyright (C) 2005 Jakub Jermar |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
#include <arch/mm/vm.h> |
#include <arch/mm/tlb.h> |
#include <mm/vm.h> |
#include <arch/cp0.h> |
#include <arch.h> |
#include <print.h> |
/** Install ASID of the current VM |
* |
* Install ASID of the current VM. |
* |
* @param vm VM structure. |
*/ |
void vm_install_arch(vm_t *vm) |
{ |
struct entry_hi hi; |
pri_t pri; |
*((__u32 *) &hi) = cp0_entry_hi_read(); |
pri = cpu_priority_high(); |
spinlock_lock(&vm->lock); |
hi.asid = vm->asid; |
cp0_entry_hi_write(*((__u32 *) &hi)); |
spinlock_lock(&vm->unlock); |
cpu_priority_restore(pri); |
} |
/SPARTAN/trunk/arch/mips32/src/mips32.c |
---|
37,7 → 37,7 |
#include <memstr.h> |
#include <arch/interrupt.h> |
#include <arch/drivers/arc.h> |
#include <proc/thread.h> |
#include <print.h> |
/* Size of the code jumping to the exception handler code |
/SPARTAN/trunk/arch/ia32/include/types.h |
---|
44,4 → 44,6 |
typedef __u32 __native; |
typedef struct page_specifier pte_t; |
#endif |
/SPARTAN/trunk/arch/ia32/include/mm/page.h |
---|
90,8 → 90,6 |
unsigned frame_address : 20; |
} __attribute__ ((packed)); |
typedef struct page_specifier pte_t; |
static inline int get_pt_flags(pte_t *pt, index_t i) |
{ |
pte_t *p = &pt[i]; |
/SPARTAN/trunk/arch/ia32/include/mm/asid.h |
---|
0,0 → 1,36 |
/* |
* Copyright (C) 2005 Jakub Jermar |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
#ifndef __ia32_ASID_H__ |
#define __ia32_ASID_H__ |
typedef int asid_t; |
#define asid_get() 0 |
#endif |
/SPARTAN/trunk/arch/ia32/include/mm/vm.h |
---|
40,4 → 40,6 |
#define USTACK_ADDRESS_ARCH (USER_ADDRESS_SPACE_END_ARCH-(PAGE_SIZE-1)) |
#define UDATA_ADDRESS_ARCH 0x21000000 |
#define vm_install_arch(vm) |
#endif |
/SPARTAN/trunk/arch/ia32/src/cpu/cpu.c |
---|
34,6 → 34,7 |
#include <arch/types.h> |
#include <print.h> |
#include <typedefs.h> |
#include <fpu_context.h> |
#include <arch/smp/apic.h> |
/SPARTAN/trunk/arch/ia32/src/interrupt.c |
---|
37,6 → 37,7 |
#include <mm/tlb.h> |
#include <arch.h> |
#include <symtab.h> |
#include <proc/thread.h> |
/* |
* Interrupt and exception dispatching. |