PERFORCE change 119002 for review

John Baldwin jhb at freebsd.org
Mon Apr 30 18:34:08 UTC 2007


On Monday 30 April 2007 01:24:53 pm Alexey Tarasov wrote:
> http://perforce.freebsd.org/chv.cgi?CH=119002
> 
> Change 119002 by taleks at 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


More information about the p4-projects mailing list