From owner-p4-projects Sun Nov 17 23:10:57 2002 Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id B5DA937B404; Sun, 17 Nov 2002 23:10:48 -0800 (PST) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4C79737B401 for ; Sun, 17 Nov 2002 23:10:48 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id EA68143E3B for ; Sun, 17 Nov 2002 23:10:47 -0800 (PST) (envelope-from marcel@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.6/8.12.6) with ESMTP id gAI77umV065429 for ; Sun, 17 Nov 2002 23:07:56 -0800 (PST) (envelope-from marcel@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.6/8.12.6/Submit) id gAI77uCD065423 for perforce@freebsd.org; Sun, 17 Nov 2002 23:07:56 -0800 (PST) Date: Sun, 17 Nov 2002 23:07:56 -0800 (PST) Message-Id: <200211180707.gAI77uCD065423@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to marcel@freebsd.org using -f From: Marcel Moolenaar Subject: PERFORCE change 21219 for review To: Perforce Change Reviews Sender: owner-p4-projects@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG http://perforce.freebsd.org/chv.cgi?CH=21219 Change 21219 by marcel@marcel_nfs on 2002/11/17 23:07:22 Add EPC_CALLSYS_NOERROR, which has the same purpose as CALLSYS_NOERROR, but uses the epc framework. In order to keep each syscall-site small, we divert from the normal runtime call sequence. Instead, we pass the return address in p6. The syscall number is passed in r8 and the previous CFM is passed on in r9. While here, flesh out some regset save/restore functions. A nice thing about them is that they help structure the problem, and thus keep your mind from folding but other than that they're probably no good. I'll continue working on them, but I don't think they'll have a long life ahead of them... The _{get|set}_special probably needs an async and a sync variant... Affected files ... .. //depot/projects/ia64/sys/ia64/ia64/syscall.s#2 edit .. //depot/projects/ia64/sys/ia64/include/_regset.h#2 edit .. //depot/projects/ia64/sys/ia64/include/asm.h#6 edit Differences ... ==== //depot/projects/ia64/sys/ia64/ia64/syscall.s#2 (text+ko) ==== @@ -51,6 +51,18 @@ * * Lightweight syscalls can be implemented by accessing kernel structures * or calling kernel functions without this setup. + * + * Syscalls don't follow the calling convention completely. The reason + * for this is that it would create unnecessary overhead. Arguments to + * syscalls are: + * r8 - syscall number + * r9 - ar.pfs + * in0-in7 - syscall arguments + * b6 - return address + * + * Syscalls return: + * r8+r9 - syscall return value(s) + * r10 - syscall error flag */ .section .text.syscall, "ax" @@ -69,5 +81,198 @@ ;; .endp epc_syscall -/* Make sure we don't cross the page boundary */ - .org PAGE_SIZE + +/* + * _{get|set}_special + * Do not follow runtime convention! + */ +/* + * inputs: r16 struct _special + * r17 return address + */ +ENTRY(_get_special, 0) +{ .mii + flushrs + add r2=8,r16 + add r3=16,r16 + ;; +} +{ .mmi + .mem.offset 0,0 + st8.spill [r2]=r1,16 // gp + .mem.offset 8,0 + st8.spill [r3]=r12,16 // sp + mov b6=r17 + ;; +} +{ .mmi + .mem.offset 16,0 + st8.spill [r2]=r13,16 // tp + mov r17=ar.rsc + mov r18=b0 + ;; +} +{ .mmi + st8 [r3]=r18,16 // rp + mov ar.rsc=0 + mov r19=pr + ;; +} +{ .mmi + st8 [r2]=r19,16 // pr + mov r20=ar.unat + mov r21=ar.pfs + ;; +} +{ .mmi + st8 [r16]=r20 // nat + st8 [r3]=r17,16 // ar.rsc + nop 0 +} +{ .mmi + st8 [r2]=r21,16 // ar.pfs + mov r22=ar.bsp + nop 1 + ;; +} +{ .mmi + st8 [r3]=r22,16 // ar.bspstore + mov r23=ar.rnat + nop 2 + ;; +} +{ .mmi + st8 [r2]=r23 // ar.rnat + mov r24=ar.fpsr + nop 3 + ;; +} +{ .mmb + st8 [r3]=r24 // ar.fpsr + mov ar.rsc=r17 + br.sptk b6 + ;; +} +END(_get_special) + +/* + * inputs: r16 struct _special + */ +ENTRY(_set_special, 0) +END(_set_special) + +/* + * _{get|set}_callee_saved + */ +ENTRY(_get_callee_saved, 1) +{ .mii + mov r31=ar.unat + add r2=8,in0 + add r3=16,in0 + ;; +} +{ .mmi + .mem.offset 0,0 + st8.spill [r2]=r4,16 // r4 + .mem.offset 8,0 + st8.spill [r3]=r5,16 // r5 + mov r29=b1 + ;; +} +{ .mmi + .mem.offset 16,0 + st8.spill [r2]=r6,16 // r6 + .mem.offset 24,0 + st8.spill [r3]=r7,16 // r7 + mov r28=b2 + ;; +} +{ .mmi + st8 [r2]=r29,16 // b1 + mov r30=ar.unat + mov r27=b3 + ;; +} +{ .mmi + st8 [in0]=r30 // nat + st8 [r3]=r28,16 // b2 + mov r26=b4 + ;; +} +{ .mmi + st8 [r2]=r27,16 // b3 + st8 [r3]=r26,16 // b4 + mov r25=b5 + ;; +} +{ .mmi + st8 [r2]=r25,16 // b5 + st8 [r3]=r31 // ar.unat + mov r24=ar.lc + ;; +} +{ .mfb + st8 [r2]=r24 // ar.lc + nop 0 + br.ret.sptk rp + ;; +} +END(_get_callee_saved) + +ENTRY(_set_callee_saved, 1) +{ .mii + ld8 r31=[in0] // nat + add r2=8,in0 + add r3=16,in0 + ;; +} +{ .mmb + mov ar.unat=r31 + lfetch [r3] + nop 0 + ;; +} +{ .mmi + ld8.fill r4=[r2],16 // r4 + ld8.fill r5=[r3],16 // r5 + nop 1 + ;; +} +{ .mmb + ld8.fill r6=[r2],16 // r6 + ld8.fill r7=[r3],16 // r7 + nop 2 + ;; +} +{ .mmi + ld8 r29=[r2],16 // b1 + ;; + ld8 r28=[r3],16 // b2 + mov b1=r29 + ;; +} +{ .mmi + ld8 r27=[r2],16 // b3 + ld8 r26=[r3],16 // b4 + mov b2=r28 + ;; +} +{ .mmi + ld8 r25=[r2],16 // b5 + ld8 r24=[r3] // ar.unat + mov b3=r27 + ;; +} +{ .mii + ld8 r23=[r2] // ar.lc + mov b4=r26 + mov b5=r25 + ;; +} +{ .mib + mov ar.unat=r24 + mov ar.lc=r23 + br.ret.sptk rp + ;; +} +END(_set_callee_saved) ==== //depot/projects/ia64/sys/ia64/include/_regset.h#2 (text+ko) ==== @@ -53,22 +53,20 @@ * Special registers. */ struct _special { - uint64_t flags; /* PSR bits and others... */ + uint64_t nat; /* NaT after spilling. */ uint64_t gr[3]; #define _GR1 0 /* GP */ #define _GR12 1 /* SP */ #define _GR13 2 /* TP */ - uint64_t nat; /* NaT *after* spilling. */ uint64_t br[1]; #define _BR0 0 /* RP */ - uint64_t ip; uint64_t pr; uint64_t ar_rsc; uint64_t ar_pfs; uint64_t ar_bspstore; - uint64_t ar_bsp; /* or ndirty? */ uint64_t ar_rnat; uint64_t ar_fpsr; + uint64_t __spare__; }; struct _special_fp { @@ -80,19 +78,19 @@ * Preserved registers. */ struct _callee_saved { + uint64_t nat; /* NaT after spilling. */ uint64_t gr[4]; #define _GR4 0 #define _GR5 1 #define _GR6 2 #define _GR7 3 - uint64_t nat; /* NaT *after* spilling. */ uint64_t br[5]; #define _BR1 0 #define _BR2 1 #define _BR3 2 #define _BR4 3 #define _BR5 4 - uint64_t ar_unat; /* All NaT bits. */ + uint64_t ar_unat; /* NaT before spilling. */ uint64_t ar_lc; }; ==== //depot/projects/ia64/sys/ia64/include/asm.h#6 (text+ko) ==== @@ -151,16 +151,27 @@ label: ASCIZ msg; \ .text; + /* * System call glue. */ -#define SYSCALLNUM(name) \ - SYS_ ## name +#define SYSCALLNUM(name) SYS_ ## name +#define GATEWAY_PAGE ((5 << 61) - 1048576) #define CALLSYS_NOERROR(name) \ mov r15=SYSCALLNUM(name); \ break 0x100000 ;; +#define EPC_CALLSYS_NOERROR(name) \ +{ .mlx ; \ + alloc r9 = ar.pfs, 0, 0, 8, 0 ; \ + movl r14 = GATEWAY_PAGE ;; } \ +{ .mib ; \ + mov r8 = SYSCALLNUM(name) ; \ + mov b7 = r14 ; \ + br.call.sptk b6 = b7 } + + /* * WEAK_ALIAS: create a weak alias (ELF only). */ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe p4-projects" in the body of the message