From owner-p4-projects@FreeBSD.ORG Mon Apr 30 18:34:08 2007 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 434CE16A408; Mon, 30 Apr 2007 18:34:08 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id DEC8916A403 for ; Mon, 30 Apr 2007 18:34:07 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (66-23-211-162.clients.speedfactory.net [66.23.211.162]) by mx1.freebsd.org (Postfix) with ESMTP id 5C61713C455 for ; Mon, 30 Apr 2007 18:34:07 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from localhost.corp.yahoo.com (john@localhost [127.0.0.1]) (authenticated bits=0) by server.baldwin.cx (8.13.8/8.13.8) with ESMTP id l3UIXsJC015709; Mon, 30 Apr 2007 14:34:05 -0400 (EDT) (envelope-from jhb@freebsd.org) From: John Baldwin To: Alexey Tarasov Date: Mon, 30 Apr 2007 14:32:39 -0400 User-Agent: KMail/1.9.6 References: <200704301724.l3UHOrtc053926@repoman.freebsd.org> In-Reply-To: <200704301724.l3UHOrtc053926@repoman.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200704301432.40011.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.0.2 (server.baldwin.cx [127.0.0.1]); Mon, 30 Apr 2007 14:34:05 -0400 (EDT) X-Virus-Scanned: ClamAV 0.88.3/3184/Mon Apr 30 09:51:57 2007 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=4.2 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.1.3 X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on server.baldwin.cx Cc: Perforce Change Reviews Subject: Re: PERFORCE change 119002 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2007 18:34:08 -0000 On Monday 30 April 2007 01:24:53 pm Alexey Tarasov wrote: > http://perforce.freebsd.org/chv.cgi?CH=119002 > > Change 119002 by taleks@taleks_th on 2007/04/30 17:24:19 > > Started adding of isr_install sys call. and call gate selector (from ring 0 to ring 3) to BTX . You don't really need to run the ISR in protected mode. If you check the PXE docs, all you need to do is set a global variable and make a !PXE call. You can write a real-mode ISR to do that and just chain that into the appropriate IRQ. Will be a lot simpler I think. > Affected files ... > > .. //depot/projects/soc2007/taleks-pxe_http/btx_mod/btx/btx.S#2 edit > .. //depot/projects/soc2007/taleks-pxe_http/btx_mod/lib/btxsys.s#2 edit > .. //depot/projects/soc2007/taleks-pxe_http/btx_mod/lib/btxv86.h#2 edit > > Differences ... > > ==== //depot/projects/soc2007/taleks-pxe_http/btx_mod/btx/btx.S#2 (text+ko) ==== > > @@ -44,6 +44,7 @@ > .set SEL_UCODE,0x28|3 # User code > .set SEL_UDATA,0x30|3 # User data > .set SEL_TSS,0x38 # TSS > + .set SEL_CALLGATE,0x40 # super2user callgate > /* > * Task state segment fields. > */ > @@ -56,6 +57,7 @@ > */ > .set SYS_EXIT,0x0 # Exit > .set SYS_EXEC,0x1 # Exec > + .set SYS_ISR_INSTALL,0x2 # ISR_install > /* > * V86 constants. > */ > @@ -620,7 +622,7 @@ > * reads count of words from saved %cx > * returns success by setting %ah to 0 > */ > -int15_87: pushl %esi # Save > +int15_87: pushl %esi # Save > pushl %edi # registers > movl 0x3C(%ebp),%edi # Load ES > movzwl 0x4(%ebp),%eax # Load user's SI > @@ -841,7 +843,9 @@ > /* > * System Call. > */ > -intx30: cmpl $SYS_EXEC,%eax # Exec system call? > +intx30: cmpl $SYS_ISR_INSTALL, %eax # is isr_install? > + je intx30.2 # yes > + cmpl $SYS_EXEC,%eax # Exec system call? > jne intx30.1 # No > pushl %ss # Set up > popl %es # all > @@ -866,6 +870,56 @@ > intx30.1: orb $0x1,%ss:btx_hdr+0x7 # Flag reboot > jmp exit # Exit > /* > + * Here we need to modify IDT in such way, that at interrupt handle > + * will be run isr_trump, which role is to run provided function in user space. > + */ > +intx30.2: xorl %eax,%eax # clear eax > + > +/* > + * updating call gate > + */ > + mov gdtdesc,%edi # calculating descriptors entry > + add $SEL_CALLGATE, %edi # pointing callgate selector > + > + popl %eax # got 32bit offset to handler > + > + mov %ax, (%di) # +0: store offset > + shr $0x10, %eax # getting high word > + mov %ax, 0x6(%di) # +6: handler offset 16..31 > +/* > + * installing handler > + */ > + xor %ax,%ax # clear eax > + pop %ah # getting interrupt number > + mul $0x08,%ax # > + > + mov $MEM_IDT, %di # point to IDT. > + add %ax,%di # calculate entry > + > + mov $SEL_SCODE,%dh # supervisor code selector > + mov user_isr_call, %ax # tramp address > + > + mov $0x8e, %dl # i386+ interrupt gate, DPL=0 > + > + mov %ax,(%di) # 0: handler offset 0..15 > + mov %dh,0x2(%di) # +2: dest selector > + # +4: 000:word_count > + mov %dl,0x5(%di) # +5: P:DPL:type > + # +6: handler offset 16..31 > +/* > + * NOTE: do we need flush caches? > + */ > + iret # return from syscall > + > +user_isr_call: > +/* > + * NOTE: do we need update CS,DS & etc before and restore after? > +*/ > + # far call via callgate selector > + lcall $SEL_S2U_CALL # NOTE: find how it must be. > + iret # return from interrupt handler > + > +/* > * Dump structure [EBX] to [EDI], using format string [ESI]. > */ > dump.0: stosb # Save char > @@ -1098,6 +1152,7 @@ > .word 0xffff,MEM_USR,0xfa00,0xcf# SEL_UCODE > .word 0xffff,MEM_USR,0xf200,0xcf# SEL_UDATA > .word _TSSLM,MEM_TSS,0x8900,0x0 # SEL_TSS > + .word 0x5, 0x0, 0xec00,0x0 # SEL_CALLGATE > gdt.1: > /* > * Pseudo-descriptors. > @@ -1165,6 +1220,7 @@ > .ascii "ss:esp" # "ss:esp=" > .byte 0x80|DMP_MEM|DMP_EOL,0x0 # "00 00 ... 00 00\n" > .asciz "BTX halted\n" # End > + > /* > * End of BTX memory. > */ > > ==== //depot/projects/soc2007/taleks-pxe_http/btx_mod/lib/btxsys.s#2 (text+ko) ==== > > @@ -24,6 +24,7 @@ > # > .global __exit > .global __exec > + .global __isr_install > # > # Constants. > # > @@ -38,3 +39,8 @@ > # > __exec: movl $0x1,%eax # BTX system > int $INT_SYS # call 0x1 > +# > +# System call: isr_install > +# > +__isr_install: movl $0x2,%eax # BTX system > + int $INT_SYS # call 0x2 > > ==== //depot/projects/soc2007/taleks-pxe_http/btx_mod/lib/btxv86.h#2 (text+ko) ==== > > @@ -59,5 +59,10 @@ > > void __exit(int) __attribute__((__noreturn__)); > void __exec(caddr_t, ...); > +/* > + * Installs interrupt handler function for interrupt int_num. > + * caddr_t - in userspace. > + */ > +void __isr_install(caddr_t isr, uint8_t int_num); > > #endif /* !_BTXV86_H_ */ > -- John Baldwin