Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | /* * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * * The contents of this file constitute Original Code as defined in and * are subject to the Apple Public Source License Version 1.1 (the * "License"). You may not use this file except in compliance with the * License. Please obtain a copy of the License at * http://www.apple.com/publicsource and read it before using this file. * * This Original Code and all software distributed under the License are * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the * License for the specific language governing rights and limitations * under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* * @OSF_FREE_COPYRIGHT@ */ /* * @APPLE_FREE_COPYRIGHT@ */ /* * Author: Bill Angell, Apple * Date: 9/auht-aught * * Random diagnostics */ #include <kern/machine.h> #include <kern/processor.h> #include <mach/machine.h> #include <mach/processor_info.h> #include <mach/mach_types.h> #include <mach/boolean.h> #include <kern/thread.h> #include <kern/task.h> #include <mach/vm_param.h> #include <vm/vm_kern.h> #include <vm/vm_map.h> #include <vm/vm_page.h> #include <vm/pmap.h> #include <ppc/exception.h> #include <ppc/Firmware.h> #include <ppc/low_trace.h> #include <ppc/db_low_trace.h> #include <ppc/mappings.h> #include <ppc/pmap.h> #include <ppc/mem.h> #include <ppc/pmap_internals.h> #include <ppc/savearea.h> #include <ppc/Diagnostics.h> #include <ppc/machine_cpu.h> #include <pexpert/pexpert.h> int diagCall(struct savearea *save) { union { unsigned long long tbase; unsigned int tb[2]; } ttt, adj; natural_t tbu, tbu2, tbl; struct per_proc_info *per_proc; /* Area for my per_proc address */ int cpu; if(!(dgWork.dgFlags & enaDiagSCs)) return 0; /* If not enabled, cause an exception */ switch(save->save_r3) { /* Select the routine */ /* * Adjust the timebase for drift recovery testing */ case dgAdjTB: /* Adjust the timebase */ adj.tb[0] = 0; /* Clear high part */ adj.tb[1] = save->save_r4; /* Set low order */ if(adj.tb[1] & 0x80000000) adj.tb[0] = 0xFFFFFFFF; /* Propagate sign bit */ do { /* Read current time */ asm volatile(" mftbu %0" : "=r" (tbu)); asm volatile(" mftb %0" : "=r" (tbl)); asm volatile(" mftbu %0" : "=r" (tbu2)); } while (tbu != tbu2); ttt.tb[0] = tbu; /* Set high */ ttt.tb[1] = tbl; /* Set low */ ttt.tbase = ttt.tbase + adj.tbase; /* Increment or decrement the TB */ tbu = ttt.tb[0]; /* Save in regular variable */ tbl = ttt.tb[1]; /* Save in regular variable */ mttb(0); /* Set low to keep from ticking */ mttbu(tbu); /* Set adjusted high */ mttb(tbl); /* Set adjusted low */ return -1; /* Return no AST checking... */ /* * Return physical address of a page */ case dgLRA: save->save_r3 = pmap_extract(current_act()->map->pmap, save->save_r4); /* Get read address */ return -1; /* Return no AST checking... */ /* * Copy physical to virtual */ case dgpcpy: #if 0 save->save_r3 = copyp2v(save->save_r4, save->save_r5, save->save_r6); /* Copy the physical page */ #endif return 1; /* Return and check for ASTs... */ /* * Soft reset processor */ case dgreset: cpu = save->save_r4; /* Get the requested CPU number */ if(cpu >= NCPUS) { /* Check for bogus cpu */ save->save_r3 = KERN_FAILURE; /* Set failure */ return 1; } if(!machine_slot[cpu].running) return KERN_FAILURE; /* It is not running */ per_proc = &per_proc_info[cpu]; /* Point to the processor */ (void)PE_cpu_start(per_proc->cpu_id, per_proc->start_paddr, (vm_offset_t)per_proc); save->save_r3 = KERN_SUCCESS; /* Set scuuess */ return 1; /* Return and check for ASTs... */ /* * various hack tests */ case dgtest: pmap_remove(kernel_pmap, save->save_r4, save->save_r4 + 4096); return 1; /* Return and check for ASTs... */ default: /* Handle invalid ones */ return 0; /* Return an exception */ }; } |