| 1 | \ ========== Copyright Header Begin ========================================== |
| 2 | \ |
| 3 | \ Hypervisor Software File: slavecpu.fth |
| 4 | \ |
| 5 | \ Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. |
| 6 | \ |
| 7 | \ - Do no alter or remove copyright notices |
| 8 | \ |
| 9 | \ - Redistribution and use of this software in source and binary forms, with |
| 10 | \ or without modification, are permitted provided that the following |
| 11 | \ conditions are met: |
| 12 | \ |
| 13 | \ - Redistribution of source code must retain the above copyright notice, |
| 14 | \ this list of conditions and the following disclaimer. |
| 15 | \ |
| 16 | \ - Redistribution in binary form must reproduce the above copyright notice, |
| 17 | \ this list of conditions and the following disclaimer in the |
| 18 | \ documentation and/or other materials provided with the distribution. |
| 19 | \ |
| 20 | \ Neither the name of Sun Microsystems, Inc. or the names of contributors |
| 21 | \ may be used to endorse or promote products derived from this software |
| 22 | \ without specific prior written permission. |
| 23 | \ |
| 24 | \ This software is provided "AS IS," without a warranty of any kind. |
| 25 | \ ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, |
| 26 | \ INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A |
| 27 | \ PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN |
| 28 | \ MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR |
| 29 | \ ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR |
| 30 | \ DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN |
| 31 | \ OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR |
| 32 | \ FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE |
| 33 | \ DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, |
| 34 | \ ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF |
| 35 | \ SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. |
| 36 | \ |
| 37 | \ You acknowledge that this software is not designed, licensed or |
| 38 | \ intended for use in the design, construction, operation or maintenance of |
| 39 | \ any nuclear facility. |
| 40 | \ |
| 41 | \ ========== Copyright Header End ============================================ |
| 42 | id: @(#)slavecpu.fth 1.1 07/04/27 |
| 43 | purpose: |
| 44 | copyright: Copyright 2007 Sun Microsystems, Inc. All Rights Reserved |
| 45 | copyright: Use is subject to license terms. |
| 46 | |
| 47 | |
| 48 | code slave-enterforth ( -- ) |
| 49 | sc3 sc4 sc5 sc6 mutex-enter prom-lock \ Wait for prom-lock |
| 50 | |
| 51 | up sc1 scr get-cpu-struct \ scr has cpu-struct-ptr |
| 52 | 0 >cpu-status sc1 set \ sc1 has offset for cpu-status |
| 53 | |
| 54 | scr sc1 sc2 ldx \ Read current cpu-state |
| 55 | CPU-IDLING sc3 set \ sc3 has CPU-IDLING constant |
| 56 | sc2 sc3 %g0 subcc \ Is it CPU-IDLING? |
| 57 | 0= if \ If it is CPU-IDLING |
| 58 | CPU-OBP-COLD sc2 move \ then mark is COLD |
| 59 | else nop |
| 60 | CPU-OBP-WARM sc2 move \ Or else mark it WARM |
| 61 | then |
| 62 | sc2 scr sc1 stx \ Update cpu-state, COLD or WARM |
| 63 | |
| 64 | 'body enterforth ip set \ Set ip to address of enterforth |
| 65 | ip base ip add |
| 66 | c; \ Done, c; includes "next" |
| 67 | |
| 68 | |
| 69 | \ Cross Call handler to jump to slave-enterforth |
| 70 | label xcall-slave-enterforth |
| 71 | \ Set the base register |
| 72 | base rdpc \ Read current PC |
| 73 | here 4 - origin - sc3 set \ sc3 has offset of previous inst |
| 74 | base sc3 base sub \ Sub offset from PC to establish as base |
| 75 | 'acf slave-enterforth sc3 set \ sc3 has acf of slave-enterforth |
| 76 | sc3 base sc3 add \ Add base add to it |
| 77 | sc3 0 wrtpc \ Set tPC to jump address |
| 78 | sc3 4 sc3 add \ Add 4 to the address |
| 79 | sc3 0 wrtnpc \ Set tNPC to jump addr + 4 |
| 80 | retry \ Return from xcall to jump addr |
| 81 | end-code |
| 82 | |
| 83 | code slave-idle-loop |
| 84 | \ base = origin |
| 85 | \ up = User Area Pointer |
| 86 | \ The User Area is now initialized |
| 87 | scr rdpstate \ We should not be spinning in |
| 88 | #sync membar \ this loop with IE = 0 |
| 89 | scr 2 scr or \ set IE = 1 |
| 90 | scr 0 wrpstate \ Write to pstate reg. |
| 91 | #sync membar |
| 92 | up sc1 scr get-cpu-struct \ scr has cpu-struct-ptr |
| 93 | scr rp get-rp0 \ Setup RP |
| 94 | |
| 95 | 0 >cpu-status sc1 set \ sc1 has offset to cpu-status |
| 96 | CPU-IDLING sc2 move \ sc2 has CPU-IDLING constant |
| 97 | sc2 scr sc1 stx \ Mark as Idle |
| 98 | |
| 99 | sc3 sc4 sc5 mutex-exit prom-lock \ Let go prom-lock |
| 100 | |
| 101 | \ Wait here until we are started OR the master CPU advances us |
| 102 | \ into the wait for lockfree phase |
| 103 | begin |
| 104 | h# 12 %o5 move \ cpu_yield, FN # 0x12 |
| 105 | %g0 fast-trap# always htrapif \ Trap into HV and stay there |
| 106 | nop \ until interrupted |
| 107 | again nop \ Loop forever while in slave idle loop |
| 108 | c; |
| 109 | |
| 110 | headerless |
| 111 | defer slave-idle-loop-hook ( -- ) ' noop is slave-idle-loop-hook |
| 112 | : (slave-idle-loop) |
| 113 | flush-temporary-mappings \ Flush all temp mappings |
| 114 | slave-idle-loop-hook |
| 115 | enable-cpu-errors \ Enable errors |
| 116 | mid@ enable-reentry \ Enable reentry for the slave CPU |
| 117 | slave-idle-loop \ Enter slave-idle-loop |
| 118 | ; |
| 119 | |
| 120 | \ |
| 121 | \ Setup the per cpu rp0, sp0 pointers just the once. |
| 122 | \ Don't make this a : definition because we don't |
| 123 | \ have stacks yet!! |
| 124 | \ |
| 125 | label slave-init |
| 126 | up sc1 scr get-cpu-struct \ scr has pointer to cpu-struct |
| 127 | CPU-INIT sc1 sc2 scr mark-cpu-state \ Mark cpu-state to CPU-INIT |
| 128 | scr sc1 sc2 set-rp0 \ Set RP0 |
| 129 | scr sc1 sc2 set-sp0 \ Set SP0 |
| 130 | |
| 131 | scr sp get-sp0 \ Establish SP |
| 132 | scr rp get-rp0 \ Establish RP |
| 133 | sp /n sp add \ account for TOS |
| 134 | |
| 135 | 'body (slave-idle-loop) ip set \ Set jump address of |
| 136 | ip base ip add \ (slave-idle-loop) |
| 137 | next \ Jump to the address |
| 138 | end-code |
| 139 | |
| 140 | headers |
| 141 | |