diff -urN linux-2.5.75/arch/sparc/Kconfig linux-2.5.75-patch-topete/arch/sparc/Kconfig --- linux-2.5.75/arch/sparc/Kconfig 2003-07-10 22:03:32.000000000 +0200 +++ linux-2.5.75-patch-topete/arch/sparc/Kconfig 2003-08-20 09:42:21.000000000 +0200 @@ -228,6 +228,14 @@ a kernel compiled with this option will run only on sun4. (And the current version will probably work only on sun4/330.) +config LEON + bool "Running on SoC 'Leon', the open source sparc VHDL model" + help + Say Y here if you want to run linux on the Leon System-on-a-Chip + platform. For information go to www.gaisler.com. Download the VHDL + source and use the instruction level Leon sparc-simulator "tsim" which + is free for private use. + if !SUN4 config PCI @@ -321,6 +329,10 @@ source "drivers/base/Kconfig" +if LEON +source "arch/sparc/Kconfig_leon" +endif + source "drivers/video/Kconfig" source "drivers/mtd/Kconfig" diff -urN linux-2.5.75/arch/sparc/Kconfig_leon linux-2.5.75-patch-topete/arch/sparc/Kconfig_leon --- linux-2.5.75/arch/sparc/Kconfig_leon 1970-01-01 01:00:00.000000000 +0100 +++ linux-2.5.75-patch-topete/arch/sparc/Kconfig_leon 2003-08-20 09:42:21.000000000 +0200 @@ -0,0 +1,62 @@ +# Konrad Eisele, 2003: arch/sparc/Kconfig_leon +# For a description of the syntax of this configuration file, +# see Documentation/kbuild/kconfig-language.txt. +# + +################### +menu "Leon Kernel settings" + +choice + prompt "Kernel executes from" + default ROMKERNEL + ---help--- + Choose the memory type where part of the kernel will be running in. + +config RAMKERNEL + bool "RAMKERNEL" + help + The kernel will be resident in S/DRAM when running. + +config ROMKERNEL + bool "ROMKERNEL" + help + The kernel's .text segment will be resident in FLASH/ROM when running. + +endchoice + +config SDRAM + bool "MEM controller supports SDRAM" + default n + +config NOSRAM + bool "Disable SRAM" + default n + depends SDRAM + help + If SDRAM is supported it will be mapped to 0x40000000 (instead of 0x60000000) if SRAM is disabled + +choice + prompt "Ram part of kernel in" + depends SDRAM && !NOSRAM + ---help--- + Choose the memory type that the Ram part of the kernel + will be loaded to. + +config SRAMKERNEL + bool "SRAMKERNEL" + help + For RAMKERNEL enabled the whole kernel will reside in SRAM. + For ROMKERNEL enabled the .data segment of the kernel will reside in SRAM. + +config SDRAMKERNEL + bool "SDRAMKERNEL" + help + For RAMKERNEL enabled the whole kernel will reside in SDRAM. + For ROMKERNEL enabled the .data segment of the kernel will reside in SDRAM. + +endchoice + +endmenu + +################### + diff -urN linux-2.5.75/arch/sparc/kernel/Makefile linux-2.5.75-patch-topete/arch/sparc/kernel/Makefile --- linux-2.5.75/arch/sparc/kernel/Makefile 2003-07-10 22:14:10.000000000 +0200 +++ linux-2.5.75-patch-topete/arch/sparc/kernel/Makefile 2003-08-20 09:42:21.000000000 +0200 @@ -6,7 +6,7 @@ EXTRA_AFLAGS := -ansi -IRQ_OBJS := irq.o sun4m_irq.o sun4c_irq.o sun4d_irq.o +IRQ_OBJS := irq.o sun4m_irq.o sun4c_irq.o sun4d_irq.o leon_irq.o obj-y := entry.o wof.o wuf.o etrap.o rtrap.o traps.o $(IRQ_OBJS) \ process.o signal.o ioport.o setup.o idprom.o \ sys_sparc.o sunos_asm.o systbls.o \ @@ -24,3 +24,9 @@ ifdef CONFIG_SUNOS_EMUL obj-y += sys_sunos.o sunos_ioctl.o endif + +ifdef CONFIG_LEON +#CFLAGS_irq.o = -Dinit_IRQ=sun_init_IRQ +#CFLAGS_setup.o = -Dsetup_arch=sun_setup_arch +obj-y += leon.o +endif diff -urN linux-2.5.75/arch/sparc/kernel/auxio.c linux-2.5.75-patch-topete/arch/sparc/kernel/auxio.c --- linux-2.5.75/arch/sparc/kernel/auxio.c 2003-07-10 22:12:21.000000000 +0200 +++ linux-2.5.75-patch-topete/arch/sparc/kernel/auxio.c 2003-08-20 09:42:21.000000000 +0200 @@ -29,6 +29,7 @@ switch (sparc_cpu_model) { case sun4d: case sun4: + case sparc_leon: return; default: break; diff -urN linux-2.5.75/arch/sparc/kernel/cpu.c linux-2.5.75-patch-topete/arch/sparc/kernel/cpu.c --- linux-2.5.75/arch/sparc/kernel/cpu.c 2003-07-10 22:14:09.000000000 +0200 +++ linux-2.5.75-patch-topete/arch/sparc/kernel/cpu.c 2003-08-20 09:42:21.000000000 +0200 @@ -126,7 +126,7 @@ void __init cpu_probe(void) { int psr_impl, psr_vers, fpu_vers; - int i, cpuid, psr; + int i, cpuid, psr, psref; cpuid = hard_smp_processor_id(); @@ -135,15 +135,29 @@ psr = get_psr(); put_psr(psr | PSR_EF); - fpu_vers = ((get_fsr()>>17)&0x7); + psref = get_psr(); + psref &= PSR_EF; + if (psref==0) { + /*no fpu, no read of fsr allowed*/ + fpu_vers = 0; + } else { + fpu_vers = ((get_fsr()>>17)&0x7); + } + put_psr(psr); for(i = 0; i #include #include #include @@ -27,7 +28,7 @@ #define t_retpc l6 /* If you change this, change winmacro.h header file */ #define t_systable l7 /* Never touch this, could be the syscall table ptr. */ #define curptr g6 /* Set after pt_regs frame is built */ - + .text .align 4 @@ -221,7 +222,11 @@ */ .globl C_LABEL(tsetup_mmu_patchme) C_LABEL(tsetup_mmu_patchme): +#ifdef CONFIG_LEON /* Leon-arch only: no btfixup */ + b C_LABEL(tsetup_srmmu_stackchk) +#else b C_LABEL(tsetup_sun4c_stackchk) +#endif andcc %sp, 0x7, %g0 /* Architecture specific stack checking routines. When either diff -urN linux-2.5.75/arch/sparc/kernel/head.S linux-2.5.75-patch-topete/arch/sparc/kernel/head.S --- linux-2.5.75/arch/sparc/kernel/head.S 2003-07-10 22:06:06.000000000 +0200 +++ linux-2.5.75-patch-topete/arch/sparc/kernel/head.S 2003-08-20 09:42:21.000000000 +0200 @@ -788,6 +788,11 @@ cmp %o0, %g6 ! an old sun4? be sun4_init nop + + set KERNBASE, %g6 + cmp %o0, %g6 ! running on sparc-leon SOC? + be leon_init + nop found_version: #ifdef CONFIG_SUN4 @@ -839,6 +844,8 @@ cmp %l1, ' ' be 1f + cmp %l1, '@' /* running on leon: written in leon_init */ + be 1f cmp %l1, 'c' be 1f cmp %l1, 'm' @@ -861,8 +868,10 @@ be sun4m_init cmp %l1, 'd' ! Let us see how the beast will die be sun4d_init - nop - + cmp %l1, '@' /* running on leon: written in leon_init */ + be sun4c_continue_boot + nop + /* Jump into mmu context zero. */ set AC_CONTEXT, %g1 stba %g0, [%g1] ASI_CONTROL @@ -1159,6 +1168,17 @@ call halt_me nop +/* leon locore same as sun4_init */ +leon_init: + set C_LABEL(cputypval), %o2 ! Let everyone know we are a "leon@" architecture + set 'l'<<24|'e'<<16|'o'<<8|'n'<<0, %o0 + st %o0, [%o2] + set '@', %o0 + stb %o0, [%o2 + 0x4] + + b got_prop + nop + sun4_init: #ifdef CONFIG_SUN4 /* There, happy now Adrian? */ diff -urN linux-2.5.75/arch/sparc/kernel/idprom.c linux-2.5.75-patch-topete/arch/sparc/kernel/idprom.c --- linux-2.5.75/arch/sparc/kernel/idprom.c 2003-07-10 22:06:05.000000000 +0200 +++ linux-2.5.75-patch-topete/arch/sparc/kernel/idprom.c 2003-08-20 09:42:21.000000000 +0200 @@ -31,6 +31,8 @@ { "Sun 4/200 Series", (SM_SUN4 | SM_4_260) }, { "Sun 4/300 Series", (SM_SUN4 | SM_4_330) }, { "Sun 4/400 Series", (SM_SUN4 | SM_4_470) }, +/* Now Leon */ +{ "Leon2 System-on-a-Chip", (M_LEON2 | M_LEON2_SOC) }, /* Now, Sun4c's */ { "Sun4c SparcStation 1", (SM_SUN4C | SM_4C_SS1) }, { "Sun4c SparcStation IPC", (SM_SUN4C | SM_4C_IPC) }, diff -urN linux-2.5.75/arch/sparc/kernel/irq.c linux-2.5.75-patch-topete/arch/sparc/kernel/irq.c --- linux-2.5.75/arch/sparc/kernel/irq.c 2003-07-10 22:04:46.000000000 +0200 +++ linux-2.5.75-patch-topete/arch/sparc/kernel/irq.c 2003-08-20 10:28:09.000000000 +0200 @@ -653,7 +653,12 @@ case sun4: sun4c_init_IRQ(); break; - + case sparc_leon: + { + void leon_init_IRQ(void); + leon_init_IRQ(); + break; + } case sun4m: #ifdef CONFIG_PCI pcic_probe(); diff -urN linux-2.5.75/arch/sparc/kernel/leon.c linux-2.5.75-patch-topete/arch/sparc/kernel/leon.c --- linux-2.5.75/arch/sparc/kernel/leon.c 1970-01-01 01:00:00.000000000 +0100 +++ linux-2.5.75-patch-topete/arch/sparc/kernel/leon.c 2003-08-20 10:18:55.000000000 +0200 @@ -0,0 +1,17 @@ +/* Konrad Eisele , 2003, arch/sparc/kernel/leon.c */ + +#include +#include + +#if !defined(__OPTIMIZE__) +#warning "###############Remove this code, this is only present for debugging while reimplementing 2.5.69 ############################" + +__u32 ntohl(__u32 x) { return __be32_to_cpu(x); }; +__u32 htonl(__u32 x) { return __cpu_to_be32(x); }; +unsigned short int ntohs(unsigned short int x) { return __be16_to_cpu(x); } +unsigned short int htons(unsigned short int x) { return __cpu_to_be16(x); } +#endif + +void btfixup(void) { + +} diff -urN linux-2.5.75/arch/sparc/kernel/leon_irq.c linux-2.5.75-patch-topete/arch/sparc/kernel/leon_irq.c --- linux-2.5.75/arch/sparc/kernel/leon_irq.c 1970-01-01 01:00:00.000000000 +0100 +++ linux-2.5.75-patch-topete/arch/sparc/kernel/leon_irq.c 2003-08-20 10:16:28.000000000 +0200 @@ -0,0 +1,153 @@ +/* Konrad Eisele , 2003: arch/sparc/leon/kernel/irq.c */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include /* for struct sbus_bus, warning suppress */ +#include + +#define CLOCK_TIMER_SCALAR 25 /* scaled down to timer to 1Mhz, used in sparc/kernel/leon_irq.c */ + +static inline unsigned long get_irqmask(unsigned int irq) +{ + unsigned long mask; + if (!irq || irq > 0xf) { + printk("leon_get_irqmask: false irq number\n"); + mask = 0; + } else { + mask = LEON_HARD_INT(irq); + } + return mask; +} + +void leon_disable_irq(unsigned int irq_nr) +{ + unsigned long mask, flags; + mask = get_irqmask(irq_nr) & LEON_IRQMASK_R; + save_and_cli(flags); + LEON_REGSTORE_PA(LEON_IMASK, LEON_REGLOAD_PA(LEON_IMASK) & ~(mask)); + restore_flags(flags); +} + +void leon_enable_irq(unsigned int irq_nr) +{ + unsigned long mask, flags; + mask = get_irqmask(irq_nr) & LEON_IRQMASK_R; + save_and_cli(flags); + LEON_REGSTORE_PA(LEON_IMASK, LEON_REGLOAD_PA(LEON_IMASK) | (mask)); + restore_flags(flags); +} + +/* We assume the caller is local cli()'d when these are called, or else + * very bizarre behavior will result. */ +void leon_disable_pil_irq(unsigned int pil) +{ + unsigned long mask = get_irqmask(pil); + LEON_REGSTORE_PA(LEON_IMASK, LEON_REGLOAD_PA(LEON_IMASK) & ~(mask)); +} + +void leon_enable_pil_irq(unsigned int pil) +{ + unsigned long mask = get_irqmask(pil); + LEON_REGSTORE_PA(LEON_IMASK, LEON_REGLOAD_PA(LEON_IMASK) | (mask)); +} + +int leondebug_irq_disable; +int leon_debug_irqout; +static int dummy_master_l10_counter; +static int dummy_master_l10_limit; +void __init leon_init_timers(irqreturn_t (*counter_fn)(int, void *, struct pt_regs *)) /* called by time_init():timer.c */ +{ + int irq; + //int freq = (leon_setup_vector.freq_kh + 500) / 1000;//(CONFIG_MKPROM_FREQ+500)/1000; + + leondebug_irq_disable = 0; + leon_debug_irqout = 0; + + LEON_REGSTORE_PA(LEON_TCTRL0, 0); + LEON_REGSTORE_PA(LEON_TCNT0, 0); + LEON_REGSTORE_PA(LEON_TRLD0, (((1000000/HZ) - 1))); + #if 0 + /* dsumon or bootloader alread initialized this */ + LEON_REGSTORE_PA(LEON_SRLD, freq-1); /* scale to 1MHZ, defined in asm-sparc/timex.h */ + LEON_REGSTORE_PA(LEON_SCNT, freq-1); + #endif + + printk("Todo: init master_l10_counter\r\n"); + master_l10_counter = &dummy_master_l10_counter; + master_l10_limit = &dummy_master_l10_limit; + dummy_master_l10_counter = 0; + dummy_master_l10_limit = 0; + + irq = request_irq(LEON_INTERRUPT_TIMER1, + counter_fn, + (SA_INTERRUPT | SA_STATIC_ALLOC), + "timer", NULL); + if (irq) { + printk("leon_time_init: unable to attach IRQ%d\n",LEON_INTERRUPT_TIMER1); + prom_halt(); + } + + LEON_REGSTORE_PA(LEON_TCTRL0, 0x7); /* enable, load reload into counter, set automatic reload */ +} + +void leon_clear_clock_irq ( void) { +} +void leon_clear_profile_irq ( int cpu) { /* nop SMP */ + BUG(); +} +void leon_load_profile_irq ( int cpu, unsigned int limit) { /* nop SMP */ + BUG(); +} +unsigned int leon_sbint_to_irq(struct sbus_dev *sdev, unsigned int sbint) { + BUG(); + return 0; +} +static char *leon_irq_itoa(unsigned int irq) { + static char buff[16]; + sprintf(buff, "%d", irq); + return buff; +} + +#ifdef CONFIG_SMP +static void leon_set_cpu_int(int cpu, int level) { + printk("Not implemented\n"); + BUG(); + //sun4d_send_ipi(cpu, level); +} +static void leon_clear_ipi(int cpu, int level) { +} + +static void leon_set_udt(int cpu) { +} +#endif + +void __init leon_init_IRQ(void) +{ + sparc_init_timers = leon_init_timers; + + BTFIXUPSET_CALL(sbint_to_irq, leon_sbint_to_irq, BTFIXUPCALL_NORM); + + BTFIXUPSET_CALL(enable_irq, leon_enable_irq, BTFIXUPCALL_NORM); + BTFIXUPSET_CALL(disable_irq, leon_disable_irq, BTFIXUPCALL_NORM); + BTFIXUPSET_CALL(enable_pil_irq, leon_enable_irq, BTFIXUPCALL_NORM); + BTFIXUPSET_CALL(disable_pil_irq, leon_disable_irq, BTFIXUPCALL_NORM); + + BTFIXUPSET_CALL(clear_clock_irq, leon_clear_clock_irq, BTFIXUPCALL_NORM); + BTFIXUPSET_CALL(clear_profile_irq, leon_clear_profile_irq, BTFIXUPCALL_NOP); + BTFIXUPSET_CALL(load_profile_irq, leon_load_profile_irq, BTFIXUPCALL_NOP); + BTFIXUPSET_CALL(__irq_itoa, leon_irq_itoa, BTFIXUPCALL_NORM); + +#ifdef CONFIG_SMP + BTFIXUPSET_CALL(set_cpu_int, leon_set_cpu_int, BTFIXUPCALL_NOP); + BTFIXUPSET_CALL(clear_cpu_int, leon_clear_ipi, BTFIXUPCALL_NOP); + BTFIXUPSET_CALL(set_irq_udt, leon_set_udt, BTFIXUPCALL_NOP); +#endif + +} diff -urN linux-2.5.75/arch/sparc/kernel/rtrap.S linux-2.5.75-patch-topete/arch/sparc/kernel/rtrap.S --- linux-2.5.75/arch/sparc/kernel/rtrap.S 2003-07-10 22:14:10.000000000 +0200 +++ linux-2.5.75-patch-topete/arch/sparc/kernel/rtrap.S 2003-08-20 09:42:21.000000000 +0200 @@ -4,6 +4,7 @@ * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) */ +#include #include #include #include @@ -134,7 +135,12 @@ * for return from traps. */ .globl C_LABEL(rtrap_mmu_patchme) -C_LABEL(rtrap_mmu_patchme): b C_LABEL(sun4c_rett_stackchk) +C_LABEL(rtrap_mmu_patchme): +#ifdef CONFIG_LEON /* Leon-arch only: no btfixup */ + b C_LABEL(srmmu_rett_stackchk) +#else + b C_LABEL(sun4c_rett_stackchk) +#endif andcc %fp, 0x7, %g0 ret_trap_userwins_ok: @@ -307,7 +313,7 @@ save %g0, %g0, %g0 - andn %g1, 0x2, %g1 + andn %g1, 0x2 , %g1 sta %g1, [%g0] ASI_M_MMUREGS mov AC_M_SFAR, %g2 diff -urN linux-2.5.75/arch/sparc/kernel/sclow.S linux-2.5.75-patch-topete/arch/sparc/kernel/sclow.S --- linux-2.5.75/arch/sparc/kernel/sclow.S 2003-07-10 22:14:15.000000000 +0200 +++ linux-2.5.75-patch-topete/arch/sparc/kernel/sclow.S 2003-08-20 09:42:21.000000000 +0200 @@ -6,6 +6,7 @@ * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu) */ +#include #include #include #include diff -urN linux-2.5.75/arch/sparc/kernel/setup.c linux-2.5.75-patch-topete/arch/sparc/kernel/setup.c --- linux-2.5.75/arch/sparc/kernel/setup.c 2003-07-10 22:04:09.000000000 +0200 +++ linux-2.5.75-patch-topete/arch/sparc/kernel/setup.c 2003-08-20 09:42:21.000000000 +0200 @@ -262,6 +262,7 @@ if(!strcmp(&cputypval,"sun4d")) { sparc_cpu_model=sun4d; } if(!strcmp(&cputypval,"sun4e")) { sparc_cpu_model=sun4e; } if(!strcmp(&cputypval,"sun4u")) { sparc_cpu_model=sun4u; } + if(!strcmp(&cputypval,"leon@")) { sparc_cpu_model=sparc_leon; } #ifdef CONFIG_SUN4 if (sparc_cpu_model != sun4) { @@ -269,6 +270,12 @@ prom_halt(); } #endif +#ifdef CONFIG_LEON + if (sparc_cpu_model != sparc_leon) { + prom_printf("This kernel is for Leon architecture only.\n"); + prom_halt(); + } +#endif printk("ARCH: "); switch(sparc_cpu_model) { case sun4: @@ -289,6 +296,9 @@ case sun4u: printk("SUN4U\n"); break; + case sparc_leon: + printk("LEON\n"); + break; default: printk("UNKNOWN!\n"); break; @@ -299,6 +309,13 @@ #elif defined(CONFIG_PROM_CONSOLE) conswitchp = &prom_con; #endif +#if defined(CONFIG_PROM_CONSOLE) && defined(CONFIG_LEON) + /* Konrad : change again to prom_con */ + register_console(&prom_debug_console); + + //conswitchp = &prom_con; +#endif + boot_flags_init(*cmdline_p); idprom_init(); diff -urN linux-2.5.75/arch/sparc/kernel/sunos_asm.S linux-2.5.75-patch-topete/arch/sparc/kernel/sunos_asm.S --- linux-2.5.75/arch/sparc/kernel/sunos_asm.S 2003-07-10 22:06:01.000000000 +0200 +++ linux-2.5.75-patch-topete/arch/sparc/kernel/sunos_asm.S 2003-08-20 09:42:21.000000000 +0200 @@ -9,6 +9,7 @@ * Copyright (C) 1995 Adrian M. Rodriguez (adrian@remus.rutgers.edu) */ +#include #include #include diff -urN linux-2.5.75/arch/sparc/kernel/time.c linux-2.5.75-patch-topete/arch/sparc/kernel/time.c --- linux-2.5.75/arch/sparc/kernel/time.c 2003-07-10 22:10:54.000000000 +0200 +++ linux-2.5.75-patch-topete/arch/sparc/kernel/time.c 2003-08-20 12:45:15.000000000 +0200 @@ -306,6 +306,9 @@ case sun4d: node = prom_getchild(bootbus = prom_searchsiblings(prom_getchild(cpuunit = prom_searchsiblings(node, "cpu-unit")), "bootbus")); break; + case sparc_leon: + node = 0; + return; default: prom_printf("CLOCK: Unsupported architecture!\n"); prom_halt(); @@ -373,8 +376,10 @@ void __init sbus_time_init(void) { +#ifndef CONFIG_LEON unsigned int year, mon, day, hour, min, sec; struct mostek48t02 *mregs; +#endif #ifdef CONFIG_SUN4 int temp; @@ -391,6 +396,7 @@ sparc_init_timers(timer_interrupt); +#ifndef CONFIG_LEON #ifdef CONFIG_SUN4 if(idprom->id_machtype == (SM_SUN4 | SM_4_330)) { #endif @@ -447,7 +453,7 @@ printk("%u/%u/%u %u:%u:%u\n",day,mon,year,hour,min,sec); } #endif - +#endif /* Now that OBP ticker has been silenced, it is safe to enable IRQ. */ local_irq_enable(); } @@ -466,7 +472,12 @@ extern __inline__ unsigned long do_gettimeoffset(void) { + #ifdef CONFIG_LEON + return ((LEON_REGLOAD_PA(LEON_TRLD0)&LEON_TCNT0_MASK) - + (LEON_REGLOAD_PA(LEON_TCNT0)&LEON_TCNT0_MASK)) >> 2; + #else return (*master_l10_counter >> 10) & 0x1fffff; + #endif } /* Ok, my cute asm atomicity trick doesn't work anymore. diff -urN linux-2.5.75/arch/sparc/kernel/trampoline.S linux-2.5.75-patch-topete/arch/sparc/kernel/trampoline.S --- linux-2.5.75/arch/sparc/kernel/trampoline.S 2003-07-10 22:14:49.000000000 +0200 +++ linux-2.5.75-patch-topete/arch/sparc/kernel/trampoline.S 2003-08-20 09:42:21.000000000 +0200 @@ -5,6 +5,7 @@ * Copyright (C) 1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz) */ +#include #include #include #include diff -urN linux-2.5.75/arch/sparc/kernel/wof.S linux-2.5.75-patch-topete/arch/sparc/kernel/wof.S --- linux-2.5.75/arch/sparc/kernel/wof.S 2003-07-10 22:12:24.000000000 +0200 +++ linux-2.5.75-patch-topete/arch/sparc/kernel/wof.S 2003-08-20 09:42:21.000000000 +0200 @@ -4,6 +4,7 @@ * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) */ +#include #include #include #include @@ -166,7 +167,12 @@ * care of things at that point. */ .globl C_LABEL(spwin_mmu_patchme) -C_LABEL(spwin_mmu_patchme): b C_LABEL(spwin_sun4c_stackchk) +C_LABEL(spwin_mmu_patchme): +#ifdef CONFIG_LEON /* Leon-arch only: no btfixup */ + b C_LABEL(spwin_srmmu_stackchk) +#else + b C_LABEL(spwin_sun4c_stackchk) +#endif andcc %sp, 0x7, %g0 spwin_good_ustack: diff -urN linux-2.5.75/arch/sparc/kernel/wuf.S linux-2.5.75-patch-topete/arch/sparc/kernel/wuf.S --- linux-2.5.75/arch/sparc/kernel/wuf.S 2003-07-10 22:03:33.000000000 +0200 +++ linux-2.5.75-patch-topete/arch/sparc/kernel/wuf.S 2003-08-20 09:42:21.000000000 +0200 @@ -4,6 +4,7 @@ * Copyright (C) 1995 David S. Miller */ +#include #include #include #include @@ -137,7 +138,12 @@ * routine. They can be found below... */ .globl C_LABEL(fwin_mmu_patchme) -C_LABEL(fwin_mmu_patchme): b C_LABEL(sun4c_fwin_stackchk) +C_LABEL(fwin_mmu_patchme): +#ifdef CONFIG_LEON /* Leon-arch only: no btfixup */ + b C_LABEL(srmmu_fwin_stackchk) +#else + b C_LABEL(sun4c_fwin_stackchk) +#endif andcc %sp, 0x7, %g0 #define STACK_OFFSET (THREAD_SIZE - TRACEREG_SZ - STACKFRAME_SZ) diff -urN linux-2.5.75/arch/sparc/leon_tmp/bootloader.h linux-2.5.75-patch-topete/arch/sparc/leon_tmp/bootloader.h --- linux-2.5.75/arch/sparc/leon_tmp/bootloader.h 1970-01-01 01:00:00.000000000 +0100 +++ linux-2.5.75-patch-topete/arch/sparc/leon_tmp/bootloader.h 2003-08-20 09:42:21.000000000 +0200 @@ -0,0 +1,17 @@ +/* generated by bootloader.pl */ +#define BOOTLOADER_FREQ_KHZ 40000 +#define BOOTLOADER_SRAMSZ_KB 0 +#define BOOTLOADER_SDRAMSZ_MB 16 +#define BOOTLOADER_BAUD 38400 + +#define BOOTLOADER_memcfg1 0x28033 +#define BOOTLOADER_memcfg2 0x81006020 +#define BOOTLOADER_uart 0x83 +#define BOOTLOADER_loopback 0x0 +#define BOOTLOADER_ftreg 0x13b000 + +#define BOOTLOADER_freq 40500000 + +#define BOOTLOADER_ramsize 0x1000000 +#define BOOTLOADER_romsize 0x800000 +#define BOOTLOADER_stack 0x40ffffe0 diff -urN linux-2.5.75/arch/sparc/leon_tmp/defconfig linux-2.5.75-patch-topete/arch/sparc/leon_tmp/defconfig --- linux-2.5.75/arch/sparc/leon_tmp/defconfig 1970-01-01 01:00:00.000000000 +0100 +++ linux-2.5.75-patch-topete/arch/sparc/leon_tmp/defconfig 2003-08-20 11:06:39.000000000 +0200 @@ -0,0 +1,273 @@ +# +# Automatically generated make config: don't edit +# +CONFIG_MMU=y +CONFIG_UID16=y +CONFIG_HIGHMEM=y +CONFIG_GENERIC_ISA_DMA=y + +# +# Code maturity level options +# +# CONFIG_EXPERIMENTAL is not set + +# +# General setup +# +CONFIG_SWAP=y +CONFIG_SYSVIPC=y +CONFIG_BSD_PROCESS_ACCT=y +CONFIG_SYSCTL=y +CONFIG_LOG_BUF_SHIFT=14 +# CONFIG_EMBEDDED is not set +CONFIG_FUTEX=y +CONFIG_EPOLL=y + +# +# Loadable module support +# +# CONFIG_MODULES is not set + +# +# General setup +# +CONFIG_VT=y +CONFIG_VT_CONSOLE=y +CONFIG_HW_CONSOLE=y +# CONFIG_SMP is not set +CONFIG_SPARC32=y +CONFIG_SBUS=y +CONFIG_SBUSCHAR=y +CONFIG_SERIAL_CONSOLE=y +CONFIG_SUN_AUXIO=y +CONFIG_SUN_IO=y +CONFIG_RWSEM_GENERIC_SPINLOCK=y +CONFIG_SUN_PM=y +# CONFIG_SUN4 is not set +CONFIG_LEON=y +# CONFIG_PCI is not set +# CONFIG_SUN_OPENPROMFS is not set +CONFIG_KCORE_ELF=y +CONFIG_BINFMT_ELF=y +# CONFIG_BINFMT_MISC is not set +# CONFIG_SUNOS_EMUL is not set + +# +# Parallel port support +# +# CONFIG_PARPORT is not set + +# +# Generic Driver Options +# +# CONFIG_FW_LOADER is not set + +# +# Leon Kernel settings +# +CONFIG_RAMKERNEL=y +# CONFIG_ROMKERNEL is not set +# CONFIG_SDRAM is not set + +# +# Graphics support +# +# CONFIG_FB is not set + +# +# Console display driver support +# +# CONFIG_VGA_CONSOLE is not set +# CONFIG_MDA_CONSOLE is not set +CONFIG_PROM_CONSOLE=y +CONFIG_DUMMY_CONSOLE=y + +# +# Memory Technology Devices (MTD) +# +# CONFIG_MTD is not set + +# +# Serial drivers +# + +# +# Non-8250 serial port support +# +CONFIG_SERIAL_SUNCORE=y +# CONFIG_SERIAL_SUNZILOG is not set +CONFIG_SERIAL_CORE=y +CONFIG_SERIAL_CORE_CONSOLE=y +CONFIG_SERIAL_LEON=y +CONFIG_SERIAL_LEON_CONSOLE=y + +# +# Misc Linux/SPARC drivers +# +# CONFIG_SUN_OPENPROMIO is not set +# CONFIG_SUN_MOSTEK_RTC is not set + +# +# Block devices +# +# CONFIG_BLK_DEV_FD is not set +# CONFIG_BLK_DEV_LOOP is not set + +# +# Multi-device support (RAID and LVM) +# +# CONFIG_MD is not set +CONFIG_BLK_DEV_RAM=y +CONFIG_BLK_DEV_RAM_SIZE=4096 +CONFIG_BLK_DEV_INITRD=y + +# +# ISDN subsystem +# + +# +# SCSI device support +# +# CONFIG_SCSI is not set + +# +# Fibre Channel support +# +# CONFIG_FC4 is not set + +# +# Networking support +# +# CONFIG_NET is not set + +# +# Amateur Radio support +# +# CONFIG_HAMRADIO is not set + +# +# Unix98 PTY support +# +CONFIG_UNIX98_PTYS=y +CONFIG_UNIX98_PTY_COUNT=256 + +# +# Input device support +# +CONFIG_INPUT=y + +# +# Userland interfaces +# +# CONFIG_INPUT_MOUSEDEV is not set +# CONFIG_INPUT_JOYDEV is not set +# CONFIG_INPUT_TSDEV is not set +# CONFIG_INPUT_EVDEV is not set +# CONFIG_INPUT_EVBUG is not set + +# +# Input I/O drivers +# +# CONFIG_GAMEPORT is not set +CONFIG_SOUND_GAMEPORT=y +# CONFIG_SERIO is not set + +# +# Input Device Drivers +# +# CONFIG_INPUT_KEYBOARD is not set +# CONFIG_INPUT_MOUSE is not set +# CONFIG_INPUT_JOYSTICK is not set +# CONFIG_INPUT_TOUCHSCREEN is not set +# CONFIG_INPUT_MISC is not set + +# +# File systems +# +# CONFIG_EXT2_FS is not set +# CONFIG_EXT3_FS is not set +# CONFIG_JBD is not set +# CONFIG_REISERFS_FS is not set +# CONFIG_JFS_FS is not set +# CONFIG_XFS_FS is not set +# CONFIG_MINIX_FS is not set +CONFIG_ROMFS_FS=y +# CONFIG_QUOTA is not set +# CONFIG_AUTOFS_FS is not set +# CONFIG_AUTOFS4_FS is not set + +# +# CD-ROM/DVD Filesystems +# +# CONFIG_ISO9660_FS is not set +# CONFIG_UDF_FS is not set + +# +# DOS/FAT/NT Filesystems +# +# CONFIG_FAT_FS is not set +# CONFIG_NTFS_FS is not set + +# +# Pseudo filesystems +# +CONFIG_PROC_FS=y +CONFIG_DEVPTS_FS=y +# CONFIG_DEVPTS_FS_XATTR is not set +# CONFIG_TMPFS is not set +CONFIG_RAMFS=y + +# +# Miscellaneous filesystems +# +# CONFIG_CRAMFS is not set +# CONFIG_VXFS_FS is not set +# CONFIG_HPFS_FS is not set +# CONFIG_QNX4FS_FS is not set +# CONFIG_SYSV_FS is not set +# CONFIG_UFS_FS is not set + +# +# Partition Types +# +# CONFIG_PARTITION_ADVANCED is not set +CONFIG_MSDOS_PARTITION=y +CONFIG_SUN_PARTITION=y + +# +# Sound card support +# +# CONFIG_SOUND is not set + +# +# USB support +# + +# +# Watchdog +# +# CONFIG_SOFT_WATCHDOG is not set + +# +# Kernel hacking +# +# CONFIG_DEBUG_SLAB is not set +# CONFIG_MAGIC_SYSRQ is not set +# CONFIG_DEBUG_SPINLOCK is not set +# CONFIG_DEBUG_SPINLOCK_SLEEP is not set +# CONFIG_DEBUG_BUGVERBOSE is not set + +# +# Security options +# +# CONFIG_SECURITY is not set + +# +# Cryptographic options +# +# CONFIG_CRYPTO is not set + +# +# Library routines +# +# CONFIG_CRC32 is not set diff -urN linux-2.5.75/arch/sparc/leon_tmp/defconfig_net linux-2.5.75-patch-topete/arch/sparc/leon_tmp/defconfig_net --- linux-2.5.75/arch/sparc/leon_tmp/defconfig_net 1970-01-01 01:00:00.000000000 +0100 +++ linux-2.5.75-patch-topete/arch/sparc/leon_tmp/defconfig_net 2003-08-20 11:05:43.000000000 +0200 @@ -0,0 +1,372 @@ +# +# Automatically generated make config: don't edit +# +CONFIG_MMU=y +CONFIG_UID16=y +CONFIG_HIGHMEM=y +CONFIG_GENERIC_ISA_DMA=y + +# +# Code maturity level options +# +# CONFIG_EXPERIMENTAL is not set + +# +# General setup +# +CONFIG_SWAP=y +CONFIG_SYSVIPC=y +CONFIG_BSD_PROCESS_ACCT=y +CONFIG_SYSCTL=y +CONFIG_LOG_BUF_SHIFT=14 +# CONFIG_EMBEDDED is not set +CONFIG_FUTEX=y +CONFIG_EPOLL=y + +# +# Loadable module support +# +# CONFIG_MODULES is not set + +# +# General setup +# +CONFIG_VT=y +CONFIG_VT_CONSOLE=y +CONFIG_HW_CONSOLE=y +# CONFIG_SMP is not set +CONFIG_SPARC32=y +CONFIG_SBUS=y +CONFIG_SBUSCHAR=y +CONFIG_SERIAL_CONSOLE=y +CONFIG_SUN_AUXIO=y +CONFIG_SUN_IO=y +CONFIG_RWSEM_GENERIC_SPINLOCK=y +CONFIG_SUN_PM=y +# CONFIG_SUN4 is not set +CONFIG_LEON=y +# CONFIG_PCI is not set +# CONFIG_SUN_OPENPROMFS is not set +CONFIG_KCORE_ELF=y +CONFIG_BINFMT_ELF=y +# CONFIG_BINFMT_MISC is not set +# CONFIG_SUNOS_EMUL is not set + +# +# Parallel port support +# +# CONFIG_PARPORT is not set + +# +# Generic Driver Options +# +# CONFIG_FW_LOADER is not set + +# +# Leon Kernel settings +# +CONFIG_RAMKERNEL=y +# CONFIG_ROMKERNEL is not set +# CONFIG_SDRAM is not set + +# +# Graphics support +# +# CONFIG_FB is not set + +# +# Console display driver support +# +# CONFIG_VGA_CONSOLE is not set +# CONFIG_MDA_CONSOLE is not set +CONFIG_PROM_CONSOLE=y +CONFIG_DUMMY_CONSOLE=y + +# +# Memory Technology Devices (MTD) +# +# CONFIG_MTD is not set + +# +# Serial drivers +# + +# +# Non-8250 serial port support +# +CONFIG_SERIAL_SUNCORE=y +# CONFIG_SERIAL_SUNZILOG is not set +CONFIG_SERIAL_CORE=y +CONFIG_SERIAL_CORE_CONSOLE=y +CONFIG_SERIAL_LEON=y +CONFIG_SERIAL_LEON_CONSOLE=y + +# +# Misc Linux/SPARC drivers +# +# CONFIG_SUN_OPENPROMIO is not set +# CONFIG_SUN_MOSTEK_RTC is not set + +# +# Block devices +# +# CONFIG_BLK_DEV_FD is not set +# CONFIG_BLK_DEV_LOOP is not set +# CONFIG_BLK_DEV_NBD is not set + +# +# Multi-device support (RAID and LVM) +# +# CONFIG_MD is not set +CONFIG_BLK_DEV_RAM=y +CONFIG_BLK_DEV_RAM_SIZE=4096 +CONFIG_BLK_DEV_INITRD=y + +# +# ISDN subsystem +# +# CONFIG_ISDN_BOOL is not set + +# +# SCSI device support +# +# CONFIG_SCSI is not set + +# +# Fibre Channel support +# +# CONFIG_FC4 is not set + +# +# Networking support +# +CONFIG_NET=y + +# +# Networking options +# +CONFIG_PACKET=y +# CONFIG_PACKET_MMAP is not set +# CONFIG_NETLINK_DEV is not set +# CONFIG_NETFILTER is not set +CONFIG_UNIX=y +# CONFIG_NET_KEY is not set +CONFIG_INET=y +# CONFIG_IP_MULTICAST is not set +# CONFIG_IP_ADVANCED_ROUTER is not set +# CONFIG_IP_PNP is not set +# CONFIG_NET_IPIP is not set +# CONFIG_NET_IPGRE is not set +# CONFIG_INET_ECN is not set +# CONFIG_SYN_COOKIES is not set +# CONFIG_INET_AH is not set +# CONFIG_INET_ESP is not set +# CONFIG_INET_IPCOMP is not set +# CONFIG_XFRM_USER is not set +# CONFIG_VLAN_8021Q is not set +# CONFIG_LLC is not set +# CONFIG_DECNET is not set +# CONFIG_BRIDGE is not set + +# +# QoS and/or fair queueing +# +# CONFIG_NET_SCHED is not set + +# +# Network testing +# +# CONFIG_NET_PKTGEN is not set +CONFIG_NETDEVICES=y +# CONFIG_DUMMY is not set +# CONFIG_BONDING is not set +# CONFIG_EQUALIZER is not set +# CONFIG_TUN is not set + +# +# Ethernet (10 or 100Mbit) +# +CONFIG_NET_ETHERNET=y +# CONFIG_MII is not set +# CONFIG_SUNLANCE is not set +CONFIG_OPEN_ETH=y +# CONFIG_HAPPYMEAL is not set +# CONFIG_SUNQE is not set + +# +# Ethernet (1000 Mbit) +# +# CONFIG_MYRI_SBUS is not set + +# +# Ethernet (10000 Mbit) +# +# CONFIG_PPP is not set +# CONFIG_SLIP is not set + +# +# Wireless LAN (non-hamradio) +# +# CONFIG_NET_RADIO is not set + +# +# Token Ring devices (depends on LLC=y) +# + +# +# Wan interfaces +# +# CONFIG_WAN is not set + +# +# Amateur Radio support +# +# CONFIG_HAMRADIO is not set + +# +# Unix98 PTY support +# +CONFIG_UNIX98_PTYS=y +CONFIG_UNIX98_PTY_COUNT=256 + +# +# Input device support +# +CONFIG_INPUT=y + +# +# Userland interfaces +# +# CONFIG_INPUT_MOUSEDEV is not set +# CONFIG_INPUT_JOYDEV is not set +# CONFIG_INPUT_TSDEV is not set +# CONFIG_INPUT_EVDEV is not set +# CONFIG_INPUT_EVBUG is not set + +# +# Input I/O drivers +# +# CONFIG_GAMEPORT is not set +CONFIG_SOUND_GAMEPORT=y +# CONFIG_SERIO is not set + +# +# Input Device Drivers +# +# CONFIG_INPUT_KEYBOARD is not set +# CONFIG_INPUT_MOUSE is not set +# CONFIG_INPUT_JOYSTICK is not set +# CONFIG_INPUT_TOUCHSCREEN is not set +# CONFIG_INPUT_MISC is not set + +# +# File systems +# +# CONFIG_EXT2_FS is not set +# CONFIG_EXT3_FS is not set +# CONFIG_JBD is not set +# CONFIG_REISERFS_FS is not set +# CONFIG_JFS_FS is not set +# CONFIG_XFS_FS is not set +# CONFIG_MINIX_FS is not set +CONFIG_ROMFS_FS=y +# CONFIG_QUOTA is not set +# CONFIG_AUTOFS_FS is not set +# CONFIG_AUTOFS4_FS is not set + +# +# CD-ROM/DVD Filesystems +# +# CONFIG_ISO9660_FS is not set +# CONFIG_UDF_FS is not set + +# +# DOS/FAT/NT Filesystems +# +# CONFIG_FAT_FS is not set +# CONFIG_NTFS_FS is not set + +# +# Pseudo filesystems +# +CONFIG_PROC_FS=y +CONFIG_DEVPTS_FS=y +# CONFIG_DEVPTS_FS_XATTR is not set +# CONFIG_TMPFS is not set +CONFIG_RAMFS=y + +# +# Miscellaneous filesystems +# +# CONFIG_CRAMFS is not set +# CONFIG_VXFS_FS is not set +# CONFIG_HPFS_FS is not set +# CONFIG_QNX4FS_FS is not set +# CONFIG_SYSV_FS is not set +# CONFIG_UFS_FS is not set + +# +# Network File Systems +# +CONFIG_NFS_FS=y +CONFIG_NFS_V3=y +CONFIG_NFSD=y +CONFIG_NFSD_V3=y +CONFIG_LOCKD=y +CONFIG_LOCKD_V4=y +CONFIG_EXPORTFS=y +CONFIG_SUNRPC=y +# CONFIG_SMB_FS is not set +# CONFIG_CIFS is not set +# CONFIG_NCP_FS is not set +# CONFIG_CODA_FS is not set + +# +# Partition Types +# +# CONFIG_PARTITION_ADVANCED is not set +CONFIG_MSDOS_PARTITION=y +CONFIG_SUN_PARTITION=y + +# +# Sound card support +# +# CONFIG_SOUND is not set + +# +# USB support +# + +# +# Bluetooth support +# +# CONFIG_BT is not set + +# +# Watchdog +# +# CONFIG_SOFT_WATCHDOG is not set + +# +# Kernel hacking +# +# CONFIG_DEBUG_SLAB is not set +# CONFIG_MAGIC_SYSRQ is not set +# CONFIG_DEBUG_SPINLOCK is not set +# CONFIG_DEBUG_SPINLOCK_SLEEP is not set +# CONFIG_DEBUG_BUGVERBOSE is not set + +# +# Security options +# +# CONFIG_SECURITY is not set + +# +# Cryptographic options +# +# CONFIG_CRYPTO is not set + +# +# Library routines +# +# CONFIG_CRC32 is not set diff -urN linux-2.5.75/arch/sparc/lib/atomic.S linux-2.5.75-patch-topete/arch/sparc/lib/atomic.S --- linux-2.5.75/arch/sparc/lib/atomic.S 2003-07-10 22:11:01.000000000 +0200 +++ linux-2.5.75-patch-topete/arch/sparc/lib/atomic.S 2003-08-20 09:42:21.000000000 +0200 @@ -35,6 +35,10 @@ jmpl %o7 + 8, %g0 mov %g4, %o7 +#ifdef CONFIG_LEON /* no btfixup, direct jump from /system.h:xchg_u32()*/ + .globl ___f____xchg32 +___f____xchg32: +#endif .globl ___xchg32_sun4md ___xchg32_sun4md: swap [%g1], %g2 diff -urN linux-2.5.75/arch/sparc/mm/Makefile linux-2.5.75-patch-topete/arch/sparc/mm/Makefile --- linux-2.5.75/arch/sparc/mm/Makefile 2003-07-10 22:12:11.000000000 +0200 +++ linux-2.5.75-patch-topete/arch/sparc/mm/Makefile 2003-08-20 09:42:21.000000000 +0200 @@ -4,7 +4,11 @@ EXTRA_AFLAGS := -ansi -obj-y := fault.o init.o loadmmu.o generic.o extable.o btfixup.o +obj-y := fault.o init.o loadmmu.o generic.o extable.o + +ifneq ($(CONFIG_LEON),y) +obj-y += btfixup.o +endif ifeq ($(CONFIG_SUN4),y) obj-y += nosrmmu.o @@ -21,3 +25,7 @@ else obj-y += sun4c.o endif + +ifdef CONFIG_LEON +obj-y += leon.o leon_dbg.o leon_nobtfixup.o +endif \ No newline at end of file diff -urN linux-2.5.75/arch/sparc/mm/fault.c linux-2.5.75-patch-topete/arch/sparc/mm/fault.c --- linux-2.5.75/arch/sparc/mm/fault.c 2003-07-10 22:07:38.000000000 +0200 +++ linux-2.5.75-patch-topete/arch/sparc/mm/fault.c 2003-08-20 12:05:01.000000000 +0200 @@ -139,6 +139,11 @@ static void unhandled_fault(unsigned long address, struct task_struct *tsk, struct pt_regs *regs) { + #ifdef CONFIG_LEON + void leon_checkcache(void); + leon_checkcache(); + #endif + if((unsigned long) address < PAGE_SIZE) { printk(KERN_ALERT "Unable to handle kernel NULL pointer dereference\n"); diff -urN linux-2.5.75/arch/sparc/mm/init.c linux-2.5.75-patch-topete/arch/sparc/mm/init.c --- linux-2.5.75/arch/sparc/mm/init.c 2003-07-10 22:08:51.000000000 +0200 +++ linux-2.5.75-patch-topete/arch/sparc/mm/init.c 2003-08-20 09:42:21.000000000 +0200 @@ -134,7 +134,7 @@ unsigned long calc_max_low_pfn(void) { int i; - unsigned long tmp = (SRMMU_MAXMEM >> PAGE_SHIFT); + unsigned long tmp = ((phys_base + SRMMU_MAXMEM) >> PAGE_SHIFT); unsigned long curr_pfn, last_pfn; last_pfn = (sp_banks[0].base_addr + sp_banks[0].num_bytes) >> PAGE_SHIFT; @@ -190,7 +190,8 @@ start_pfn = (unsigned long)__pa(PAGE_ALIGN((unsigned long) &_end)); /* Adjust up to the physical address where the kernel begins. */ - start_pfn += phys_base; + //done by __pa + //start_pfn += phys_base; /* Now shift down to get the real physical page frame number. */ start_pfn >>= PAGE_SHIFT; @@ -202,7 +203,7 @@ max_low_pfn = max_pfn; highstart_pfn = highend_pfn = max_pfn; - if (max_low_pfn > (SRMMU_MAXMEM >> PAGE_SHIFT)) { + if (max_low_pfn > ((phys_base + SRMMU_MAXMEM) >> PAGE_SHIFT)) { highstart_pfn = (SRMMU_MAXMEM >> PAGE_SHIFT); max_low_pfn = calc_max_low_pfn(); printk(KERN_NOTICE "%ldMB HIGHMEM available.\n", calc_highpages()); @@ -266,8 +267,8 @@ reserve_bootmem(initrd_start, size); *pages_avail -= PAGE_ALIGN(size) >> PAGE_SHIFT; - initrd_start += PAGE_OFFSET; - initrd_end += PAGE_OFFSET; + initrd_start = (initrd_start - phys_base) + PAGE_OFFSET; + initrd_end = (initrd_end - phys_base) + PAGE_OFFSET; } #endif /* Reserve the kernel text/data/bss. */ @@ -324,6 +325,7 @@ break; case sun4m: case sun4d: + case sparc_leon: srmmu_paging_init(); sparc_unmapped_base = 0x50000000; BTFIXUPSET_SETHI(sparc_unmapped_base, 0x50000000); @@ -334,6 +336,13 @@ prom_printf("paging_init: Halting...\n"); prom_halt(); }; + +#ifdef CONFIG_LEON + if(sparc_leon == sparc_cpu_model) { + void leon_paging_init(void); + leon_paging_init(); + } +#endif /* Initialize the protection map with non-constant, MMU dependent values. */ protection_map[0] = PAGE_NONE; @@ -465,7 +474,7 @@ unsigned long page; struct page *p; - page = addr + phys_base; + page = addr; // + phys_base; p = virt_to_page(page); ClearPageReserved(p); diff -urN linux-2.5.75/arch/sparc/mm/leon.c linux-2.5.75-patch-topete/arch/sparc/mm/leon.c --- linux-2.5.75/arch/sparc/mm/leon.c 1970-01-01 01:00:00.000000000 +0100 +++ linux-2.5.75-patch-topete/arch/sparc/mm/leon.c 2003-08-20 09:42:21.000000000 +0200 @@ -0,0 +1,153 @@ +/* Konrad Eisele , 2003: arch/sparc/leon/mm/leon.c */ + +#include +#include +#include +#include + +//##################################################### +static __inline__ void cache_flushall(void) { + + __asm__ __volatile__("sta %%g0, [%%g0] %0\n\t": : + "i" (ASI_LEON_IFLUSH) : "memory"); + __asm__ __volatile__("sta %%g0, [%%g0] %0\n\t": : + "i" (ASI_LEON_DFLUSH) : "memory"); + + //srmmu_flush_whole_tlb(); +} + +void leon_flush_cache_all (void) {cache_flushall();} +void leon_flush_cache_mm (struct mm_struct *p1) {cache_flushall();} +void leon_flush_cache_range (struct vm_area_struct *vma, unsigned long p2, unsigned long p3) {cache_flushall();} +void leon_flush_cache_page (struct vm_area_struct *vma, unsigned long p2) {cache_flushall();} +void leon_flush_sig_insns (struct mm_struct *p1, unsigned long p2) { cache_flushall(); } +void leon_flush_page_for_dma(unsigned long p1) { cache_flushall(); } + +void leon_flush_page_to_ram(unsigned long virt_addr) { + + //for now make flush for the whole cache: + cache_flushall(); + /* + __asm__ __volatile__("sta %%g0, [%%g0] %0\n\t": : + "i" (ASI_LEON_FLUSH_PAGE), + "r" (virt_addr) : "memory"); + */ +} + +//##################################################### +void leon_flush_tlb_all (void) { cache_flushall();srmmu_flush_whole_tlb();} +void leon_flush_tlb_mm (struct mm_struct * p1) {cache_flushall();srmmu_flush_whole_tlb();} +void leon_flush_tlb_page (struct vm_area_struct *p1, unsigned long p2) {cache_flushall();srmmu_flush_whole_tlb();} +void leon_flush_tlb_range (struct vm_area_struct *vma, unsigned long p2, unsigned long p3) {cache_flushall();srmmu_flush_whole_tlb();} + +//##################################################### + +#define PFN(x) ((x) >> PAGE_SHIFT) +#define PADDR(x) ((x) << PAGE_SHIFT) +extern unsigned long last_valid_pfn; +/* max_mapnr not initilized yet */ +#define _pfn_valid(pfn) ((pfn < last_valid_pfn) && (pfn >= PFN(phys_base))) + +unsigned long srmmu_swprobe_ctx(unsigned long ctx, unsigned long vaddr, unsigned long *paddr) { + + unsigned long ctxtbl; + unsigned long pgd,pmd,ped; + unsigned long ptr; + unsigned long lvl, pte, paddrbase; + + //vaddr &= PAGE_MASK; + paddrbase = 0; + + if (!(ctxtbl = srmmu_get_ctable_ptr())) + return 0; + if (!_pfn_valid(PFN(ctxtbl))) + return 0; + //ctx = srmmu_get_context(); + pgd = LEON_GETPADDR(ctxtbl+(ctx*4)); + + if (((pgd&SRMMU_ET_MASK) == SRMMU_ET_PTE)) { + lvl = 3; + pte = pgd; + paddrbase = pgd & SRMMU_PTE_PMASK; + goto ready; + } + if (((pgd&SRMMU_ET_MASK) != SRMMU_ET_PTD)) + return 0; + + ptr = (pgd & SRMMU_PTD_PMASK) << 4; + ptr += (((vaddr & 0xff000000)>>24)*4); + if (!_pfn_valid(PFN(ptr))) + return 0; + + pmd = LEON_GETPADDR(ptr); + if (((pmd&SRMMU_ET_MASK) == SRMMU_ET_PTE)) { + lvl = 2; + pte = pmd; + paddrbase = pmd & SRMMU_PTE_PMASK; + goto ready; + } + if (((pmd&SRMMU_ET_MASK) != SRMMU_ET_PTD)) + return 0; + + ptr = (pmd & SRMMU_PTD_PMASK) << 4; + ptr += (((vaddr & 0x00fc0000)>>18)*4); + if (!_pfn_valid(PFN(ptr))) + return 0; + + ped = LEON_GETPADDR(ptr); + if (((ped&SRMMU_ET_MASK) == SRMMU_ET_PTE)) { + lvl = 1; + pte = ped; + paddrbase = ped & SRMMU_PTE_PMASK; + goto ready; + } + if (((ped&SRMMU_ET_MASK) != SRMMU_ET_PTD)) + return 0; + + ptr = (ped & SRMMU_PTD_PMASK) << 4; + ptr += (((vaddr & 0x0003f000)>>12)*4); + if (!_pfn_valid(PFN(ptr))) + return 0; + + ptr = LEON_GETPADDR(ptr); + if (((ptr&SRMMU_ET_MASK) == SRMMU_ET_PTE)) { + lvl = 0; + pte = ptr; + paddrbase = ptr & SRMMU_PTE_PMASK; + goto ready; + } + return 0; + +ready: + if (paddr) { + switch (lvl) { + case 0: *paddr = (vaddr & 0x00000fff) | ((pte&~0xff)<<4); break; + case 1: *paddr = (vaddr & 0x0003ffff) | ((pte&~0xff)<<4); break; + case 2: *paddr = (vaddr & 0x00ffffff) | ((pte&~0xff)<<4); break; + default: + case 3: *paddr = vaddr; break; + } + } + return paddrbase; +} + +unsigned long srmmu_swprobe(unsigned long vaddr, unsigned long *paddr) { + return srmmu_swprobe_ctx(srmmu_get_context(), vaddr, paddr); +} + + +void srmmu_allocate_ptable_skeleton(unsigned long start, unsigned long end); +void __init leon_paging_init(void) { + +#ifdef CONFIG_LEON +#ifdef CONFIG_OPEN_ETH + /* until I rewrite driver/net/open_eth.c to access ethermac core's registers with asi BYPASS*/ + /* using sun's DVMA_VADDR range */ + srmmu_allocate_ptable_skeleton(DVMA_VADDR, DVMA_END); + sparc_mapiorange (0,0xb0000000,LEON_VA_ETHERMAC/*LEON_VA_ETHERMAC*/, PAGE_SIZE); +#endif +#endif + +} + + diff -urN linux-2.5.75/arch/sparc/mm/leon_dbg.c linux-2.5.75-patch-topete/arch/sparc/mm/leon_dbg.c --- linux-2.5.75/arch/sparc/mm/leon_dbg.c 1970-01-01 01:00:00.000000000 +0100 +++ linux-2.5.75-patch-topete/arch/sparc/mm/leon_dbg.c 2003-08-20 10:37:25.000000000 +0200 @@ -0,0 +1,449 @@ +/* Konrad Eisele , 2003: arch/sparc/leon/mm/leon.c */ + +#include +#include +#include +#include +#include +#include + +//p1 is physical address +void leon_doshow_tlb(unsigned long *p1) { + unsigned long i, v1, v2, v3, v4, pa, ptep, ptebase; + + printk("using pa:%8x as buffer\n ",(unsigned int)p1); + + for (i = 0;i < LEON_MMUTLB_ENT_MAX;i++) { + // do bypass so no flush is needed + v1 = LEON_GETPADDR(p1+0); + v2 = LEON_GETPADDR(p1+1); + v3 = LEON_GETPADDR(p1+2); + v4 = LEON_GETPADDR(p1+3); + p1 += 4; + //if (v1 == 0 && v2 == 0 && v3 == 0 && v4 == 0) + // break; + + ptep = (v2 & SRMMU_PTE_PMASK) << 4; + prom_printf ("%2d:0x%8x@0x%8x(lvl:%d wr:%d hit:%d ctx:%3d valid:%d) %8x=>%8x", + (unsigned int)i, (unsigned int)v2,(unsigned int)v1, + (unsigned int)(v3&LEON_DIAGF_LVL) , + (unsigned int)((v3&LEON_DIAGF_WR) >> LEON_DIAGF_WR_SHIEFT) , + (unsigned int)((v3&LEON_DIAGF_HIT) >> LEON_DIAGF_HIT_SHIEFT), + (unsigned int)((v3&LEON_DIAGF_CTX) >> LEON_DIAGF_CTX_SHIEFT), + (unsigned int)((v3&LEON_DIAGF_VALID) >> LEON_DIAGF_VALID_SHIEFT), + (unsigned int)v4,(unsigned int) ptep); + + if (v3 & LEON_DIAGF_VALID) { + if ((ptebase = srmmu_swprobe((unsigned long)v4,&pa)) != 0) { + if (pa == ptep) { + prom_printf (" < checked"); + } + } + } + printk ("\n"); + } +} + +#define PFN(x) ((x) >> PAGE_SHIFT) +#define PADDR(x) ((x) << PAGE_SHIFT) +extern unsigned long last_valid_pfn; +/* max_mapnr not initilized yet */ +#define _pfn_valid(pfn) ((pfn < last_valid_pfn) && (pfn >= PFN(phys_base))) +#define PRINTVADDR(i,j,k) prom_printf("0x%08x", ( (((i)==-1?0:i)<<24) & 0xff000000) | \ + ((((j)==-1?0:j)<<18) & 0x00fc0000) | \ + ((((k)==-1?0:k)<<12) & 0x0003f000)); \ + i == -1 ? prom_printf("(---)") : prom_printf("(%03d)",i);\ + j == -1 ? prom_printf("(--)") : prom_printf("(%02d)",j);\ + k == -1 ? prom_printf("(--)") : prom_printf("(%02d)",k); + +unsigned long leon_dumppth(unsigned long ctx) { + + unsigned long ctxtbl; + unsigned long pgd,pmd,ped; + unsigned long ptr; + unsigned long pte, paddrbase; + unsigned long flags,i,j,k; + + local_irq_save(flags); + + //vaddr &= PAGE_MASK; + paddrbase = 0; + + if (!(ctxtbl = srmmu_get_ctable_ptr())) + return 0; + if (!_pfn_valid(PFN(ctxtbl))) { + return 0; + } + + prom_printf("Page table hirarchy:\n"); + + pgd = LEON_GETPADDR(ctxtbl+(ctx*4)); + + /* **** pgd **** */ + if (((pgd&SRMMU_ET_MASK) == SRMMU_ET_PTE)) { + prom_printf("ctx %d: PGD mapping 0-0xffffffff",ctx); + } + else { + if (((pgd&SRMMU_ET_MASK) != SRMMU_ET_PTD)) { + prom_printf("ctx %d: PGD invalid\n",ctx); + } + else { + prom_printf("PGD@%x:\n",(pgd & SRMMU_PTD_PMASK) << 4); + for (i = 0; i < SRMMU_PTRS_PER_PGD; i++) { + + ptr = (pgd & SRMMU_PTD_PMASK) << 4; + ptr += i*4; + if (!_pfn_valid(PFN(ptr))) { + prom_printf("!ctx %d: PGD pointer corrupt",ctx); + } + else { + pmd = LEON_GETPADDR(ptr); + /* **** pmd **** */ + if (((pmd&SRMMU_ET_MASK) == SRMMU_ET_PTE)) { + prom_printf("-# "); + PRINTVADDR(i,-1,-1) + prom_printf(": pte %08x\n",pmd); + } + else if (((pmd&SRMMU_ET_MASK) != SRMMU_ET_PTD)) { + unsigned long i_f = i; + for (; i < SRMMU_PTRS_PER_PGD; i++) { + ptr = (pgd & SRMMU_PTD_PMASK) << 4; + ptr += i*4; + if (!_pfn_valid(PFN(ptr)) || + (((LEON_GETPADDR(ptr) &SRMMU_ET_MASK) == SRMMU_ET_PTD) || + ((LEON_GETPADDR(ptr) &SRMMU_ET_MASK) == SRMMU_ET_PTE))) { + break; + } + } + prom_printf("-# "); + PRINTVADDR(i_f,-1,-1); + if (i_f != (i-1)) { + prom_printf("-"); + PRINTVADDR(i-1,-1,-1); } + prom_printf(": inv\n"); + i--; + } + else { + prom_printf("-# "); + PRINTVADDR(i,-1,-1); + prom_printf(" PMD@%x:\n",(pmd & SRMMU_PTD_PMASK) << 4); + + for (j = 0; j < SRMMU_PTRS_PER_PMD; j++) { + + ptr = (pmd & SRMMU_PTD_PMASK) << 4; + ptr += j*4; + if (!_pfn_valid(PFN(ptr))) { + prom_printf(" %d!PED of PMD@%x pointer corrupt\n",ptr); + } + else { + ped = LEON_GETPADDR(ptr); + /* **** ped **** */ + if (((ped&SRMMU_ET_MASK) == SRMMU_ET_PTE)) { + prom_printf("--# "); + PRINTVADDR(i,j,-1) + prom_printf(": pte %08x\n",j,ped); + } + else if (((ped&SRMMU_ET_MASK) != SRMMU_ET_PTD)) { + unsigned long jf = j; + for (; j < SRMMU_PTRS_PER_PMD; j++) { + ptr = (pmd & SRMMU_PTD_PMASK) << 4; + ptr += j*4; + if (!_pfn_valid(PFN(ptr)) || + (((LEON_GETPADDR(ptr) &SRMMU_ET_MASK) == SRMMU_ET_PTD) || + ((LEON_GETPADDR(ptr) &SRMMU_ET_MASK) == SRMMU_ET_PTE))) { + break; + } + } + prom_printf("--# "); + PRINTVADDR(i,jf,-1); + if (jf != (j-1)) { + prom_printf("-"); + PRINTVADDR(i,j-1,-1); + } + prom_printf(": inv\n"); + j--; + } + else { + prom_printf("--# "); + PRINTVADDR(i,j,-1); + prom_printf("PED@%x:\n",(ped & SRMMU_PTD_PMASK) << 4); + + for (k = 0; k < SRMMU_PTRS_PER_PTE; k++) { + + ptr = (ped & SRMMU_PTD_PMASK) << 4; + ptr += k*4; + if (!_pfn_valid(PFN(ptr))) { + prom_printf(" %d!PET of PED@%x pointer corrupt\n",k,ptr); + } + else { + pte = LEON_GETPADDR(ptr); + /* **** ped **** */ + if (((pte&SRMMU_ET_MASK) == SRMMU_ET_PTE)) { + prom_printf("---#"); + PRINTVADDR(i,j,k) + prom_printf(": pte %08x\n",pte); + } + else if (((pte&SRMMU_ET_MASK) != SRMMU_ET_PTD)) { + unsigned long kf = k; + for (;k < SRMMU_PTRS_PER_PTE; k++) { + ptr = (ped & SRMMU_PTD_PMASK) << 4; + ptr += k*4; + if (!_pfn_valid(PFN(ptr)) || + (((LEON_GETPADDR(ptr) &SRMMU_ET_MASK) == SRMMU_ET_PTD) || + ((LEON_GETPADDR(ptr) &SRMMU_ET_MASK) == SRMMU_ET_PTE))) { + break; + } + } + prom_printf("---#"); + PRINTVADDR(i,j,kf); + if (kf != (k-1)) { + prom_printf("-"); + PRINTVADDR(i,j,k-1); + } + prom_printf(": inv\n"); + k--; + } + } + } + } + } + } + } + } + } + } + } + + local_irq_restore(flags); + return 0; +} + + +int leonconf, dsetsize, isetsize; +int dsetbits, isetbits; +int DSETS, DTAGLOW, DTAGAMSK, ITAGAMSK, ITAGLOW; + +#define CCTRL_IFP (1<<15) +#define CCTRL_DFP (1<<14) + +#define DDIAGMSK ((1<> 15) & 3; + DLINEBITS = ((leonconf >> 10) & 3); + ITAG_BITS = ((leonconf >> 17) & 7) + 8 - ILINEBITS; + DTAG_BITS = ((leonconf >> 12) & 7) + 8 - DLINEBITS; + isetsize = (1<<((leonconf >> 17) & 7)) * 1024; + dsetsize = (1<<((leonconf >> 12) & 7)) * 1024; + isetbits = ((leonconf >> 17) & 7) + 10; + dsetbits = ((leonconf >> 12) & 7) + 10; + ITAGS = (1 << ITAG_BITS); + ILINESZ = (1 << ILINEBITS); + DTAGS = (1 << DTAG_BITS); + DLINESZ = (1 << DLINEBITS); + IVALMSK = (1 << ILINESZ)-1; + DVALMSK = (1 << DLINESZ)-1; + ITAGAMSK = ~((1 << (ITAG_BITS + ILINEBITS +2)) - 1); + DTAGAMSK = ~((1 << (DTAG_BITS + DLINEBITS +2)) - 1); + ISETS = ((oldccr >> 26) & 3) + 1; + DSETS = ((oldccr >> 24) & 3) + 1; + + DTAGLOW = 10 + ((leonconf >> 12) & 7); + ITAGLOW = 10 + ((leonconf >> 17) & 7); + + prom_printf("Check dcache consistency (sets:%d sz:%x linesz:%d)\n",DSETS,(1<%03d+%08x (v:%02x):",j,ctx,vaddr,valid); + for (k = 0;k> 15) & 3; + DLINEBITS = ((leonconf >> 10) & 3); + ITAG_BITS = ((leonconf >> 17) & 7) + 8 - ILINEBITS; + DTAG_BITS = ((leonconf >> 12) & 7) + 8 - DLINEBITS; + isetsize = (1<<((leonconf >> 17) & 7)) * 1024; + dsetsize = (1<<((leonconf >> 12) & 7)) * 1024; + isetbits = ((leonconf >> 17) & 7) + 10; + dsetbits = ((leonconf >> 12) & 7) + 10; + ITAGS = (1 << ITAG_BITS); + ILINESZ = (1 << ILINEBITS); + DTAGS = (1 << DTAG_BITS); + DLINESZ = (1 << DLINEBITS); + IVALMSK = (1 << ILINESZ)-1; + DVALMSK = (1 << DLINESZ)-1; + ITAGAMSK = ~((1 << (ITAG_BITS + ILINEBITS +2)) - 1); + DTAGAMSK = ~((1 << (DTAG_BITS + DLINEBITS +2)) - 1); + ISETS = ((oldccr >> 26) & 3) + 1; + DSETS = ((oldccr >> 24) & 3) + 1; + + DTAGLOW = 10 + ((leonconf >> 12) & 7); + ITAGLOW = 10 + ((leonconf >> 17) & 7); + + + + prom_printf("Check dcache consistency (sets:%d sz:%x linesz:%d)\n",DSETS,(1<, 2003: arch/sparc/leon/mm/leon_nobtfixup.c */ + +#include + +#define SPARC_FIXBTFIXUP_LEON_DODECLARE +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* in /mm/srmmu.c */ +BTFIXUPDEF_CALL(void, flush_page_for_dma, unsigned long) +#define flush_page_for_dma(page) BTFIXUP_CALL(flush_page_for_dma)(page) + +#ifdef CONFIG_SMP +BTFIXUPDEF_CALL(void, local_flush_page_for_dma, unsigned long) +#define local_flush_page_for_dma(page) BTFIXUP_CALL(local_flush_page_for_dma)(page) +#endif + +/* in /mm/sun4c */ +BTFIXUPDEF_CALL(void, sun4c_flush_page, unsigned long) +BTFIXUPDEF_CALL(void, sun4c_flush_segment, unsigned long) +BTFIXUPDEF_CALL(void, sun4c_flush_context, void) + +#define sun4c_flush_page(addr) BTFIXUP_CALL(sun4c_flush_page)(addr) +#define sun4c_flush_segment(addr) BTFIXUP_CALL(sun4c_flush_segment)(addr) +#define sun4c_flush_context() BTFIXUP_CALL(sun4c_flush_context)() + diff -urN linux-2.5.75/arch/sparc/mm/loadmmu.c linux-2.5.75-patch-topete/arch/sparc/mm/loadmmu.c --- linux-2.5.75/arch/sparc/mm/loadmmu.c 2003-07-10 22:11:34.000000000 +0200 +++ linux-2.5.75-patch-topete/arch/sparc/mm/loadmmu.c 2003-08-20 09:42:21.000000000 +0200 @@ -36,6 +36,7 @@ break; case sun4m: case sun4d: + case sparc_leon: ld_mmu_srmmu(); break; default: diff -urN linux-2.5.75/arch/sparc/mm/srmmu.c linux-2.5.75-patch-topete/arch/sparc/mm/srmmu.c --- linux-2.5.75/arch/sparc/mm/srmmu.c 2003-07-10 22:10:55.000000000 +0200 +++ linux-2.5.75-patch-topete/arch/sparc/mm/srmmu.c 2003-08-20 10:26:29.000000000 +0200 @@ -240,7 +240,7 @@ * and a page entry and page directory to the page they refer to. */ static pte_t srmmu_mk_pte(struct page *page, pgprot_t pgprot) -{ return __pte(((page - mem_map) << (PAGE_SHIFT-4)) | pgprot_val(pgprot)); } +{ return __pte((page_to_pfn(page) << (PAGE_SHIFT-4)) | pgprot_val(pgprot)); } static pte_t srmmu_mk_pte_phys(unsigned long page, pgprot_t pgprot) { return __pte(((page) >> 4) | pgprot_val(pgprot)); } @@ -272,7 +272,7 @@ unsigned long ptp; /* Physical address, shifted right by 4 */ int i; - ptp = (ptep - mem_map) << (PAGE_SHIFT-4); /* watch for overflow */ + ptp = page_to_pfn(ptep) << (PAGE_SHIFT-4); /* watch for overflow */ for (i = 0; i < SRMMU_PTRS_PER_PTE_SOFT/SRMMU_PTRS_PER_PTE; i++) { srmmu_set_pte((pte_t *)&pmdp->pmdv[i], SRMMU_ET_PTD | ptp); ptp += (SRMMU_PTRS_PER_PTE*sizeof(pte_t) >> 4); @@ -401,7 +401,13 @@ /* P3 XXX The 4x overuse: corroborated by /proc/meminfo. */ // if (srmmu_nocache_npages < 256) srmmu_nocache_npages = 256; - if (srmmu_nocache_npages < 550) srmmu_nocache_npages = 550; + if (srmmu_nocache_npages < 550) { +#ifndef CONFIG_LEON + srmmu_nocache_npages = 550; +#else + srmmu_nocache_npages = 64; //32 +#endif + } /* anything above 1280 blows up */ if (srmmu_nocache_npages > 1280) srmmu_nocache_npages = 1280; @@ -440,8 +446,8 @@ paddr = __pa((unsigned long)srmmu_nocache_pool); vaddr = SRMMU_NOCACHE_VADDR; -/* P3 */ printk("srmmu: pool 0x%x vaddr 0x%x bitmap 0x%x bits %d (0x%x)\n", - (int)srmmu_nocache_pool, vaddr, srmmu_nocache_bitmap, bitmap_bits, bitmap_bits); +/* P3 */ printk("srmmu: pool 0x%x vaddr 0x%x-0x%x bitmap 0x%x bits %d (0x%x)\n", + (int)srmmu_nocache_pool, (int)vaddr, (int)srmmu_nocache_end, (int)srmmu_nocache_bitmap, (int)bitmap_bits, (int)bitmap_bits); while (vaddr < srmmu_nocache_end) { pgd = pgd_offset_k(vaddr); @@ -454,7 +460,7 @@ pteval |= SRMMU_CACHE; srmmu_set_pte(__nocache_fix(pte), pteval); - + vaddr += PAGE_SIZE; paddr += PAGE_SIZE; } @@ -514,7 +520,7 @@ if ((pte = (unsigned long)srmmu_pte_alloc_one_kernel(mm, address)) == 0) return NULL; - return mem_map + (__nocache_pa(pte) >> PAGE_SHIFT); + return pfn_to_page( __nocache_pa(pte) >> PAGE_SHIFT ); } static void srmmu_free_pte_fast(pte_t *pte) @@ -529,7 +535,7 @@ p = (unsigned long)page_address(pte); /* Cached address (for test) */ if (p == 0) BUG(); - p = ((pte - mem_map) << PAGE_SHIFT); /* Physical address */ + p = page_to_pfn(pte) << PAGE_SHIFT; /* Physical address */ p = (unsigned long) __nocache_va(p); /* Nocached virtual */ srmmu_free_nocache(p, SRMMU_PTE_SZ_SOFT); } @@ -585,6 +591,19 @@ if (is_hypersparc) hyper_flush_whole_icache(); +#ifdef CONFIG_LEON + + /* patch Konrad remove */ + //flush_tlb_mm(0); + //__asm__ __volatile__("sta %%g0, [%%g0] %0\n\t": : + // "i" (ASI_LEON_IFLUSH) : "memory"); + __asm__ __volatile__("sta %%g0, [%%g0] %0\n\t": : + "i" (ASI_LEON_DFLUSH) : "memory"); + + //void leon_checkcache(void); + //leon_checkcache(); +#endif + srmmu_set_context(mm->context); } @@ -1070,7 +1089,7 @@ pmdp = (pmd_t *) __srmmu_get_nocache( SRMMU_PMD_TABLE_SIZE, SRMMU_PMD_TABLE_SIZE); if (pmdp == NULL) - early_pgtable_allocfail("pmd"); + early_pgtable_allocfail("pmd_1"); memset(__nocache_fix(pmdp), 0, SRMMU_PMD_TABLE_SIZE); srmmu_pgd_set(__nocache_fix(pgdp), pmdp); } @@ -1079,7 +1098,7 @@ ptep = (pte_t *)__srmmu_get_nocache(SRMMU_PTE_SZ_SOFT, SRMMU_PTE_SZ_SOFT); if (ptep == NULL) - early_pgtable_allocfail("pte"); + early_pgtable_allocfail("pte_1"); memset(__nocache_fix(ptep), 0, SRMMU_PTE_SZ_SOFT); srmmu_pmd_set(__nocache_fix(pmdp), ptep); } @@ -1098,7 +1117,7 @@ if(srmmu_pgd_none(*pgdp)) { pmdp = (pmd_t *)__srmmu_get_nocache(SRMMU_PMD_TABLE_SIZE, SRMMU_PMD_TABLE_SIZE); if (pmdp == NULL) - early_pgtable_allocfail("pmd"); + early_pgtable_allocfail("pmd_2"); memset(pmdp, 0, SRMMU_PMD_TABLE_SIZE); srmmu_pgd_set(pgdp, pmdp); } @@ -1106,8 +1125,11 @@ if(srmmu_pmd_none(*pmdp)) { ptep = (pte_t *) __srmmu_get_nocache(SRMMU_PTE_SZ_SOFT, SRMMU_PTE_SZ_SOFT); - if (ptep == NULL) - early_pgtable_allocfail("pte"); + if (ptep == NULL) { + prom_printf("Cannot alloc kernel %x-%x.\n", start, end); + early_pgtable_allocfail("pte_2"); + + } memset(ptep, 0, SRMMU_PTE_SZ_SOFT); srmmu_pmd_set(pmdp, ptep); } @@ -1120,6 +1142,11 @@ * looking at the prom's page table directly which is what most * other OS's do. Yuck... this is much better. */ +#ifdef CONFIG_LEON +unsigned long srmmu_swprobe(unsigned long vaddr,unsigned long *paddr); +#define srmmu_hwprobe(a) srmmu_swprobe(a,0) +#endif + void __init srmmu_inherit_prom_mappings(unsigned long start,unsigned long end) { pgd_t *pgdp; @@ -1161,7 +1188,7 @@ if(srmmu_pgd_none(*(pgd_t *)__nocache_fix(pgdp))) { pmdp = (pmd_t *)__srmmu_get_nocache(SRMMU_PMD_TABLE_SIZE, SRMMU_PMD_TABLE_SIZE); if (pmdp == NULL) - early_pgtable_allocfail("pmd"); + early_pgtable_allocfail("pmd_3"); memset(__nocache_fix(pmdp), 0, SRMMU_PMD_TABLE_SIZE); srmmu_pgd_set(__nocache_fix(pgdp), pmdp); } @@ -1170,7 +1197,7 @@ ptep = (pte_t *) __srmmu_get_nocache(SRMMU_PTE_SZ_SOFT, SRMMU_PTE_SZ_SOFT); if (ptep == NULL) - early_pgtable_allocfail("pte"); + early_pgtable_allocfail("pte_3"); memset(__nocache_fix(ptep), 0, SRMMU_PTE_SZ_SOFT); srmmu_pmd_set(__nocache_fix(pmdp), ptep); } @@ -1193,6 +1220,7 @@ } #define KERNEL_PTE(page_shifted) ((page_shifted)|SRMMU_CACHE|SRMMU_PRIV|SRMMU_VALID) +//#define KERNEL_PTE(page_shifted) ((page_shifted)|SRMMU_PRIV|SRMMU_VALID) /* Create a third-level SRMMU 16MB page mapping. */ static void __init do_large_mapping(unsigned long vaddr, unsigned long phys_base) @@ -1354,8 +1382,8 @@ } /* P3: easy to fix, todo. Current code is utterly broken, though. */ - if (phys_base != 0) - panic("phys_base nonzero"); + //if (phys_base != 0) + // panic("phys_base nonzero"); } static void srmmu_mmu_info(struct seq_file *m) @@ -1935,6 +1963,57 @@ #endif } +#ifdef CONFIG_LEON + + +void leon_flush_cache_all (void); +void leon_flush_cache_mm (struct mm_struct *p1); +void leon_flush_cache_range (struct vm_area_struct *vma, unsigned long p2, unsigned long p3); +void leon_flush_cache_page (struct vm_area_struct *vma, unsigned long p2); +void leon_flush_sig_insns (struct mm_struct *p1, unsigned long p2); +void leon_flush_page_for_dma(unsigned long p1); +void leon_flush_page_to_ram(unsigned long virt_addr); + +void leon_flush_tlb_all (void); +void leon_flush_tlb_mm (struct mm_struct * p1); +void leon_flush_tlb_page (struct vm_area_struct *p1, unsigned long p2); +void leon_flush_tlb_range (struct vm_area_struct *vma, unsigned long p2, unsigned long p3); + +static void __init poke_leonsparc(void) { +} + +static void __init init_leon(void) { + + BTFIXUPSET_CALL(flush_cache_all, leon_flush_cache_all, BTFIXUPCALL_NORM); + BTFIXUPSET_CALL(flush_cache_mm, leon_flush_cache_mm, BTFIXUPCALL_NORM); + BTFIXUPSET_CALL(flush_cache_page, leon_flush_cache_page, BTFIXUPCALL_NORM); + BTFIXUPSET_CALL(flush_cache_range, leon_flush_cache_range, BTFIXUPCALL_NORM); + BTFIXUPSET_CALL(flush_page_for_dma, leon_flush_page_for_dma, BTFIXUPCALL_NORM); + +#ifdef CONFIG_SMP + if (sparc_cpu_model == sun4d) { + BTFIXUPSET_CALL(flush_tlb_all, leonsmp_flush_tlb_all, BTFIXUPCALL_NORM); + BTFIXUPSET_CALL(flush_tlb_mm, leonsmp_flush_tlb_mm, BTFIXUPCALL_NORM); + BTFIXUPSET_CALL(flush_tlb_page, leonsmp_flush_tlb_page, BTFIXUPCALL_NORM); + BTFIXUPSET_CALL(flush_tlb_range, leonsmp_flush_tlb_range, BTFIXUPCALL_NORM); + } else +#endif + { + BTFIXUPSET_CALL(flush_tlb_all, leon_flush_tlb_all, BTFIXUPCALL_NORM); + BTFIXUPSET_CALL(flush_tlb_mm, leon_flush_tlb_mm, BTFIXUPCALL_NORM); + BTFIXUPSET_CALL(flush_tlb_page, leon_flush_tlb_page, BTFIXUPCALL_NORM); + BTFIXUPSET_CALL(flush_tlb_range, leon_flush_tlb_range, BTFIXUPCALL_NORM); + } + + BTFIXUPSET_CALL(__flush_page_to_ram, leon_flush_page_to_ram, BTFIXUPCALL_NOP); + BTFIXUPSET_CALL(flush_sig_insns, leon_flush_sig_insns, BTFIXUPCALL_NOP); + + poke_srmmu = poke_leonsparc; + + srmmu_cache_pagetables = 0; +} +#endif + static void __init init_viking(void) { unsigned long mreg = srmmu_get_mmureg(); @@ -2010,6 +2089,12 @@ psr_typ = (psr >> 28) & 0xf; psr_vers = (psr >> 24) & 0xf; + /* Leon's psr is undefined (0?) so I do a ifdef: Leon-sparc processor */ +#ifdef CONFIG_LEON + init_leon(); + return; +#endif + /* First, check for HyperSparc or Cypress. */ if(mod_typ == 1) { switch(mod_rev) { @@ -2085,7 +2170,8 @@ init_tsunami(); return; } - + + /* Oh well */ srmmu_is_bad(); } @@ -2110,9 +2196,10 @@ } while(0) static void __init patch_window_trap_handlers(void) -{ +{ +#ifndef CONFIG_LEON unsigned long *iaddr, *daddr; - + PATCH_BRANCH(spwin_mmu_patchme, spwin_srmmu_stackchk); PATCH_BRANCH(fwin_mmu_patchme, srmmu_fwin_stackchk); PATCH_BRANCH(tsetup_mmu_patchme, tsetup_srmmu_stackchk); @@ -2120,6 +2207,7 @@ PATCH_BRANCH(sparc_ttable[SP_TRAP_TFLT].inst_three, srmmu_fault); PATCH_BRANCH(sparc_ttable[SP_TRAP_DFLT].inst_three, srmmu_fault); PATCH_BRANCH(sparc_ttable[SP_TRAP_DACC].inst_three, srmmu_fault); +#endif } #ifdef CONFIG_SMP diff -urN linux-2.5.75/arch/sparc/prom/Makefile linux-2.5.75-patch-topete/arch/sparc/prom/Makefile --- linux-2.5.75/arch/sparc/prom/Makefile 2003-07-10 22:08:51.000000000 +0200 +++ linux-2.5.75-patch-topete/arch/sparc/prom/Makefile 2003-08-20 09:45:04.000000000 +0200 @@ -7,3 +7,4 @@ palloc.o ranges.o segment.o console.o printf.o tree.o lib-$(CONFIG_SUN4) += sun4prom.o +lib-$(CONFIG_LEON) += leonprom.o diff -urN linux-2.5.75/arch/sparc/prom/init.c linux-2.5.75-patch-topete/arch/sparc/prom/init.c --- linux-2.5.75/arch/sparc/prom/init.c 2003-07-10 22:04:03.000000000 +0200 +++ linux-2.5.75-patch-topete/arch/sparc/prom/init.c 2003-08-20 09:42:21.000000000 +0200 @@ -13,6 +13,9 @@ #include #include #include +#ifdef CONFIG_LEON +#include +#endif struct linux_romvec *romvec; enum prom_major_version prom_vers; @@ -41,6 +44,10 @@ extern struct linux_romvec *sun4_prom_init(void); rp = sun4_prom_init(); #endif +#ifdef CONFIG_LEON + extern struct linux_romvec *leon_prom_init(struct leon_setup *bv); + rp = leon_prom_init((struct leon_setup *)rp); +#endif romvec = rp; switch(romvec->pv_romvers) { diff -urN linux-2.5.75/arch/sparc/prom/leonprom.c linux-2.5.75-patch-topete/arch/sparc/prom/leonprom.c --- linux-2.5.75/arch/sparc/prom/leonprom.c 1970-01-01 01:00:00.000000000 +0100 +++ linux-2.5.75-patch-topete/arch/sparc/prom/leonprom.c 2003-08-20 11:19:45.000000000 +0200 @@ -0,0 +1,291 @@ +/* + * Copyright (C) 1996 The Australian National University. + * Copyright (C) 1996 Fujitsu Laboratories Limited + * Copyright (C) 1997 Michael A. Griffith (grif@acm.org) + * Copyright (C) 1997 Sun Weenie (ko@ko.reno.nv.us) + * Copyright (C) 1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz) + * + * This software may be distributed under the terms of the Gnu + * Public License version 2 or later + * + * fake a really simple Sun prom for the SUN4 + * fake it for Leon too. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define BARGV_MAX 32 +struct leon_setup leon_setup_vector; +static struct linux_romvec leonromvec; +static struct idprom leon_idprom; +static int leon_nctx; +static struct linux_romvec leonromvec; + +static struct linux_arguments_v0 bargv0 __initdata; +static struct linux_arguments_v0 *bargv0p __initdata; + +struct property { + char *name; + char *value; + int length; +}; + +struct node { + int level; + struct property *properties; +}; + +struct property null_properties = { NULL, NULL, -1 }; + +struct property root_properties[] = { + {"device_type", "cpu", 4}, + {"idprom", (char *)&leon_idprom, sizeof(struct idprom)}, + {NULL, NULL, -1} +}; +struct property cpu_properties[] = { + {"device_type", "cpu", 4}, + {"mmu-nctx", (char *)&leon_nctx, 4}, + {NULL, NULL, -1} +}; + +struct node nodes[] = { + { 0, &null_properties }, + { 0, root_properties }, + { 1, cpu_properties }, + { -1,&null_properties } +}; + + +static int no_nextnode(int node) +{ + if (nodes[node].level == nodes[node+1].level) + return node+1; + return -1; +} + +static int no_child(int node) +{ + if (nodes[node].level == nodes[node+1].level-1) + return node+1; + return -1; +} + +static struct property *find_property(int node,char *name) +{ + struct property *prop = &nodes[node].properties[0]; + while (prop && prop->name) { + if (strcmp(prop->name,name) == 0) return prop; + prop++; + } + return NULL; +} + +static int no_proplen(int node,char *name) +{ + struct property *prop = find_property(node,name); + if (prop) return prop->length; + return -1; +} + +static int no_getprop(int node,char *name,char *value) +{ + struct property *prop = find_property(node,name); + if (prop) { + memcpy(value,prop->value,prop->length); + return 1; + } + return -1; +} + +static int no_setprop(int node,char *name,char *value,int len) +{ + return -1; +} + +static char *no_nextprop(int node,char *name) +{ + struct property *prop = find_property(node,name); + if (prop) return prop[1].name; + return NULL; +} + +static struct linux_nodeops leon_nodeops = { + no_nextnode, + no_child, + no_proplen, + no_getprop, + no_setprop, + no_nextprop +}; + +static int synch_hook; + +static int baud_rates[] = { + 1200 , + 2400 , + 4800 , + 9600 , + 19200 , + 38400 , + 57600 , + 115200 , + 230400 , + 460800 , + 921600 , + 0 +}; + +/* from arch/sparc/kernel/setup.c */ +#define RAMDISK_LOAD_FLAG 0x4000 +extern unsigned short root_flags; +extern unsigned short root_dev; +extern unsigned short ram_flags; +extern unsigned int sparc_ramdisk_image; +extern unsigned int sparc_ramdisk_size; +extern int root_mountflags; +void leon_reboot(char *bcommand); +void leon_halt(void); +int leon_nbputchar(int c); +int leon_nbgetchar(void); +struct linux_romvec * __init leon_prom_init(struct leon_setup *bv) +{ + unsigned long i,j; + unsigned char cksum, *ptr; + + /* complete leon_setup struct */ + leon_setup_vector.memctrl1 = LEON_REGLOAD_PA(LEON_MCFG1); + leon_setup_vector.memctrl2 = LEON_REGLOAD_PA(LEON_MCFG2); + // the frequency is actually detected using (LEON_REGLOAD_PA(LEON_SRLD)+1) * 1000 * 1000; + // assuming that bootloader or the dsumon has set up LEON_SRLD, so that timer ticks on 1mhz + leon_setup_vector.freq_kh = bv ->freq_kh; + leon_setup_vector.uart_baud[0] = bv ->uart_baud[0]; + leon_setup_vector.uart_baud[1] = bv ->uart_baud[1]; + i = (leon_setup_vector.memctrl2 & LEON_MCFG2_SRAMBANKSZ) >> LEON_MCFG2_SRAMBANKSZ_SHIEFT; + leon_setup_vector.sram_kb = 8 << i; /* starting from 8 k */ + if ((LEON_MCFG2_SRAMDIS & leon_setup_vector.memctrl2)) + leon_setup_vector.sram_kb = 0; + i = (leon_setup_vector.memctrl2 & LEON_MCFG2_SDRAMBANKSZ) >> LEON_MCFG2_SDRAMBANKSZ_SHIEFT; + leon_setup_vector.sdram_mb = 4 << i; /* starting from 4 mb */ + if (!(LEON_MCFG2_SDRAMEN & leon_setup_vector.memctrl2)) + leon_setup_vector.sdram_mb = 0; + + /* retrive baudrate */ + for (j = 0;j < 2;j++) + if (leon_setup_vector.uart_baud[j]) { + for (i = 0;baud_rates[i]; i++) + if (baud_rates[i] >= leon_setup_vector.uart_baud[j]) { + break; + } + if (!(leon_setup_vector.uart_baud[j] = baud_rates[i])) + leon_setup_vector.uart_baud[j] = 921600; + } + + printk("Extracted hardware params:\n"); + printk("sram : %i kb\n",(int)leon_setup_vector.sram_kb); + printk("sdram : %i mb\n",(int)leon_setup_vector.sdram_mb); + printk("uart0_baud : %i baud\n",(int)leon_setup_vector.uart_baud[0]); + printk("uart1_baud : %i baud\n",(int)leon_setup_vector.uart_baud[1]); + + if (leon_setup_vector.sram_kb != 0 && leon_setup_vector.sdram_mb != 0) { + printk ("Only eather sram or sdram is supported. No DISCONTIGMEM yet.\n"); + BUG(); + } + + /* idprom */ + memset(&leon_idprom,0,sizeof(leon_idprom)); + leon_idprom.id_format = 1; + leon_idprom.id_machtype = M_LEON2 | M_LEON2_SOC; + ptr = (unsigned char *)&leon_idprom; + for (i = cksum = 0; i <= 0x0E; i++) + cksum ^= *ptr++; + leon_idprom.id_cksum = cksum; + + /* init sun4 like linux_romvec */ + memset(&leonromvec,0,sizeof(leonromvec)); + leonromvec.pv_romvers = 40; /* same version id as sun4 */ + leonromvec.pv_nodeops = &leon_nodeops; + leonromvec.pv_reboot = leon_reboot; + leonromvec.pv_halt = leon_halt; + leonromvec.pv_nbputchar = leon_nbputchar; + leonromvec.pv_nbgetchar = leon_nbgetchar; + leonromvec.pv_synchook = (void (**)(void))&synch_hook; + + /* building kernel args */ + leonromvec.pv_v0bootargs = &bargv0p; + bargv0p = &bargv0; + memset(&bargv0,0,sizeof(bargv0)); + bargv0.argv[1] = &(bv->args[0]); + + /* init number of contexts in prom node */ + leon_nctx = 256; + + /* boot options */ + + root_dev = bv ->root_dev; + root_flags = 0x0800 | RAMDISK_LOAD_FLAG; + root_mountflags |= bv ->root_mountflags_or; + if (bv ->initrd_start) { + sparc_ramdisk_image = bv ->initrd_start; + sparc_ramdisk_size = bv ->initrd_size; + } + + printk("PROMLIB: Leon emulation\n"); + + return &leonromvec; +} + +static spinlock_t con_lock = SPIN_LOCK_UNLOCKED; + +/* Reset and reboot the machine with the command 'bcommand'. */ +void leon_reboot(char *bcommand) +{ + unsigned long flags; + spin_lock_irqsave(&con_lock, flags); + while (1) { printk("Can't reboot\n"); }; + spin_unlock_irqrestore(&con_lock, flags); +} + +/* Drop into the prom, but completely terminate the program. + * No chance of continuing. + */ +void leon_halt(void) +{ + unsigned long flags; + spin_lock_irqsave(&con_lock, flags); + while (1) { printk("Halt\n"); }; + spin_unlock_irqrestore(&con_lock, flags); +} + +/* put single char, don't care for blocking*/ +int leon_nbgetchar(void) { + BUG(); + return -1; +} + +/* put single char, don't care for blocking*/ +int leon_nbputchar(int c) { + + unsigned int old_cr; + old_cr = LEON_REGLOAD_PA(LEON_UCTRL0); + LEON_REGSTORE_PA(LEON_UCTRL0,(old_cr & ~(LEON_UCTRL_TI)) | (LEON_UCTRL_TE)); + + while (!(LEON_REGLOAD_PA(LEON_USTAT0) & 0x4)); + LEON_REGSTORE_PA(LEON_UDATA0, (unsigned char)c); + + while (!(LEON_REGLOAD_PA(LEON_USTAT0) & 0x4)); + LEON_REGSTORE_PA(LEON_UCTRL0,old_cr); + return 0; +} + diff -urN linux-2.5.75/arch/sparc/prom/memory.c linux-2.5.75-patch-topete/arch/sparc/prom/memory.c --- linux-2.5.75/arch/sparc/prom/memory.c 2003-07-10 22:15:41.000000000 +0200 +++ linux-2.5.75-patch-topete/arch/sparc/prom/memory.c 2003-08-20 11:21:13.000000000 +0200 @@ -13,6 +13,9 @@ #include #include #include +#ifdef CONFIG_LEON +#include +#endif /* This routine, for consistency, returns the ram parameters in the * V0 prom memory descriptor format. I choose this format because I @@ -192,6 +195,18 @@ prom_phys_avail[0].num_bytes = *(sun4_romvec->memoryavail); prom_phys_avail[0].theres_more = 0x0; #endif +#ifdef CONFIG_LEON + /* how simple :) */ + prom_phys_total[0].start_adr = (char *)(LEONSETUP_MEM_BASEADDR); + prom_phys_total[0].num_bytes = LEONSETUP_MEM_SZAVAIL_KB * 1024; + prom_phys_total[0].theres_more = 0x0; + prom_prom_taken[0].start_adr = 0x0; + prom_prom_taken[0].num_bytes = 0x0; + prom_prom_taken[0].theres_more = 0x0; + prom_phys_avail[0].start_adr = (char *)LEONSETUP_MEM_BASEADDR; + prom_phys_avail[0].num_bytes = LEONSETUP_MEM_SZAVAIL_KB * 1024; + prom_phys_avail[0].theres_more = 0x0; +#endif break; default: diff -urN linux-2.5.75/include/asm-sparc/asi.h linux-2.5.75-patch-topete/include/asm-sparc/asi.h --- linux-2.5.75/include/asm-sparc/asi.h 2003-07-10 22:08:54.000000000 +0200 +++ linux-2.5.75-patch-topete/include/asm-sparc/asi.h 2003-08-20 09:42:21.000000000 +0200 @@ -108,4 +108,20 @@ #define ASI_M_ACTION 0x4c /* Breakpoint Action Register (GNU/Viking) */ +/* Leon ASI definitions */ +#ifdef CONFIG_LEON +#include +#undef ASI_M_FLUSH_PROBE +#undef ASI_M_MMUREGS +#undef ASI_M_FLUSH_PAGE +#undef ASI_M_FLUSH_CTX +#undef ASI_M_BYPASS + +#define ASI_M_FLUSH_PROBE ASI_LEON_MMUFLUSH /* Reference MMU Flush/Probe; rw, ss */ +#define ASI_M_MMUREGS ASI_LEON_MMUREGS /* MMU Registers; rw, ss */ +#define ASI_M_FLUSH_PAGE ASI_LEON_FLUSH_PAGE /* Flush I Cache Line (page); wo, ss */ +#define ASI_M_FLUSH_CTX ASI_LEON_FLUSH_CTX /* Flush I Cache Line (context); wo, ss */ +#define ASI_M_BYPASS ASI_LEON_BYPASS /* Reference MMU bypass; rw, as */ +#endif /* CONFIG_LEON */ + #endif /* _SPARC_ASI_H */ diff -urN linux-2.5.75/include/asm-sparc/btfixup.h linux-2.5.75-patch-topete/include/asm-sparc/btfixup.h --- linux-2.5.75/include/asm-sparc/btfixup.h 2003-07-10 22:08:59.000000000 +0200 +++ linux-2.5.75-patch-topete/include/asm-sparc/btfixup.h 2003-08-20 09:42:21.000000000 +0200 @@ -11,6 +11,10 @@ #ifndef __ASSEMBLY__ +#ifdef CONFIG_LEON /* CONFIG_LEON: no btfixup */ +#include +#else /* CONFIG_LEON */ + #ifdef MODULE extern unsigned int ___illegal_use_of_BTFIXUP_SIMM13_in_module(void); extern unsigned int ___illegal_use_of_BTFIXUP_SETHI_in_module(void); @@ -195,6 +199,8 @@ #define BTFIXUPVAL_CALL(__name) \ ((unsigned long)___fs_##__name[1]) + +#endif /* !CONFIG_LEON */ extern void btfixup(void); diff -urN linux-2.5.75/include/asm-sparc/fixbtfixup_leon.h linux-2.5.75-patch-topete/include/asm-sparc/fixbtfixup_leon.h --- linux-2.5.75/include/asm-sparc/fixbtfixup_leon.h 1970-01-01 01:00:00.000000000 +0100 +++ linux-2.5.75-patch-topete/include/asm-sparc/fixbtfixup_leon.h 2003-08-20 11:15:52.000000000 +0200 @@ -0,0 +1,78 @@ +// Konrad Eisele, 2003: include/asm/fixbtfixup.h +// When CONFIG_LEON is enabled then no btfixup is used. + +#ifndef _SPARC_FIXBTFIXUP_LEON_H +#define _SPARC_FIXBTFIXUP_LEON_H + +#ifdef SPARC_FIXBTFIXUP_LEON_DODECLARE +#define dd_extern +#else +#define dd_extern extern +#endif + +/* ****** Fixup call xx */ +#define BTFIXUPDEF_CALL(__type, __name, __args...) \ + dd_extern __type (*nobtfixup_##__name)(__args); +#define BTFIXUPDEF_CALL_CONST(__type, __name, __args...) \ + dd_extern __type (*nobtfixup_##__name)(__args); //__attribute__((const)); +#define BTFIXUP_CALL(__name) nobtfixup_##__name + +/* ****** blackbox */ +#define BTFIXUPDEF_BLACKBOX(__name) +#define BTFIXUP_BLACKBOX(__name) nobtfixup_##__name + +/* ****** Put bottom 13bits into some register variable */ +#define BTFIXUPDEF_SIMM13(__name) \ + dd_extern unsigned long nobtfixup_##__name; +#define BTFIXUPDEF_SIMM13_INIT(__name,__val) \ + dd_extern unsigned long nobtfixup_##__name; +#define BTFIXUP_SIMM13(__name) nobtfixup_##__name + +/* ****** Put either bottom 13 bits, or upper 22 bits into some register variable + * (depending on the value, this will lead into sethi FIX, reg; or + * mov FIX, reg; ) */ +#define BTFIXUPDEF_HALF(__name) \ + dd_extern unsigned long nobtfixup_##__name; +#define BTFIXUPDEF_HALF_INIT(__name,__val) \ + dd_extern unsigned long nobtfixup_##__name; +#define BTFIXUP_HALF(__name) nobtfixup_##__name + +/* ****** Put upper 22 bits into some register variable */ +#define BTFIXUPDEF_SETHI(__name) \ + dd_extern unsigned long nobtfixup_##__name; +#define BTFIXUPDEF_SETHI_INIT(__name,__val) \ + dd_extern unsigned long nobtfixup_##__name; +#define BTFIXUP_SETHI(__name) nobtfixup_##__name + +/* ****** Put a full 32bit integer into some register variable */ +#define BTFIXUPDEF_INT(__name) \ + dd_extern unsigned long nobtfixup_##__name; +#define BTFIXUP_INT(__name) nobtfixup_##__name + + +#define BTFIXUPCALL_NORM 0x00000000 /* Always call */ +#define BTFIXUPCALL_NOP 0x01000000 /* Possibly optimize to nop */ +#define BTFIXUPCALL_RETINT(i) (0x90102000|((i) & 0x1fff)) /* Possibly optimize to mov i, %o0 */ +#define BTFIXUPCALL_ORINT(i) (0x90122000|((i) & 0x1fff)) /* Possibly optimize to or %o0, i, %o0 */ +#define BTFIXUPCALL_RETO0 0x01000000 /* Return first parameter, actually a nop */ +#define BTFIXUPCALL_ANDNINT(i) (0x902a2000|((i) & 0x1fff)) /* Possibly optimize to andn %o0, i, %o0 */ +#define BTFIXUPCALL_SWAPO0O1 0xd27a0000 /* Possibly optimize to swap [%o0],%o1 */ +#define BTFIXUPCALL_SWAPO0G0 0xc07a0000 /* Possibly optimize to swap [%o0],%g0 */ +#define BTFIXUPCALL_SWAPG1G2 0xc4784000 /* Possibly optimize to swap [%g1],%g2 */ +#define BTFIXUPCALL_STG0O0 0xc0220000 /* Possibly optimize to st %g0,[%o0] */ +#define BTFIXUPCALL_STO1O0 0xd2220000 /* Possibly optimize to st %o1,[%o0] */ + +#define BTFIXUPSET_CALL(__name, __addr, __insn) nobtfixup_##__name = __addr; +#define BTFIXUPSET_BLACKBOX(__name, __func) BUG(); +#define BTFIXUPCOPY_CALL(__name, __from) nobtfixup_##__name = nobtfixup_##__from; +#define BTFIXUPSET_SIMM13(__name, __val) nobtfixup_##__name = __val; +#define BTFIXUPCOPY_SIMM13(__name, __from) nobtfixup_##__name = nobtfixup_##__from; +#define BTFIXUPSET_HALF(__name, __val) nobtfixup_##__name = __val; +#define BTFIXUPCOPY_HALF(__name, __from) nobtfixup_##__name = nobtfixup_##__from; +#define BTFIXUPSET_SETHI(__name, __val) nobtfixup_##__name = __val; +#define BTFIXUPCOPY_SETHI(__name, __from) nobtfixup_##__name = nobtfixup_##__from; +#define BTFIXUPSET_INT(__name, __val) nobtfixup_##__name = __val; +#define BTFIXUPCOPY_INT(__name, __from) nobtfixup_##__name = nobtfixup_##__from; +#define BTFIXUPVAL_CALL(__name) NULL + +#endif /* !(_SPARC_BTFIXUP_LEON_H) */ diff -urN linux-2.5.75/include/asm-sparc/head.h linux-2.5.75-patch-topete/include/asm-sparc/head.h --- linux-2.5.75/include/asm-sparc/head.h 2003-07-10 22:08:27.000000000 +0200 +++ linux-2.5.75-patch-topete/include/asm-sparc/head.h 2003-08-20 09:42:21.000000000 +0200 @@ -20,10 +20,15 @@ rd %psr, %l0; b label; rd %wim, %l3; nop; /* Data/text faults. Defaults to sun4c version at boot time. */ -#define SPARC_TFAULT rd %psr, %l0; rd %wim, %l3; b sun4c_fault; mov 1, %l7; -#define SPARC_DFAULT rd %psr, %l0; rd %wim, %l3; b sun4c_fault; mov 0, %l7; #define SRMMU_TFAULT rd %psr, %l0; rd %wim, %l3; b C_LABEL(srmmu_fault); mov 1, %l7; #define SRMMU_DFAULT rd %psr, %l0; rd %wim, %l3; b C_LABEL(srmmu_fault); mov 0, %l7; +#ifndef CONFIG_LEON + #define SPARC_TFAULT rd %psr, %l0; rd %wim, %l3; b sun4c_fault; mov 1, %l7; + #define SPARC_DFAULT rd %psr, %l0; rd %wim, %l3; b sun4c_fault; mov 0, %l7; +#else + #define SPARC_TFAULT SRMMU_TFAULT + #define SPARC_DFAULT SRMMU_DFAULT +#endif /* This is for traps we should NEVER get. */ #define BAD_TRAP(num) \ diff -urN linux-2.5.75/include/asm-sparc/leon.h linux-2.5.75-patch-topete/include/asm-sparc/leon.h --- linux-2.5.75/include/asm-sparc/leon.h 1970-01-01 01:00:00.000000000 +0100 +++ linux-2.5.75-patch-topete/include/asm-sparc/leon.h 2003-08-20 09:42:21.000000000 +0200 @@ -0,0 +1,322 @@ +/* Konrad Eisele, 2003: include/asm/leon.h */ + +#ifndef LEON_H_INCLUDE +#define LEON_H_INCLUDE + +#include +#include + +#ifndef __ASSEMBLER__ +struct lregs { + volatile unsigned int memcfg1; /* 0x00 */ + volatile unsigned int memcfg2; + volatile unsigned int ectrl; + volatile unsigned int failaddr; + volatile unsigned int memstatus; /* 0x10 */ + volatile unsigned int cachectrl; + volatile unsigned int powerdown; + volatile unsigned int writeprot1; + volatile unsigned int writeprot2; /* 0x20 */ + volatile unsigned int leonconf; + volatile unsigned int dummy2; + volatile unsigned int dummy3; + volatile unsigned int dummy4; /* 0x30 */ + volatile unsigned int dummy5; + volatile unsigned int dummy6; + volatile unsigned int dummy7; + volatile unsigned int timercnt1; /* 0x40 */ + volatile unsigned int timerload1; + volatile unsigned int timerctrl1; + volatile unsigned int wdog; + volatile unsigned int timercnt2; + volatile unsigned int timerload2; + volatile unsigned int timerctrl2; + volatile unsigned int dummy8; + volatile unsigned int scalercnt; + volatile unsigned int scalerload; + volatile unsigned int dummy9; + volatile unsigned int dummy10; + volatile unsigned int uartdata1; + volatile unsigned int uartstatus1; + volatile unsigned int uartctrl1; + volatile unsigned int uartscaler1; + volatile unsigned int uartdata2; + volatile unsigned int uartstatus2; + volatile unsigned int uartctrl2; + volatile unsigned int uartscaler2; + volatile unsigned int irqmask; + volatile unsigned int irqpend; + volatile unsigned int irqforce; + volatile unsigned int irqclear; + volatile unsigned int piodata; + volatile unsigned int piodir; + volatile unsigned int pioirq; + volatile unsigned int dummy11; + volatile unsigned int imask2; + volatile unsigned int ipend2; + volatile unsigned int istat2; + volatile unsigned int dummy12; + volatile unsigned int dcomdata; + volatile unsigned int dcomstatus; + volatile unsigned int dcomctrl; + volatile unsigned int dcomscaler; +}; +#endif + +/* control registers, check out the LEON manual at gaisler.com for details*/ +#define LEON_PREGS 0x80000000 +#define LEON_MCFG1 0x00 +#define LEON_MCFG2 0x04 +#define LEON_ECTRL 0x08 +#define LEON_FADDR 0x0c +#define LEON_MSTAT 0x10 +#define LEON_CCTRL 0x14 +#define LEON_PWDOWN 0x18 +#define LEON_WPROT1 0x1C +#define LEON_WPROT2 0x20 +#define LEON_LCONF 0x24 +#define LEON_TCNT0 0x40 +#define LEON_TRLD0 0x44 +#define LEON_TCTRL0 0x48 +#define LEON_TCNT1 0x50 +#define LEON_TRLD1 0x54 +#define LEON_TCTRL1 0x58 +#define LEON_SCNT 0x60 +#define LEON_SRLD 0x64 +#define LEON_UART0 0x70 +#define LEON_UDATA0 0x70 +#define LEON_USTAT0 0x74 +#define LEON_UCTRL0 0x78 +#define LEON_USCAL0 0x7c +#define LEON_UART1 0x80 +#define LEON_UDATA1 0x80 +#define LEON_USTAT1 0x84 +#define LEON_UCTRL1 0x88 +#define LEON_USCAL1 0x8c +#define LEON_IMASK 0x90 +#define LEON_IPEND 0x94 +#define LEON_IFORCE 0x98 +#define LEON_ICLEAR 0x9c +#define LEON_IOREG 0xA0 +#define LEON_IODIR 0xA4 +#define LEON_IOICONF 0xA8 +#define LEON_IPEND2 0xB0 +#define LEON_IMASK2 0xB4 +#define LEON_ISTAT2 0xB8 +#define LEON_ICLEAR2 0xBC + +/* ASI codes */ +#define ASI_LEON_PCI 0x4 +#define ASI_LEON_IFLUSH 0x5 +#define ASI_LEON_DFLUSH 0x6 +#define ASI_LEON_ITAG 0xC +#define ASI_LEON_IDATA 0xD +#define ASI_LEON_DTAG 0xE +#define ASI_LEON_DDATA 0xF +#define ASI_LEON_MMUFLUSH 0x18 +#define ASI_LEON_MMUREGS 0x19 +#define ASI_LEON_BYPASS 0x1c +#define ASI_LEON_FLUSH_PAGE 0x10 +//#define ASI_LEON_FLUSH_SEGMENT 0x11 +//#define ASI_LEON_FLUSH_REGION 0x12 +#define ASI_LEON_FLUSH_CTX 0x13 +//#define ASI_LEON_FLUSH_USER 0x14 +#define ASI_MMU_DIAG 0x1d + +#define ASI_LEON_DCTX 0x14 +#define ASI_LEON_ICTX 0x15 + + + +/* mmu register access, ASI_LEON_MMUREGS */ +#define LEON_CNR_CTRL 0x000 /*000*/ +#define LEON_CNR_CTXP 0x100 /*001*/ +#define LEON_CNR_CTX 0x200 /*010*/ +#define LEON_CNR_F 0x300 /*011*/ +#define LEON_CNR_FADDR 0x400 /*100*/ + +#define LEON_CNR_CTX_NCTX 256 /* number of MMU ctx*/ + +#define LEON_CNR_CTRL_TLBDIS 0x80000000 + +#define LEON_MMUTLB_ENT_MAX 64 + +//diagnostic acces from mmutlb.vhd: +//0: pte address +//4: pte +//8: additional flags +#define LEON_DIAGF_LVL 0x3 +#define LEON_DIAGF_WR 0x8 +#define LEON_DIAGF_WR_SHIEFT 3 +#define LEON_DIAGF_HIT 0x10 +#define LEON_DIAGF_HIT_SHIEFT 4 +#define LEON_DIAGF_CTX 0x1fe0 +#define LEON_DIAGF_CTX_SHIEFT 5 +#define LEON_DIAGF_VALID 0x2000 +#define LEON_DIAGF_VALID_SHIEFT 13 + + +/* + * Interrupt Sources + * + * The interrupt source numbers directly map to the trap type and to + * the bits used in the Interrupt Clear, Interrupt Force, Interrupt Mask, + * and the Interrupt Pending Registers. + */ +#define LEON_INTERRUPT_CORRECTABLE_MEMORY_ERROR 1 +#define LEON_INTERRUPT_UART_1_RX_TX 2 +#define LEON_INTERRUPT_UART_0_RX_TX 3 +#define LEON_INTERRUPT_EXTERNAL_0 4 +#define LEON_INTERRUPT_EXTERNAL_1 5 +#define LEON_INTERRUPT_EXTERNAL_2 6 +#define LEON_INTERRUPT_EXTERNAL_3 7 +#define LEON_INTERRUPT_TIMER1 8 +#define LEON_INTERRUPT_TIMER2 9 +#define LEON_INTERRUPT_EMPTY1 10 +#define LEON_INTERRUPT_EMPTY2 11 +#define LEON_INTERRUPT_OPEN_ETH 12 +#define LEON_INTERRUPT_EMPTY4 13 +#define LEON_INTERRUPT_EMPTY5 14 +#define LEON_INTERRUPT_EMPTY6 15 + +/* irq masks */ +#define LEON_HARD_INT(x) (0x000000001 << (x)) /* irq 0-15 */ +#define LEON_IRQMASK_R 0x0000fffe /* bit 15- 1 of lregs.irqmask */ +#define LEON_IRQPRIO_R 0xfffe0000 /* bit 31-17 of lregs.irqmask */ + +/* leo uart register definitions */ +#define LEON_OFF_UDATA 0x0 +#define LEON_OFF_USTAT 0x4 +#define LEON_OFF_UCTRL 0x8 +#define LEON_OFF_USCAL 0xc + +#define LEON_UCTRL_RE 0x01 +#define LEON_UCTRL_TE 0x02 +#define LEON_UCTRL_RI 0x04 +#define LEON_UCTRL_TI 0x08 +#define LEON_UCTRL_PS 0x10 +#define LEON_UCTRL_PE 0x20 +#define LEON_UCTRL_FL 0x40 +#define LEON_UCTRL_LB 0x80 + +#define LEON_USTAT_DR 0x01 +#define LEON_USTAT_TS 0x02 +#define LEON_USTAT_TH 0x04 +#define LEON_USTAT_BR 0x08 +#define LEON_USTAT_OV 0x10 +#define LEON_USTAT_PE 0x20 +#define LEON_USTAT_FE 0x40 + +#define LEON_MCFG2_SRAMDIS 0x00002000 +#define LEON_MCFG2_SDRAMEN 0x00004000 +#define LEON_MCFG2_SRAMBANKSZ 0x00001e00 /* [12-9] */ +#define LEON_MCFG2_SRAMBANKSZ_SHIEFT 9 +#define LEON_MCFG2_SDRAMBANKSZ 0x03800000 /* [25-23] */ +#define LEON_MCFG2_SDRAMBANKSZ_SHIEFT 23 + +#define LEON_USTAT_ERROR (LEON_USTAT_OV|LEON_USTAT_PE|LEON_USTAT_FE) /*no break yet*/ + +#ifdef CONFIG_OPEN_ETH +#define LEON_ETH_BASE_ADD ((unsigned long)LEON_VA_ETHERMAC) +#endif + +#ifndef __ASSEMBLER__ + +/* do a physical address bypass write, i.e. for 0x80000000 */ +static __inline__ void leon_store_reg(unsigned long paddr,unsigned long value) +{ + __asm__ __volatile__("sta %0, [%1] %2\n\t": : + "r" (value), "r" (paddr), + "i" (ASI_LEON_BYPASS) : "memory"); +} + +/* do a physical address bypass load, i.e. for 0x80000000 */ +static __inline__ unsigned long leon_load_reg(unsigned long paddr) +{ + unsigned long retval; + __asm__ __volatile__("lda [%1] %2, %0\n\t" : + "=r" (retval) : + "r" (paddr), "i" (ASI_LEON_BYPASS)); + return retval; +} + +extern __inline__ void leon_srmmu_disabletlb(void) +{ + unsigned int retval; + __asm__ __volatile__("lda [%%g0] %2, %0\n\t" : "=r" (retval) : "r" (0), "i" (ASI_LEON_MMUREGS)); + retval |= LEON_CNR_CTRL_TLBDIS; + __asm__ __volatile__("sta %0, [%%g0] %2\n\t" : : "r" (retval), "r" (0), "i" (ASI_LEON_MMUREGS) : "memory"); +} + +extern __inline__ void leon_srmmu_enabletlb(void) +{ + unsigned int retval; + __asm__ __volatile__("lda [%%g0] %2, %0\n\t" : "=r" (retval) : "r" (0), "i" (ASI_LEON_MMUREGS)); + retval = retval & ~LEON_CNR_CTRL_TLBDIS; + __asm__ __volatile__("sta %0, [%%g0] %2\n\t" : : "r" (retval), "r" (0), "i" (ASI_LEON_MMUREGS) : "memory"); +} + +#define LEON_BYPASS_LOAD_PA(x) leon_load_reg ((unsigned long)(x)) +#define LEON_BYPASS_STORE_PA(x,v) leon_store_reg((unsigned long)(x),(unsigned long)(v)) +#define LEON_REGLOAD_PA(x) leon_load_reg ((unsigned long)(x)+LEON_PREGS) +#define LEON_REGSTORE_PA(x,v) leon_store_reg((unsigned long)(x)+LEON_PREGS,(unsigned long)(v)) +#define LEON_REGSTORE_OR_PA(x,v) leon_store_reg((unsigned long)(x)+LEON_PREGS,leon_load_reg((unsigned long)(x)+LEON_PREGS)|(unsigned long)(v)) +#define LEON_REGSTORE_AND_PA(x,v) leon_store_reg((unsigned long)(x)+LEON_PREGS,leon_load_reg((unsigned long)(x)+LEON_PREGS)&(unsigned long)(v)) + +#define LEON_GETPADDR(x) leon_load_reg((unsigned long)(x)) +#define LEON_SETPADDR(x,v) leon_store_reg((unsigned long)(x),(unsigned long)(v)) + +/* this structure will be located at bootup at address KERNBASE (0xf0000000). + * A pointer to it is given inb %o0 when jumping to gokernel */ +struct leon_setup { + unsigned long dummy1; + unsigned long dummy2; + unsigned long memctrl1; + unsigned long memctrl2; + unsigned long freq_kh; /* initialized by bootloader */ + unsigned long uart_baud[2]; /* initialized by bootloader */ + unsigned long sram_kb; + unsigned long sdram_mb; + unsigned long root_dev; + unsigned long root_mountflags_or; + unsigned long initrd_start; + unsigned long initrd_size; + char args[256]; +}; + +extern struct leon_setup leon_setup_vector; + +extern unsigned long srmmu_swprobe(unsigned long vaddr,unsigned long *paddr); +extern void leon_doshow_tlb(unsigned long *p1); +static __inline__ void leon_show_tlb(void) { + unsigned long b[LEON_MMUTLB_ENT_MAX*4]; + unsigned long pa,i,pbase; + leon_srmmu_disabletlb(); + for (i = 0;i < LEON_MMUTLB_ENT_MAX*4;i++) + b[i] = 0; + if ((pbase = srmmu_swprobe((unsigned long)&b,&pa)) != 0) { + unsigned long *p1 = (unsigned long *)pa; + leon_doshow_tlb(p1); + __asm__ __volatile__("sta %%g0, [%1] %0\n\t": : + "i" (ASI_MMU_DIAG), "r" (p1) : "memory"); + leon_doshow_tlb(p1); + } + leon_srmmu_enabletlb(); +} + +#endif /* !ASM */ + +#define LEONSETUP_MEM_SZAVAIL_KB (leon_setup_vector.sram_kb ? leon_setup_vector.sram_kb : (leon_setup_vector.sdram_mb * 1024)) +#define LEONSETUP_MEM_BASEADDR 0x40000000 + + +#define LEON_VA_ETHERMAC DVMA_VADDR /* map leon on ethermac adress space at pa 0xb0000000 */ + +#endif + + + + + + + diff -urN linux-2.5.75/include/asm-sparc/leon_dbg.h linux-2.5.75-patch-topete/include/asm-sparc/leon_dbg.h --- linux-2.5.75/include/asm-sparc/leon_dbg.h 1970-01-01 01:00:00.000000000 +0100 +++ linux-2.5.75-patch-topete/include/asm-sparc/leon_dbg.h 2003-08-20 09:42:21.000000000 +0200 @@ -0,0 +1,62 @@ +/* Konrad Eisele, 2003: include/asm/leon_dbg.h */ + +#ifndef LEON_DBG_H_INCLUDE +#define LEON_DBG_H_INCLUDE + +#include + +extern __inline__ unsigned long +asmgetitag (unsigned long addr) { + register unsigned long entry; + __asm__ __volatile__(" lda [%1] %2,%0\n\t" : + "=r" (entry): + "r" (addr), "i" (ASI_LEON_ITAG)); + return entry; +} + +extern __inline__ unsigned long +asmgetidata (unsigned long addr) { + register unsigned long entry; + __asm__ __volatile__(" lda [%1] %2,%0\n\t" : + "=r" (entry): + "r" (addr), "i" (ASI_LEON_IDATA)); + return entry; +} + +extern __inline__ unsigned long +asmgetictx (unsigned long addr) { + register unsigned long entry; + __asm__ __volatile__(" lda [%1] %2,%0\n\t" : + "=r" (entry): + "r" (addr), "i" (ASI_LEON_ICTX)); + return entry; +} + +extern __inline__ unsigned long +asmgetdtag (unsigned long addr) { + register unsigned long entry; + __asm__ __volatile__(" lda [%1] %2,%0\n\t" : + "=r" (entry): + "r" (addr), "i" (ASI_LEON_DTAG)); + return entry; +} + +extern __inline__ unsigned long +asmgetddata (unsigned long addr) { + register unsigned long entry; + __asm__ __volatile__(" lda [%1] %2,%0\n\t" : + "=r" (entry): + "r" (addr), "i" (ASI_LEON_DDATA)); + return entry; +} + +extern __inline__ unsigned long +asmgetdctx (unsigned long addr) { + register unsigned long entry; + __asm__ __volatile__(" lda [%1] %2,%0\n\t" : + "=r" (entry): + "r" (addr), "i" (ASI_LEON_DCTX)); + return entry; +} + +#endif diff -urN linux-2.5.75/include/asm-sparc/machines.h linux-2.5.75-patch-topete/include/asm-sparc/machines.h --- linux-2.5.75/include/asm-sparc/machines.h 2003-07-10 22:04:08.000000000 +0200 +++ linux-2.5.75-patch-topete/include/asm-sparc/machines.h 2003-08-20 10:17:32.000000000 +0200 @@ -15,7 +15,7 @@ /* Current number of machines we know about that has an IDPROM * machtype entry including one entry for the 0x80 OBP machines. */ -#define NUM_SUN_MACHINES 15 +#define NUM_SUN_MACHINES 16 extern struct Sun_Machine_Models Sun_Machines[NUM_SUN_MACHINES]; @@ -32,6 +32,7 @@ #define SM_ARCH_MASK 0xf0 #define SM_SUN4 0x20 +#define M_LEON2 0x30 #define SM_SUN4C 0x50 #define SM_SUN4M 0x70 #define SM_SUN4M_OBP 0x80 @@ -43,6 +44,9 @@ #define SM_4_330 0x03 /* Sun 4/300 series */ #define SM_4_470 0x04 /* Sun 4/400 series */ +/* Leon machines */ +#define M_LEON2_SOC 0x01 /* Leon2 Soc */ + /* Sun4c machines Full Name - PROM NAME */ #define SM_4C_SS1 0x01 /* Sun4c SparcStation 1 - Sun 4/60 */ #define SM_4C_IPC 0x02 /* Sun4c SparcStation IPC - Sun 4/40 */ diff -urN linux-2.5.75/include/asm-sparc/page.h linux-2.5.75-patch-topete/include/asm-sparc/page.h --- linux-2.5.75/include/asm-sparc/page.h 2003-07-10 22:06:50.000000000 +0200 +++ linux-2.5.75-patch-topete/include/asm-sparc/page.h 2003-08-20 09:42:21.000000000 +0200 @@ -156,17 +156,22 @@ #define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK) #define PAGE_OFFSET 0xf0000000 -#define __pa(x) ((unsigned long)(x) - PAGE_OFFSET) -#define __va(x) ((void *)((unsigned long) (x) + PAGE_OFFSET)) +#ifndef __ASSEMBLY__ +extern unsigned long phys_base; +#endif +#define __pa(x) ((unsigned long)(x) - PAGE_OFFSET + phys_base) +#define __va(x) ((void *)((unsigned long) (x) - phys_base + PAGE_OFFSET)) #define virt_to_phys(x) __pa((unsigned long)(x)) #define phys_to_virt(x) __va((unsigned long)(x)) -#define pfn_to_page(pfn) (mem_map + (pfn)) -#define page_to_pfn(page) ((unsigned long)((page) - mem_map)) -#define virt_to_page(kaddr) (mem_map + (__pa(kaddr) >> PAGE_SHIFT)) -#define pfn_valid(pfn) ((pfn) < max_mapnr) -#define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT) +#define PFN(x) ((x) >> PAGE_SHIFT) +#define PADDR(x) ((x) << PAGE_SHIFT) +#define pfn_to_page(pfn) (mem_map + (((unsigned long)pfn) - PFN(phys_base))) +#define page_to_pfn(page) (((unsigned long)((page) - mem_map)) + PFN(phys_base)) +#define virt_to_page(kaddr) pfn_to_page(PFN(__pa(kaddr))) +#define pfn_valid(pfn) (((pfn) >= PFN(phys_base)) && (((pfn)-PFN(phys_base)) < max_mapnr)) +#define virt_addr_valid(kaddr) pfn_valid(PFN(__pa(kaddr))) #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \ VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) diff -urN linux-2.5.75/include/asm-sparc/system.h linux-2.5.75-patch-topete/include/asm-sparc/system.h --- linux-2.5.75/include/asm-sparc/system.h 2003-07-10 22:12:24.000000000 +0200 +++ linux-2.5.75-patch-topete/include/asm-sparc/system.h 2003-08-20 09:42:21.000000000 +0200 @@ -29,6 +29,7 @@ sun4u = 0x05, /* V8 ploos ploos */ sun_unknown = 0x06, ap1000 = 0x07, /* almost a sun4m */ + sparc_leon = 0x08, /* sparc-leon SOC */ }; /* Really, userland should not be looking at any of this... */ @@ -153,6 +154,7 @@ "wr %%g4, 0x0, %%psr\n\t" \ "nop\n\t" \ "nop\n\t" \ + "nop\n\t" \ "jmpl %%o7 + 0x8, %%g0\n\t" \ " ld [%%g3 + %5], %0\n\t" \ "here:\n" \ @@ -326,6 +328,9 @@ extern void __xchg_called_with_bad_pointer(void); + +//"###############Remove this code, this is only present for debugging while reimplementing 2.5.69" +#if defined(__OPTIMIZE__) static __inline__ unsigned long __xchg(unsigned long x, __volatile__ void * ptr, int size) { switch (size) { @@ -335,6 +340,15 @@ __xchg_called_with_bad_pointer(); return x; } +#else +//change to macro so that a nonoptimaized kernel (noninline) can use +#define __xchg(x,ptr,size) \ +({ unsigned long tmp;unsigned long tmp_x=x; __volatile__ void * tmp_ptr=ptr; \ + if (size == 4) { tmp = xchg_u32(tmp_ptr, tmp_x); } \ + else { __xchg_called_with_bad_pointer(); }; \ + tmp;}) +#endif + extern void die_if_kernel(char *str, struct pt_regs *regs) __attribute__ ((noreturn)); diff -urN linux-2.5.75/usr/initramfs_data.S linux-2.5.75-patch-topete/usr/initramfs_data.S --- linux-2.5.75/usr/initramfs_data.S 1970-01-01 01:00:00.000000000 +0100 +++ linux-2.5.75-patch-topete/usr/initramfs_data.S 2003-08-20 11:52:37.000000000 +0200 @@ -0,0 +1,2 @@ + .section .init.ramfs,"a" +.incbin "usr/initramfs_data.cpio.gz"