From: James S. <jsi...@us...> - 2002-01-28 20:32:30
|
Update of /cvsroot/linux-mips/linux/arch/mips/sibyte/swarm In directory usw-pr-cvs1:/tmp/cvs-serv7656/arch/mips/sibyte/swarm Modified Files: cfe_api.c cfe_api.h smp.c time.c Log Message: Big overhaul of 64-bit kernel along the lines of what we already have for the 64-bit kernel just more radical. Index: cfe_api.c =================================================================== RCS file: /cvsroot/linux-mips/linux/arch/mips/sibyte/swarm/cfe_api.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- cfe_api.c 2001/11/08 17:42:08 1.1 +++ cfe_api.c 2002/01/28 20:31:57 1.2 @@ -253,7 +253,7 @@ return xiocb.xiocb_status; } -int cfe_enummem(long idx, unsigned long *addr, unsigned long *size, long *type) +int cfe_enummem(long idx, unsigned long long *addr, unsigned long long *size, long *type) { cfe_xiocb_t xiocb; xiocb.xiocb_fcode = CFE_CMD_FW_MEMENUM; @@ -369,8 +369,18 @@ void cfe_console_print(char *str) { + int len = strlen(str); + int res; + if (cfe_console_handle != -1) { cfe_write(cfe_console_handle, str, strlen(str)); + do { + res = cfe_writeblk(cfe_console_handle, 0, str, len); + if (res < 0) + break; + str += res; + len -= res; + } while (len); } } Index: cfe_api.h =================================================================== RCS file: /cvsroot/linux-mips/linux/arch/mips/sibyte/swarm/cfe_api.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- cfe_api.h 2001/11/08 17:42:08 1.1 +++ cfe_api.h 2002/01/28 20:31:57 1.2 @@ -46,7 +46,7 @@ int cfe_ioctl(int handle,unsigned int ioctlnum,unsigned char *buffer,int length,int *retlen); int cfe_inpstat(int handle); int cfe_enumenv(int idx,char *name,int namelen,char *val,int vallen); -int cfe_enummem(long idx, unsigned long *addr, unsigned long *size, long *type); +int cfe_enummem(long idx, unsigned long long *addr, unsigned long long *size, long *type); int cfe_setenv(char *name,char *val); int cfe_getenv(char *name,char *dest,int destlen); long long cfe_getticks(void); Index: smp.c =================================================================== RCS file: /cvsroot/linux-mips/linux/arch/mips/sibyte/swarm/smp.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- smp.c 2001/12/17 18:48:28 1.4 +++ smp.c 2002/01/28 20:31:57 1.5 @@ -18,14 +18,19 @@ #include <linux/config.h> #include <linux/kernel.h> +#include <linux/delay.h> +#include <linux/init.h> +#include <linux/smp.h> + +#include <asm/sibyte/sb1250.h> #include <asm/sibyte/sb1250_regs.h> #include <asm/sibyte/sb1250_int.h> #include <asm/mipsregs.h> +#include <asm/mmu_context.h> + #include "cfe_xiocb.h" #include "cfe_api.h" - - extern void asmlinkage smp_bootstrap(void); /* Boot all other cpus in the system, initialize them, and @@ -68,4 +73,79 @@ void prom_smp_finish(void) { sb1250_smp_finish(); +} + +/* + * XXX This is really halfway portable code and halfway system specific code. + */ +extern atomic_t cpus_booted; + +void __init smp_boot_cpus(void) +{ + int i; + + smp_num_cpus = prom_setup_smp(); + init_new_context(current, &init_mm); + current->processor = 0; + cpu_data[0].udelay_val = loops_per_jiffy; + cpu_data[0].asid_cache = ASID_FIRST_VERSION; + CPUMASK_CLRALL(cpu_online_map); + CPUMASK_SETB(cpu_online_map, 0); + atomic_set(&cpus_booted, 1); /* Master CPU is already booted... */ + init_idle(); + for (i = 1; i < smp_num_cpus; i++) { + struct task_struct *p; + struct pt_regs regs; + printk("Starting CPU %d... ", i); + + /* Spawn a new process normally. Grab a pointer to + its task struct so we can mess with it */ + do_fork(CLONE_VM|CLONE_PID, 0, ®s, 0); + p = init_task.prev_task; + + /* Schedule the first task manually */ + p->processor = i; + p->cpus_runnable = 1 << i; /* we schedule the first task manually */ + + /* Attach to the address space of init_task. */ + atomic_inc(&init_mm.mm_count); + p->active_mm = &init_mm; + init_tasks[i] = p; + + del_from_runqueue(p); + unhash_process(p); + + prom_boot_secondary(i, + (unsigned long)p + KERNEL_STACK_SIZE - 32, + (unsigned long)p); + +#if 0 + /* This is copied from the ip-27 code in the mips64 tree */ + + struct task_struct *p; + + /* + * The following code is purely to make sure + * Linux can schedule processes on this slave. + */ + kernel_thread(0, NULL, CLONE_PID); + p = init_task.prev_task; + sprintf(p->comm, "%s%d", "Idle", i); + init_tasks[i] = p; + p->processor = i; + p->cpus_runnable = 1 << i; /* we schedule the first task manually */ + del_from_runqueue(p); + unhash_process(p); + /* Attach to the address space of init_task. */ + atomic_inc(&init_mm.mm_count); + p->active_mm = &init_mm; + prom_boot_secondary(i, + (unsigned long)p + KERNEL_STACK_SIZE - 32, + (unsigned long)p); +#endif + } + + /* Wait for everyone to come up */ + while (atomic_read(&cpus_booted) != smp_num_cpus); + smp_threads_ready = 1; } Index: time.c =================================================================== RCS file: /cvsroot/linux-mips/linux/arch/mips/sibyte/swarm/time.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- time.c 2001/11/08 17:42:08 1.1 +++ time.c 2002/01/28 20:31:57 1.2 @@ -22,8 +22,6 @@ * track of here is what time of day we think it is. And we don't * really even do a good job of that... */ - - #include <linux/init.h> #include <linux/time.h> #include <linux/sched.h> @@ -36,9 +34,6 @@ #include <asm/sibyte/sb1250_regs.h> #include <asm/sibyte/sb1250_smbus.h> -static unsigned long long sec_bias = 0; -static unsigned int usec_bias = 0; - extern rwlock_t xtime_lock; /* Xicor 1241 definitions */ @@ -219,7 +214,7 @@ /* * Bring up the timer at 100 Hz. */ -void __init time_init(void) +void __init swarm_time_init(void) { unsigned int flags; int status; @@ -243,26 +238,4 @@ xtime.tv_usec = 0; write_unlock_irqrestore(&xtime_lock, flags); } -} - -void do_settimeofday(struct timeval *tv) -{ - unsigned long saved_jiffies; - unsigned long flags; - saved_jiffies = jiffies; - write_lock_irqsave(&xtime_lock, flags); - sec_bias = (saved_jiffies/HZ) - tv->tv_sec; - usec_bias = ((saved_jiffies%HZ)*(1000000/HZ)) - tv->tv_usec; - write_unlock_irqrestore(&xtime_lock, flags); -} - -void do_gettimeofday(struct timeval *tv) -{ - unsigned long saved_jiffies; - unsigned long flags; - saved_jiffies = jiffies; - read_lock_irqsave(&xtime_lock, flags); - tv->tv_sec = sec_bias + (saved_jiffies/HZ); - tv->tv_usec = usec_bias + ((saved_jiffies%HZ) * (1000000/HZ)); - read_unlock_irqrestore(&xtime_lock, flags); } |