vpe.c (e01402b115cccb6357f956649487aca2c6f7fbba) | vpe.c (340ee4b98c0543b5632cac975a7449a2d28762d8) |
---|---|
1/* 2 * Copyright (C) 2004, 2005 MIPS Technologies, Inc. All rights reserved. 3 * 4 * This program is free software; you can distribute it and/or modify it 5 * under the terms of the GNU General Public License (Version 2) as 6 * published by the Free Software Foundation. 7 * 8 * This program is distributed in the hope it will be useful, but WITHOUT --- 18 unchanged lines hidden (view full) --- 27 * 28 * To load and run, simply cat a SP 'program file' to /dev/vpe1. 29 * i.e cat spapp >/dev/vpe1. 30 * 31 * You'll need to have the following device files. 32 * mknod /dev/vpe0 c 63 0 33 * mknod /dev/vpe1 c 63 1 34 */ | 1/* 2 * Copyright (C) 2004, 2005 MIPS Technologies, Inc. All rights reserved. 3 * 4 * This program is free software; you can distribute it and/or modify it 5 * under the terms of the GNU General Public License (Version 2) as 6 * published by the Free Software Foundation. 7 * 8 * This program is distributed in the hope it will be useful, but WITHOUT --- 18 unchanged lines hidden (view full) --- 27 * 28 * To load and run, simply cat a SP 'program file' to /dev/vpe1. 29 * i.e cat spapp >/dev/vpe1. 30 * 31 * You'll need to have the following device files. 32 * mknod /dev/vpe0 c 63 0 33 * mknod /dev/vpe1 c 63 1 34 */ |
35 | 35#include <linux/config.h> |
36#include <linux/kernel.h> 37#include <linux/module.h> 38#include <linux/fs.h> 39#include <linux/init.h> 40#include <asm/uaccess.h> 41#include <linux/slab.h> 42#include <linux/list.h> 43#include <linux/vmalloc.h> 44#include <linux/elf.h> 45#include <linux/seq_file.h> 46#include <linux/syscalls.h> 47#include <linux/moduleloader.h> 48#include <linux/interrupt.h> 49#include <linux/poll.h> 50#include <linux/bootmem.h> 51#include <asm/mipsregs.h> | 36#include <linux/kernel.h> 37#include <linux/module.h> 38#include <linux/fs.h> 39#include <linux/init.h> 40#include <asm/uaccess.h> 41#include <linux/slab.h> 42#include <linux/list.h> 43#include <linux/vmalloc.h> 44#include <linux/elf.h> 45#include <linux/seq_file.h> 46#include <linux/syscalls.h> 47#include <linux/moduleloader.h> 48#include <linux/interrupt.h> 49#include <linux/poll.h> 50#include <linux/bootmem.h> 51#include <asm/mipsregs.h> |
52#include <asm/mipsmtregs.h> |
|
52#include <asm/cacheflush.h> 53#include <asm/atomic.h> 54#include <asm/cpu.h> 55#include <asm/processor.h> 56#include <asm/system.h> 57 58typedef void *vpe_handle; 59 --- 632 unchanged lines hidden (view full) --- 692 "VPE: only Master VPE's are allowed to configure MT\n"); 693 return -1; 694 } 695 696 /* disable MT (using dvpe) */ 697 dvpe(); 698 699 /* Put MVPE's into 'configuration state' */ | 53#include <asm/cacheflush.h> 54#include <asm/atomic.h> 55#include <asm/cpu.h> 56#include <asm/processor.h> 57#include <asm/system.h> 58 59typedef void *vpe_handle; 60 --- 632 unchanged lines hidden (view full) --- 693 "VPE: only Master VPE's are allowed to configure MT\n"); 694 return -1; 695 } 696 697 /* disable MT (using dvpe) */ 698 dvpe(); 699 700 /* Put MVPE's into 'configuration state' */ |
700 write_c0_mvpcontrol(read_c0_mvpcontrol() | MVPCONTROL_VPC); | 701 set_c0_mvpcontrol(MVPCONTROL_VPC); |
701 702 if (!list_empty(&v->tc)) { 703 if ((t = list_entry(v->tc.next, struct tc, tc)) == NULL) { 704 printk(KERN_WARNING "VPE: TC %d is already in use.\n", 705 t->index); 706 return -ENOEXEC; 707 } 708 } else { --- 46 unchanged lines hidden (view full) --- 755 756 /* set config to be the same as vpe0, particularly kseg0 coherency alg */ 757 write_vpe_c0_config(read_c0_config()); 758 759 /* clear out any left overs from a previous program */ 760 write_vpe_c0_cause(0); 761 762 /* take system out of configuration state */ | 702 703 if (!list_empty(&v->tc)) { 704 if ((t = list_entry(v->tc.next, struct tc, tc)) == NULL) { 705 printk(KERN_WARNING "VPE: TC %d is already in use.\n", 706 t->index); 707 return -ENOEXEC; 708 } 709 } else { --- 46 unchanged lines hidden (view full) --- 756 757 /* set config to be the same as vpe0, particularly kseg0 coherency alg */ 758 write_vpe_c0_config(read_c0_config()); 759 760 /* clear out any left overs from a previous program */ 761 write_vpe_c0_cause(0); 762 763 /* take system out of configuration state */ |
763 write_c0_mvpcontrol(read_c0_mvpcontrol() & ~MVPCONTROL_VPC); | 764 clear_c0_mvpcontrol(MVPCONTROL_VPC); |
764 765 /* clear interrupts enabled IE, ERL, EXL, and KSU from c0 status */ 766 write_vpe_c0_status(read_vpe_c0_status() & ~(ST0_ERL | ST0_KSU | ST0_IE | ST0_EXL)); 767 768 /* set it running */ 769 evpe(EVPE_ENABLE); 770 771 return 0; --- 357 unchanged lines hidden (view full) --- 1129 1130 if ((t = list_entry(v->tc.next, struct tc, tc)) == NULL) { 1131 return -ENOEXEC; 1132 } 1133 1134 evpe_flags = dvpe(); 1135 1136 /* Put MVPE's into 'configuration state' */ | 765 766 /* clear interrupts enabled IE, ERL, EXL, and KSU from c0 status */ 767 write_vpe_c0_status(read_vpe_c0_status() & ~(ST0_ERL | ST0_KSU | ST0_IE | ST0_EXL)); 768 769 /* set it running */ 770 evpe(EVPE_ENABLE); 771 772 return 0; --- 357 unchanged lines hidden (view full) --- 1130 1131 if ((t = list_entry(v->tc.next, struct tc, tc)) == NULL) { 1132 return -ENOEXEC; 1133 } 1134 1135 evpe_flags = dvpe(); 1136 1137 /* Put MVPE's into 'configuration state' */ |
1137 write_c0_mvpcontrol(read_c0_mvpcontrol() | MVPCONTROL_VPC); | 1138 set_c0_mvpcontrol(MVPCONTROL_VPC); |
1138 1139 settc(t->index); 1140 write_vpe_c0_vpeconf0(read_vpe_c0_vpeconf0() & ~VPECONF0_VPA); 1141 1142 /* mark the TC unallocated and halt'ed */ 1143 write_tc_c0_tcstatus(read_tc_c0_tcstatus() & ~TCSTATUS_A); 1144 write_tc_c0_tchalt(TCHALT_H); 1145 1146 v->state = VPE_STATE_UNUSED; 1147 | 1139 1140 settc(t->index); 1141 write_vpe_c0_vpeconf0(read_vpe_c0_vpeconf0() & ~VPECONF0_VPA); 1142 1143 /* mark the TC unallocated and halt'ed */ 1144 write_tc_c0_tcstatus(read_tc_c0_tcstatus() & ~TCSTATUS_A); 1145 write_tc_c0_tchalt(TCHALT_H); 1146 1147 v->state = VPE_STATE_UNUSED; 1148 |
1148 write_c0_mvpcontrol(read_c0_mvpcontrol() & ~MVPCONTROL_VPC); | 1149 clear_c0_mvpcontrol(MVPCONTROL_VPC); |
1149 evpe(evpe_flags); 1150 1151 return 0; 1152} 1153 1154EXPORT_SYMBOL(vpe_free); 1155 1156void *vpe_get_shared(int index) --- 29 unchanged lines hidden (view full) --- 1186 1187 if (major == 0) 1188 major = VPE_MAJOR; 1189 1190 dmt(); 1191 dvpe(); 1192 1193 /* Put MVPE's into 'configuration state' */ | 1150 evpe(evpe_flags); 1151 1152 return 0; 1153} 1154 1155EXPORT_SYMBOL(vpe_free); 1156 1157void *vpe_get_shared(int index) --- 29 unchanged lines hidden (view full) --- 1187 1188 if (major == 0) 1189 major = VPE_MAJOR; 1190 1191 dmt(); 1192 dvpe(); 1193 1194 /* Put MVPE's into 'configuration state' */ |
1194 write_c0_mvpcontrol(read_c0_mvpcontrol() | MVPCONTROL_VPC); | 1195 set_c0_mvpcontrol(MVPCONTROL_VPC); |
1195 1196 /* dump_mtregs(); */ 1197 1198 INIT_LIST_HEAD(&vpecontrol.vpe_list); 1199 INIT_LIST_HEAD(&vpecontrol.tc_list); 1200 1201 val = read_c0_mvpconf0(); 1202 for (i = 0; i < ((val & MVPCONF0_PTC) + 1); i++) { --- 62 unchanged lines hidden (view full) --- 1265 tmp |= TCSTATUS_IXMT; /* interrupt exempt */ 1266 write_tc_c0_tcstatus(tmp); 1267 1268 write_tc_c0_tchalt(TCHALT_H); 1269 } 1270 } 1271 1272 /* release config state */ | 1196 1197 /* dump_mtregs(); */ 1198 1199 INIT_LIST_HEAD(&vpecontrol.vpe_list); 1200 INIT_LIST_HEAD(&vpecontrol.tc_list); 1201 1202 val = read_c0_mvpconf0(); 1203 for (i = 0; i < ((val & MVPCONF0_PTC) + 1); i++) { --- 62 unchanged lines hidden (view full) --- 1266 tmp |= TCSTATUS_IXMT; /* interrupt exempt */ 1267 write_tc_c0_tcstatus(tmp); 1268 1269 write_tc_c0_tchalt(TCHALT_H); 1270 } 1271 } 1272 1273 /* release config state */ |
1273 write_c0_mvpcontrol(read_c0_mvpcontrol() & ~MVPCONTROL_VPC); | 1274 clear_c0_mvpcontrol(MVPCONTROL_VPC); |
1274 1275 return 0; 1276} 1277 1278static void __exit vpe_module_exit(void) 1279{ 1280 struct vpe *v, *n; 1281 --- 14 unchanged lines hidden --- | 1275 1276 return 0; 1277} 1278 1279static void __exit vpe_module_exit(void) 1280{ 1281 struct vpe *v, *n; 1282 --- 14 unchanged lines hidden --- |