OpenBSD/sgi on octane2 - curprocpaddrをcurcpu()->ci_curprocpaddrへ移動(解決篇)

OpenBSD/sgi on octane2 - curprocpaddrをcurcpu()->ci_curprocpaddrへ移動 - かーねる・う゛いえむにっきの解決篇。

この間うまく動かなかったコードでは、一度GET_CPU_INFO(reg0, reg1)したら同じ関数ではもう一度取得しなおす事はせずreg0へ参照を行うだけで済ませていた。
が、特に関数呼び出しが行われた時にレジスタ破壊が起きている可能性が強いので、取り合えず毎回GET_CPU_INFO()しまくるように書き換えた。

Index: context.S
===================================================================
RCS file: /cvs/src/sys/arch/mips64/mips64/context.S,v
retrieving revision 1.20
diff -r1.20 context.S
40,41d39
< #define curproc       (cpu_info_primary + CI_CURPROC)
<
106c104,105
<       PTR_L   t3, curprocpaddr
---
>       GET_CPU_INFO(t1, t3)
>       PTR_L   t3, CI_CURPROCPADDR(t1)
149,150c148,150
<       PTR_S   s0, curproc                     # set curproc
<       PTR_S   t3, curprocpaddr
---
>       GET_CPU_INFO(t1, t0)
>       PTR_S   s0, CI_CURPROC(t1)              # set curproc
>       PTR_S   t3, CI_CURPROCPADDR(t1)
Index: exception.S
===================================================================
RCS file: /cvs/src/sys/arch/mips64/mips64/exception.S,v
retrieving revision 1.16
diff -r1.16 exception.S
227c227,228
<       PTR_L   k0, curprocpaddr
---
>       GET_CPU_INFO(k1, k0)
>       PTR_L   k0, CI_CURPROCPADDR(k1)
251c252,253
<       PTR_L   t0, curprocpaddr
---
>       GET_CPU_INFO(k1, k0)
>       PTR_L   t0, CI_CURPROCPADDR(k1)
259c261
<       PTR_L   t0, curproc
---
>       PTR_L   t0, CI_CURPROC(k1)
284c286
<       PTR_L   t1, curproc             # set up rm7k.
---
>       PTR_L   t1, CI_CURPROC(k1)      # set up rm7k.
300c302,303
<       PTR_L   t0, curprocpaddr
---
>       GET_CPU_INFO(k1, k0)
>       PTR_L   t0, CI_CURPROCPADDR(k1)
317c320,321
<       PTR_L   k0, curprocpaddr
---
>       GET_CPU_INFO(k1, k0)
>       PTR_L   k0, CI_CURPROCPADDR(k1)
387c391,392
<       PTR_L   k0, curprocpaddr
---
>       GET_CPU_INFO(k1, k0)
>       PTR_L   k0, CI_CURPROCPADDR(k1)
406c411
<       PTR_L   t0, curproc
---
>       PTR_L   t0, CI_CURPROC(k1)
428c433,434
<       PTR_L   t0, curprocpaddr
---
>       GET_CPU_INFO(k1, k0)
>       PTR_L   t0, CI_CURPROCPADDR(k1)
434c440,441
<       PTR_L   t0, curprocpaddr
---
>       GET_CPU_INFO(k1, k0)
>       PTR_L   t0, CI_CURPROCPADDR(k1)
442c449
<       LOAD    t0, curproc             # set up rm7k.
---
>       LOAD    t0, CI_CURPROC(k1)      # set up rm7k.
468c475,476
<       PTR_L   k0, curprocpaddr
---
>       GET_CPU_INFO(k1, k0)
>       PTR_L   k0, CI_CURPROCPADDR(k1)
603a612,615
> #ifdef MULTIPROCESSOR
>       jal     _C_LABEL(proc_trampoline_mp)
>       nop
> #endif
666c678,679
<       PTR_L   k0, curprocpaddr
---
>       GET_CPU_INFO(k1, k0)
>       PTR_L   k0, CI_CURPROCPADDR(k1)
Index: lcore_access.S
===================================================================
RCS file: /cvs/src/sys/arch/mips64/mips64/lcore_access.S,v
retrieving revision 1.16
diff -r1.16 lcore_access.S
194c194,195
<       PTR_L   t3, curprocpaddr
---
>       GET_CPU_INFO(t1, t0)
>       PTR_L   t3, CI_CURPROCPADDR(t1)
199c200,201
<       PTR_L   t3, curprocpaddr
---
>       GET_CPU_INFO(t1, t0)
>       PTR_L   t3, CI_CURPROCPADDR(t1)
222c224,225
<       PTR_L   t3, curprocpaddr
---
>       GET_CPU_INFO(t1, t0)
>       PTR_L   t3, CI_CURPROCPADDR(t1)
227c230,231
<       PTR_L   t3, curprocpaddr
---
>       GET_CPU_INFO(t1, t0)
>       PTR_L   t3, CI_CURPROCPADDR(t1)
247c251,252
<       PTR_L   t3, curprocpaddr
---
>       GET_CPU_INFO(t1, t0)
>       PTR_L   t3, CI_CURPROCPADDR(t1)
252c257,258
<       PTR_L   t3, curprocpaddr
---
>       GET_CPU_INFO(t1, t0)
>       PTR_L   t3, CI_CURPROCPADDR(t1)
272c278,279
<       PTR_L   t3, curprocpaddr
---
>       GET_CPU_INFO(t1, t0)
>       PTR_L   t3, CI_CURPROCPADDR(t1)
277c284,285
<       PTR_L   t3, curprocpaddr
---
>       GET_CPU_INFO(t1, t0)
>       PTR_L   t3, CI_CURPROCPADDR(t1)
286c294,295
<       PTR_L   t3, curprocpaddr
---
>       GET_CPU_INFO(t1, t0)
>       PTR_L   t3, CI_CURPROCPADDR(t1)
299c308,309
<       PTR_L   t3, curprocpaddr
---
>       GET_CPU_INFO(t1, t0)
>       PTR_L   t3, CI_CURPROCPADDR(t1)
307c317,318
<       PTR_L   t3, curprocpaddr
---
>       GET_CPU_INFO(t1, t0)
>       PTR_L   t3, CI_CURPROCPADDR(t1)
317c328,329
<       PTR_L   t3, curprocpaddr
---
>       GET_CPU_INFO(t1, t0)
>       PTR_L   t3, CI_CURPROCPADDR(t1)
331c343,344
<       PTR_L   t3, curprocpaddr
---
>       GET_CPU_INFO(t1, t0)
>       PTR_L   t3, CI_CURPROCPADDR(t1)
345c358,359
<       PTR_L   t3, curprocpaddr
---
>       GET_CPU_INFO(t1, t0)
>       PTR_L   t3, CI_CURPROCPADDR(t1)
Index: lcore_ddb.S
===================================================================
RCS file: /cvs/src/sys/arch/mips64/mips64/lcore_ddb.S,v
retrieving revision 1.8
diff -r1.8 lcore_ddb.S
45c45,46
<       PTR_L   t0, curprocpaddr
---
>       GET_CPU_INFO(t1, t0)
>       PTR_L   t0, CI_CURPROCPADDR(t1)
64c65,66
<       PTR_L   t0, curprocpaddr
---
>       GET_CPU_INFO(t1, t0)
>       PTR_L   t0, CI_CURPROCPADDR(t1)
82c84,85
<       PTR_L   t0, curprocpaddr
---
>       GET_CPU_INFO(t1, t0)
>       PTR_L   t0, CI_CURPROCPADDR(t1)
99c102,103
<       PTR_L   t0, curprocpaddr
---
>       GET_CPU_INFO(t1, t0)
>       PTR_L   t0, CI_CURPROCPADDR(t1)
114c118,119
<       PTR_L   t0, curprocpaddr
---
>       GET_CPU_INFO(t1, t0)
>       PTR_L   t0, CI_CURPROCPADDR(t1)
134c139,140
<       PTR_L   t0, curprocpaddr
---
>       GET_CPU_INFO(t1, t0)
>       PTR_L   t0, CI_CURPROCPADDR(t1)
152c158,159
<       PTR_L   t0, curprocpaddr
---
>       GET_CPU_INFO(t1, t0)
>       PTR_L   t0, CI_CURPROCPADDR(t1)
168c175,176
<       PTR_L   t0, curprocpaddr
---
>       GET_CPU_INFO(t1, t0)
>       PTR_L   t0, CI_CURPROCPADDR(t1)
Index: lcore_float.S
===================================================================
RCS file: /cvs/src/sys/arch/mips64/mips64/lcore_float.S,v
retrieving revision 1.15
diff -r1.15 lcore_float.S
40,41d39
< #define curproc       (cpu_info_primary + CI_CURPROC)
<
455c453,454
<       PTR_L   a0, curprocpaddr        # first arg is ptr to CPU regs
---
>       GET_CPU_INFO(t2, t3)
>       PTR_L   a0, CI_CURPROCPADDR(t2) # first arg is ptr to CPU regs
475c474,475
<       PTR_L   a3, curprocpaddr        # first arg is ptr to CPU regs
---
>       GET_CPU_INFO(t2, t3)
>       PTR_L   a3, CI_CURPROCPADDR(t2) # first arg is ptr to CPU regs
489c489,490
<       PTR_L   a0, curproc             # get current process
---
>       GET_CPU_INFO(t2, t3)
>       PTR_L   a0, CI_CURPROC(t2)      # get current process
Index: tlbhandler.S
===================================================================
RCS file: /cvs/src/sys/arch/mips64/mips64/tlbhandler.S,v
retrieving revision 1.16
diff -r1.16 tlbhandler.S
61a62,73
>       j       tlb_miss_handler
>       nop
>       .end    tlb_miss
>
>       .globl  e_tlb_miss
> e_tlb_miss:
>       .set    at
>
>       .globl  tlb_miss_handler
>       .set    noat
>       .ent    tlb_miss_handler, 0
> tlb_miss_handler:
85c97,98
<       PTR_L   k1, curprocpaddr
---
>       GET_CPU_INFO(k1, k0)
>       PTR_L   k1, CI_CURPROCPADDR(k1)
117,120c130,131
<       .end    tlb_miss
<
<       .globl  e_tlb_miss
< e_tlb_miss:
---
>       .end    tlb_miss_handler
>       .set    at
128a140,153
>       j       xtlb_miss_handler
>       nop
>       .end    xtlb_miss
>
>       .globl  e_xtlb_miss
> e_xtlb_miss:
>       .set    at
>
>       .globl  xtlb_miss_handler
>       .set    noat
>       .ent    xtlb_miss_handler, 0
> xtlb_miss_handler:
> /*****************************  End of code copied to exception vector */
>
143a169,173
>       nop
>       GET_CPU_INFO(k1, k0)
>       PTR_L   k1, CI_CURPROCPADDR(k1)
>       dmfc0   k0, COP_0_BAD_VADDR
>       PTR_SRL k0, k0, SEGSHIFT
145d174
<       PTR_L   k1, curprocpaddr
164,167c193
<       .end    xtlb_miss
<
<       .globl  e_xtlb_miss
< e_xtlb_miss:
---
>       .end    xtlb_miss_handler
169d194
< /*****************************  End of code copied to exception vector */
329c354,355
<       PTR_L   k1, curprocpaddr
---
>       GET_CPU_INFO(k1, k0)
>       PTR_L   k1, CI_CURPROCPADDR(k1)

美しくないから気に入らないが、一応動いた。

Option? 5
Command Monitor.  Type "exit" to return to the menu.
>> bootp()192.168.3.1:bsd
Setting $netaddr to 192.168.3.2 (from server )
Obtaining bsd from server
5898464+492872 entry: 0xa800000020020000
ARCS64 Firmware Version 64.0
Found SGI-IP30, setting up.
Initial setup done, switching console.
cpu_id:0
Copyright (c) 1982, 1986, 1989, 1991, 1993
        The Regents of the University of California.  All rights reserved.
Copyright (c) 1995-2009 OpenBSD. All rights reserved.  http://www.OpenBSD.org

OpenBSD 4.5-current (OCTANE_RAMDISK_MP) #26: Thu May 14 17:01:28 JST 2009

real mem = 1073741824 (1024MB)
rsvd mem = 1064960 (1MB)
avail mem = 1013772288 (966MB)
mainbus0 at root
test1:0xa80000002060b800
test3:0
cpu_number():0
curcpu():0xa800000020633580
test2:0xa80000002060b800
cpu0 at mainbus0: MIPS R12000 CPU rev 3.5 400 MHz with R10000 FPU rev 0.0
cpu0: cache L1-I 32KB D 32KB 2 way, L2 2048KB 2 way
clock0 at mainbus0: ticker on int5 using count register
xbow0 at mainbus0: XBow revision 5
xheart0 at xbow0 widget 8: Heart revision 6
onewire0 at xheart0
owserial0 at onewire0 family 0x0b sn 0000004d74fa
owserial0: "PM20400MHZ" p/n 030-1476-001, serial KWL381
"Odyssey" revision 2 at xbow0 widget 11 not configured
xbridge0 at xbow0 widget 15: Bridge revision 4
pci0 at xbridge0 bus 0
isp0 at pci0 dev 0 function 0 "QLogic ISP1020" rev 0x05: irq 0
isp0: invalid NVRAM header
scsibus0 at isp0: 16 targets, initiator 0
sd0 at scsibus0 targ 1 lun 0: <QUANTUM, ATLAS_V__9_SCA, 0238> SCSI3 0/direct fixed
sd0: 8682MB, 512 bytes/sec, 17781964 sec total
isp1 at pci0 dev 1 function 0 "QLogic ISP1020" rev 0x05: irq 1
isp1: invalid NVRAM header
scsibus1 at isp1: 16 targets, initiator 0
ioc0 at pci0 dev 2 function 0 "SGI IOC3" rev 0x01
onewire1 at ioc0
owmac0 at onewire1 family 0x09 sn 000002d29696
owmac0: Ethernet Address 08:00:69:13:67:82
owserial1 at onewire1 family 0x0b sn 0000004d4ee4
owserial1: "FP1" p/n 030-0891-003, serial LMR447
owserial2 at onewire1 family 0x0b sn 0000004e12fb
owserial2: "PWR.SPPLY.ER" p/n 060-0035-002, serial AAE0420107
ioc0: superio irq 4, ethernet irq 2
com0 at ioc0 base 0x00020178: ns16550a, 16 byte fifo
com0: console
com1 at ioc0 base 0x00020170: ns16550a, 16 byte fifo
iockbc at ioc0 not configured
ef at ioc0 base 0x000000f0 not configured
dsrtc at ioc0 not configured
"SGI Rad1" rev 0xc0 at pci0 dev 3 function 0 not configured
rd0: fixed, 8192 blocks
boot device: sd0
root on rd0a swap on rd0b dump on rd0b
WARNING: No TOD clock, believing file system.
WARNING: CHECK AND RESET THE DATE!
erase ^?, werase ^W, kill ^U, intr ^C, status ^T
(I)nstall, (U)pgrade or (S)hell?
(I)nstall, (U)pgrade or (S)hell?
(I)nstall, (U)pgrade or (S)hell? s
#
#
# ps
sh: ps: not found
# ls
.profile     etc          install.sub  sbin         usr
bin          install      mnt          tmp          var
dev          install.md   mnt2         upgrade
# ls /bin
cat      cp       df       expr     ln       mt       rm       sync
chgrp    cpio     ed       hostname ls       mv       sh       tar
chmod    dd       eject    ksh      mkdir    pax      stty
#

おk。次行くぞコラ。