From owner-p4-projects@FreeBSD.ORG Mon Apr 30 17:24:54 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 60CF516A409; Mon, 30 Apr 2007 17:24:54 +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 0B07216A401 for ; Mon, 30 Apr 2007 17:24:54 +0000 (UTC) (envelope-from taleks@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41]) by mx1.freebsd.org (Postfix) with ESMTP id B9EB713C45B for ; Mon, 30 Apr 2007 17:24:53 +0000 (UTC) (envelope-from taleks@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.8/8.13.8) with ESMTP id l3UHOrdY053929 for ; Mon, 30 Apr 2007 17:24:53 GMT (envelope-from taleks@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.8/8.13.8/Submit) id l3UHOrtc053926 for perforce@freebsd.org; Mon, 30 Apr 2007 17:24:53 GMT (envelope-from taleks@FreeBSD.org) Date: Mon, 30 Apr 2007 17:24:53 GMT Message-Id: <200704301724.l3UHOrtc053926@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to taleks@FreeBSD.org using -f From: Alexey Tarasov To: Perforce Change Reviews Cc: Subject: 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 17:24:54 -0000 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 . 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_ */