/SPARTAN/trunk/include/mm/tlb.h |
---|
29,21 → 29,20 |
#ifndef __TLB_H__ |
#define __TLB_H__ |
extern void tlb_init(void); |
#ifdef __SMP__ |
extern void tlb_init(void); |
extern void tlb_shootdown_start(void); |
extern void tlb_shootdown_finalize(void); |
extern void tlb_shootdown_ipi_recv(void); |
#else |
#define tlb_init() ; |
#define tlb_shootdown_start() ; |
#define tlb_shootdown_finalize() ; |
#define tlb_shootdown_ipi_recv() ; |
# define tlb_shootdown_start() ; |
# define tlb_shootdown_finalize() ; |
# define tlb_shootdown_ipi_recv() ; |
#endif /* __SMP__ */ |
/* Export TLB interface that each architecture must implement. */ |
extern void tlb_init_arch(void); |
extern void tlb_invalidate(int asid); |
extern void tlb_shootdown_ipi_send(void); |
/SPARTAN/trunk/src/main/main.c |
---|
151,7 → 151,6 |
frame_init(); |
page_init(); |
tlb_init(); |
arch_post_mm_init(); |
printf("%s\n%s\n", project, copyright); |
230,6 → 229,7 |
arch_pre_mm_init(); |
frame_init(); |
page_init(); |
tlb_init(); |
arch_post_mm_init(); |
cpu_init(); |
/SPARTAN/trunk/src/mm/tlb.c |
---|
27,6 → 27,7 |
*/ |
#include <mm/tlb.h> |
#include <arch/mm/tlb.h> |
#include <smp/ipi.h> |
#include <synch/spinlock.h> |
#include <typedefs.h> |
37,12 → 38,17 |
#ifdef __SMP__ |
static spinlock_t tlblock; |
#endif |
void tlb_init(void) |
{ |
spinlock_initialize(&tlblock); |
if (config.cpu_active == 1) |
spinlock_initialize(&tlblock); |
tlb_init_arch(); |
} |
#ifdef __SMP__ |
/* must be called with interrupts disabled */ |
void tlb_shootdown_start(void) |
{ |
/SPARTAN/trunk/arch/ia64/include/mm/tlb.h |
---|
0,0 → 1,34 |
/* |
* 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_TLB_H__ |
#define __ia64_TLB_H__ |
#define tlb_init_arch() |
#endif |
/SPARTAN/trunk/arch/ppc32/include/mm/tlb.h |
---|
0,0 → 1,34 |
/* |
* 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_TLB_H__ |
#define __ppc32_TLB_H__ |
#define tlb_init_arch() |
#endif |
/SPARTAN/trunk/arch/amd64/include/mm/tlb.h |
---|
0,0 → 1,34 |
/* |
* 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_TLB_H__ |
#define __amd64_TLB_H__ |
#define tlb_init_arch() |
#endif |
/SPARTAN/trunk/arch/mips32/include/cp0.h |
---|
52,32 → 52,13 |
*/ |
#define cp0_compare_value 10000 |
static inline void tlbp(void) |
{ |
__asm__ volatile ("tlbp"); |
} |
static inline void tlbr(void) |
{ |
__asm__ volatile ("tlbr"); |
} |
static inline void tlbwi(void) |
{ |
__asm__ volatile ("tlbwi"); |
} |
static inline void tlbwr(void) |
{ |
__asm__ volatile ("tlbwr"); |
} |
#define cp0_mask_all_int() cp0_status_write(cp0_status_read() & ~(cp0_status_im_mask)) |
#define cp0_unmask_all_int() cp0_status_write(cp0_status_read() | cp0_status_im_mask) |
#define cp0_mask_int(it) cp0_status_write(cp0_status_read() & ~(1<<(cp0_status_im_shift+(it)))) |
#define cp0_unmask_int(it) cp0_status_write(cp0_status_read() | (1<<(cp0_status_im_shift+(it)))) |
extern __u32 cp0_index_read(void); |
extern void cp0_idnex_write(__u32 val); |
extern void cp0_index_write(__u32 val); |
extern __u32 cp0_random_read(void); |
/SPARTAN/trunk/arch/mips32/include/mm/tlb.h |
---|
31,6 → 31,13 |
#include <arch/exception.h> |
#define TLB_SIZE 48 |
#define TLB_WIRED 1 |
#define TLB_KSTACK_WIRED_INDEX 0 |
#define TLB_PAGE_MASK_16K (0x3<<13) |
#define PAGE_UNCACHED 2 |
#define PAGE_CACHEABLE_EXC_WRITE 5 |
65,7 → 72,35 |
typedef struct entry_lo pte_t; |
/** Read Indexed TLB Entry |
* |
* Read Indexed TLB Entry. |
*/ |
static inline void tlbr(void) |
{ |
__asm__ volatile ("tlbr\n\t"); |
} |
/** Write Indexed TLB Entry |
* |
* Write Indexed TLB Entry. |
*/ |
static inline void tlbwi(void) |
{ |
__asm__ volatile ("tlbwi\n\t"); |
} |
/** Write Random TLB Entry |
* |
* Write Random TLB Entry. |
*/ |
static inline void tlbwr(void) |
{ |
__asm__ volatile ("tlbwr\n\t"); |
} |
extern void tlb_invalid(struct exception_regdump *pstate); |
extern void tlb_refill(struct exception_regdump *pstate); |
extern void tlb_modified(struct exception_regdump *pstate); |
#endif |
/SPARTAN/trunk/arch/mips32/src/exception.c |
---|
80,7 → 80,7 |
panic("unhandled Coprocessor Unusable Exception\n"); |
break; |
case EXC_Mod: |
panic("unhandled TLB Modification Exception\n"); |
tlb_modified(pstate); |
break; |
case EXC_AdEL: |
panic("unhandled Address Error Exception - load or instruction fetch\n"); |
/SPARTAN/trunk/arch/mips32/src/asm.S |
---|
62,8 → 62,8 |
.global cp0_badvaddr_read |
.global cp0_count_read |
.global cp0_count_write |
.global cp0_hi_read |
.global cp0_hi_write |
.global cp0_entry_hi_read |
.global cp0_entry_hi_write |
.global cp0_compare_read |
.global cp0_compare_write |
.global cp0_status_read |
/SPARTAN/trunk/arch/mips32/src/mm/tlb.c |
---|
32,9 → 32,32 |
#include <arch/cp0.h> |
#include <panic.h> |
#include <arch.h> |
#include <symtab.h> |
void tlb_init_arch(void) |
{ |
int i; |
cp0_pagemask_write(TLB_PAGE_MASK_16K); |
cp0_entry_hi_write(0); |
cp0_entry_lo0_write(0); |
cp0_entry_lo1_write(0); |
/* |
* Invalidate all entries. |
*/ |
for (i = 0; i < TLB_SIZE; i++) { |
cp0_index_write(0); |
tlbwi(); |
} |
/* |
* The kernel is going to make use of some wired |
* entries (e.g. mapping kernel stacks). |
*/ |
cp0_wired_write(TLB_WIRED); |
} |
void tlb_refill(struct exception_regdump *pstate) |
{ |
char *symbol = ""; |
46,8 → 69,8 |
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) |
57,10 → 80,22 |
char *s = get_symtab_entry(pstate->epc); |
if (s) |
symbol = s; |
panic("%X: TLB exception at %X(%s)\n", cp0_badvaddr_read(), |
panic("%X: TLB Invalid Exception at %X(%s)\n", cp0_badvaddr_read(), |
pstate->epc, symbol); |
} |
void tlb_modified(struct exception_regdump *pstate) |
{ |
char *symbol = ""; |
char *s = get_symtab_entry(pstate->epc); |
if (s) |
symbol = s; |
panic("%X: TLB Modified Exception at %X(%s)\n", cp0_badvaddr_read(), |
pstate->epc, symbol); |
} |
void tlb_invalidate(int asid) |
{ |
pri_t pri; |
/SPARTAN/trunk/arch/ia32/include/mm/tlb.h |
---|
0,0 → 1,34 |
/* |
* 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_TLB_H__ |
#define __ia32_TLB_H__ |
#define tlb_init_arch() |
#endif |