Plan 9 from Bell Labs’s /usr/web/sources/extra/9hist/pc/l.s

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


## diffname pc/l.s 1991/0614
## diff -e /dev/null /n/bootesdump/1991/0614/sys/src/9/safari/l.s
0a

/*
 * Boot first processor
 */
TEXT	start(SB),$0

	/* clear bss */
	CALL	main(SB)
	/* never returns */


TEXT	traptab(SB),$0

	CALL	noerrcode(SB)	/* divide */
	CALL	noerrcode(SB)	/* debug */
	CALL	noerrcode(SB)	/* non maskable interrupt */
	CALL	noerrcode(SB)	/* breakpoint */
	CALL	noerrcode(SB)	/* overflow */
	CALL	noerrcode(SB)	/* bounds check */
	CALL	noerrcode(SB)	/* invalid opcode */
	CALL	noerrcode(SB)	/* coprocessor not available */
	CALL	errcode(SB)	/* double fault */
	CALL	noerrcode(SB)	/* coprocessor segment overrun */
	CALL	errcode(SB)	/* invalid tss */
	CALL	errcode(SB)	/* segment not present */
	CALL	errcode(SB)	/* stack exception */	
	CALL	errcode(SB)	/* general protection exception */
	CALL	errcode(SB)	/* page fault */
	CALL	noerrcode(SB)	/* coprocessor error */
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)
	CALL	noerrcode(SB)

TEXT	noerrcode(SB),$0
	PUSH	EAX
	/* drop through */
TEXT	errcode(SB),$0
	PUSH	EAX
	PUSH	EBX
	PUSH	ECX
	PUSH	EDX
	PUSH	EBP
	PUSH	ESI
	PUSH	EDI
	CALL	trap(SB)
	POP	EDI
	POP	ESI
	POP	EBP
	POP	EDX
	POP	ECX
	POP	EBX
	POP	EAX
	ADD	$8,ESP	/* jump over error code + return addr */
	IRET
.
## diffname pc/l.s 1991/0619
## diff -e /n/bootesdump/1991/0614/sys/src/9/safari/l.s /n/bootesdump/1991/0619/sys/src/9/safari/l.s
292a

TEXT	trap(SB),$0

	RET

TEXT	main(SB),$0

	RET
.
284,291c
	ADDL	$4,ESP			/* drop trap number */
	POPL	EDI
	POPL	ESI
	POPL	EBP
	POPL	EDX
	POPL	ECX
	POPL	EBX
	POPL	EAX
	ADDL	$4,ESP			/* drop error code */
.
276,282c

	XCHGL	(ESP),EAX
	/* fall through */

TEXT	saveregs(SB),$0

george:
	PUSHL	EBX
	MOVL	$noerrcode(SB),EBX	/* calculate trap number */
	SUBL	EAX,EBX			/* ... */
	SHRL	$1,EBX			/* ... */
	PUSHL	ECX
	PUSHL	EDX
	PUSHL	EBP
	PUSHL	ESI
	PUSHL	EDI
	PUSHL	EBX			/* save trap number */
.
273,274c

	PUSHL	EAX
	MOVL	4(ESP),EAX
/*	JMP	george /**/

.
11a
/*
 *  trap vector, each instruction is 4 bytes long
 */
.
3c
 *  boot first processor
.
## diffname pc/l.s 1991/0620
## diff -e /n/bootesdump/1991/0619/sys/src/9/safari/l.s /n/bootesdump/1991/0620/sys/src/9/safari/l.s
15,31c
divtrap:
	PUSHL	$0
	PUSHL	$0
	JMP	alltrap
debtrap:
	PUSHL	$0
	PUSHL	$1
	JMP	alltrap
nmitrap:
	PUSHL	$0
	PUSHL	$2
	JMP	alltrap
bptrap:
	PUSHL	$0
	PUSHL	$3
	JMP	alltrap
oftrap:
	PUSHL	$0
	PUSHL	$4
	JMP	alltrap
boundtrap:
	PUSHL	$0
	PUSHL	$5
	JMP	alltrap
invtrap:
	PUSHL	$0
	PUSHL	$6
	JMP	alltrap
nocotrap:
	PUSHL	$0
	PUSHL	$7
	JMP	alltrap
dfault:
	PUSHL	$8
	JMP	alltrap
csotrap:
	PUSHL	$0
	PUSHL	$9
	JMP	alltrap
tsstrap:
	PUSHL	$0
	PUSHL	$10
	JMP	alltrap
segtrap:
	PUSHL	$11
	JMP	alltrap
stacktrap:
	PUSHL	$12
	JMP	alltrap
prottrap:
	PUSHL	$13
	JMP	alltrap
pagefault:
	PUSHL	$14
	JMP	alltrap
cetrap:
	PUSHL	$0
	PUSHL	$15
	JMP	alltrap
.
13c
 *  standard traps
.
## diffname pc/l.s 1991/0622
## diff -e /n/bootesdump/1991/0620/sys/src/9/safari/l.s /n/bootesdump/1991/0622/sys/src/9/safari/l.s
342,355c
	POPAL
	IRETL
.
323,340c
alltrap:
	PUSHAL
.
319,321c
	PUSHL	$0
	PUSHL	$16
	JMP	alltrap
.
317c
TEXT	invtrap(SB),$0
.
74,315d
70c

TEXT	trap15(SB),$0

.
67c

TEXT	trap14(SB),$0

.
64c

TEXT	trap13(SB),$0

.
61c

TEXT	trap12(SB),$0

.
58c

TEXT	trap11(SB),$0

.
54c

TEXT	trap10(SB),$0

.
50c

TEXT	trap9(SB),$0

.
47c

TEXT	trap8(SB),$0

.
43c

TEXT	trap7(SB),$0

.
39c

TEXT	trap6(SB),$0

.
35c

TEXT	trap5(SB),$0

.
31c

TEXT	trap4(SB),$0

.
27c

TEXT	trap3(SB),$0

.
23c

TEXT	trap2(SB),$0

.
19c

TEXT	trap1(SB),$0

.
15c

TEXT	trap0(SB),$0

.
11d
3c
 *  boot processor
.
## diffname pc/l.s 1991/0623
## diff -e /n/bootesdump/1991/0622/sys/src/9/safari/l.s /n/bootesdump/1991/0623/sys/src/9/safari/l.s
118a

	RET

TEXT	trap(SB),$0
.
117a
/*
 *  stubs
 */
.
115a
	ADDL	$#8,SP		/* pop the trap and error codes */
.
112a

.
111a
/*
 *  common trap code
 */
.
108c
	PUSHL	$0	/* put on an error code */
.
105a
/*
 *  invalid trap
 */
.
102c
	PUSHL	$0	/* put on an error code */
.
76c
	PUSHL	$0	/* put on an error code */
.
70c
	PUSHL	$0	/* put on an error code */
.
59c
	PUSHL	$0	/* put on an error code */
.
53c
	PUSHL	$0	/* put on an error code */
.
47c
	PUSHL	$0	/* put on an error code */
.
41c
	PUSHL	$0	/* put on an error code */
.
35c
	PUSHL	$0	/* put on an error code */
.
29c
	PUSHL	$0	/* put on an error code */
.
23c
	PUSHL	$0	/* put on an error code */
.
18d
16a
	PUSHL	$0	/* put on an error code */
.
14d
12c
 *  first 16 ``standard'' traps
.
## diffname pc/l.s 1991/0625
## diff -e /n/bootesdump/1991/0623/sys/src/9/safari/l.s /n/bootesdump/1991/0625/sys/src/9/safari/l.s
124,134d
122c
	POPL	DS
	ADDL	$8,SP		/* pop the trap and error codes */
.
119a
	MOVL	$KDSEL, AX
	MOVW	AX, DS
.
118a
	PUSHL	DS
.
7c
	CLI			/* disable interrupts */
	MOVW	$NULLSEL,IDTR	/* force shutdown on error */

	/* point data segment at low memory */
	XORL	AX,AX
	MOVW	AX,DS

	/* load gdt address (valid after paging) */
	LEAL	gdtptr(SB),AX
	MOVL	-KZERO(AX),GDTR

.
1a
GLOBL	gdtptr(SB),$6

	DATA	gdtptr+0(SB)/2, $(6*8)
	DATA	gdtptr+2(SB)/4, $gdt(SB)

.
0a
#include "mem.h"
.
## diffname pc/l.s 1991/0626
## diff -e /n/bootesdump/1991/0625/sys/src/9/safari/l.s /n/bootesdump/1991/0626/sys/src/9/safari/l.s
141c
/*	POPL	DS	/**/
.
138c
/*	MOVW	AX, DS /**/
.
135c
/*	PUSHL	DS	/**/
.
22c
/*	MOVL	(AX),GDTR /**/
.
20c
	/* point CPU at the interrupt/trap table */
.
18c
/*	MOVW	AX,DS /**/
.
15a
	/* point CPU at the interrupt/trap table */
	LEAL	idtptr(SB),AX
/*	MOVL	(AX),IDTR /**/

.
14d
8a
 *  pointer to idt (must be in first 64K of program)
 */
GLOBL	idtptr(SB),$6

	DATA	idtptr+0(SB)/2, $(6*8)
	DATA	idtptr+2(SB)/4, $idt(SB)

/*
.
5c
	DATA	gdtptr+0(SB)/2, $(5*8)
.
2a
/*
 *  pointer to initial gdt (must be in first 64K of program)
 */
.
## diffname pc/l.s 1991/0627
## diff -e /n/bootesdump/1991/0626/sys/src/9/safari/l.s /n/bootesdump/1991/0627/sys/src/9/safari/l.s
38c
	/* point CPU at the global descriptor table */
	MOVL	gdtptr(SB),GDTR

	/* switch to protected mode */
	MOVL	CR0,AX
	ORL	$1,AX
	MOVL	AX,CR0

	/* clear prefetch buffer */
	JMP	flush

/*
 *  come here in USE16 protected mode
 */
flush:
	/* map data and stack address to physical memory */
	MOVW	$SELECTOR(1, SELGDT, 0),AX
	MOVW	AX,DS
	MOVW	AX,ES
	MOVW	AX,SS

	/* switch to 32 bit code */
	JMPFAR	SELECTOR(2, SELGDT, 0):start32

/*
 *  come here in USE32 protected mode
 */
TEXT	start32(SB),$0

	/* clear bss (should use REP) */
	MOVL	$edata(SB),SI
	MOVL	$edata+4(SB),DI
	MOVL	$end(SB),CX
	SUBL	DI,CX
	SHRL	$2,CX
	XORL	AX,AX
	MOVL	AX,edata(SB)
	CLD
	REP
	MOVSL	(SI),(DI)

	/* set up stack */
	MOVL	$mach0(SB),AX
	MOVL	A0, m(SB)
	MOVL	$0, 0(A0)
	MOVL	A0, A7
	ADDL	$(MACHSIZE-4), A7	/* start stack under machine struct */
	MOVL	$0, u(SB)

	CALL	main(SB),$0
.
34,36c
	/* point CPU at the interrupt descriptor table */
	MOVL	tgdt(SB),IDTR
.
32c
	MOVW	AX,DS
.
26,29d
22,23c
start16:
.
20c
 *  come here in (16bit) real-address mode
.
16,17c
	WORD	$(3*8)
	LONG	$tgdt(SB)
.
14c
TEXT	tgdtptr(SB),$0
.
12c
 *  pointer to initial gdt
.
10a
	/* data segment descriptor for 4 gigabytes (PL 0) */
	LONG	SEGG|SEGB|(0xF<<16)|SEGP|SEGPL(0)|SEGDATA|SEGW
	LONG	0xFFFF

	/* exec segment descriptor for 4 gigabytes (PL 0) */
	LONG	SEGG|SEGD|(0xF<<16)|SEGP|SEGPL(p)|SEGEXEC|SEGR
	LONG	0xFFFF

.
8,9c
	/* null descriptor */
	LONG	$0
	LONG	$0
.
6c
TEXT	tgdt(SB),$0
.
4c
 *  gdt to get us to 32-bit/segmented/unpaged mode
.
2a
TEXT	start(SB),$0

	JMP	start16

.
## diffname pc/l.s 1991/0628
## diff -e /n/bootesdump/1991/0627/sys/src/9/safari/l.s /n/bootesdump/1991/0628/sys/src/9/safari/l.s
88,91c
	MOVL	AX, m(SB)
	MOVL	$0, 0(AX)
	MOVL	AX, SP
	ADDL	$(MACHSIZE-4), AX	/* start stack under machine struct */
.
67c
/*	JMPFAR	SELECTOR(2, SELGDT, 0):start32 /**/
.
30c
	LONG	tgdt(SB)
.
21,22c
	LONG	$(SEGG|SEGD|(0xF<<16)|SEGP|SEGPL(0)|SEGEXEC|SEGR)
	LONG	$(0xFFFF)
.
17,18c
	LONG	$(SEGG|SEGB|(0xF<<16)|SEGP|SEGPL(0)|SEGDATA|SEGW)
	LONG	$(0xFFFF)
.
4d
## diffname pc/l.s 1991/0629
## diff -e /n/bootesdump/1991/0628/sys/src/9/safari/l.s /n/bootesdump/1991/0629/sys/src/9/safari/l.s
199,212c
GLOBL	mach0+0(SB), $MACHSIZE
GLOBL	u(SB), $4
GLOBL	m(SB), $4
.
195,197c
loop:
	JMP	loop
.
193c
	MOVL	$0xb8100,BX
	MOVB	$0x34,AL
	MOVB	AL,(BX)
	INCW	BX
	MOVB	$0x43,AL
	MOVB	AL,(BX)
.
191c
 *	print a blue 4 on a red background
.
107,189c
	CALL	main(SB)
.
105c
	/*
	 *  stack and mach
	 */
	MOVL	$mach0(SB),SP
	MOVL	SP,m(SB)
	MOVL	$0,0(SP)
	ADDL	$(MACHSIZE-4),SP	/* start stack under machine struct */
	MOVL	$0, u(SB)
.
101,103d
99c
	MOVL	$0xb8100,BX
	MOVB	$0x34,AL
	MOVB	AL,(BX)
	INCW	BX
	MOVB	$0x43,AL
	MOVB	AL,(BX)
here:
	JMP	here
.
97c
 *	print a blue 4 on a red background
.
93,95d
85,91d
83c
	MOVSL
.
79,81d
73,76c
	/*
	 * Clear BSS
	 */
	LEAL	edata(SB),SI
	LEAL	edata+4(SB),DI
	MOVL	$0,AX
	MOVL	AX,(SI)
	LEAL	end(SB),CX
.
71c
	MOVL	$0xb8100,BX
	MOVB	$0x33,AL
	MOVB	AL,(BX)
	INCW	BX
	MOVB	$0x43,AL
	MOVB	AL,(BX)
.
69c
 *	print a blue 3 on a red background
.
67a
TEXT	mode32bit(SB),$0

.
65,66c
/*	JMPFAR*	SELECTOR(2, SELGDT, 0):$protected(SB) /**/
	 BYTE	$0xEA
	 WORD	$mode32bit(SB)
	 WORD	$SELECTOR(2, SELGDT, 0)
.
63a
	MOVW	AX,ES
.
62d
59,60c

/*
 *	set all segs
 */
/*	MOVW	$SELECTOR(1, SELGDT, 0),AX	/**/
	 BYTE	$0xc7
	 BYTE	$0xc0
	 WORD	$SELECTOR(1, SELGDT, 0)
.
57a
	CLC
	JCC	flush
	MOVL	AX,AX
.
56c
 *	clear prefetch queue (wierd code to avoid optimizations)
.
52,54d
47c
/*
 *	now that we're in low core, update the DS
 */

	MOVL	$0,BX
	MOVW	BX,DS

/*
 * 	goto protected mode
 */
/*	MOVL	tgdtptr(SB),GDTR /**/
	 BYTE	$0x0f
	 BYTE	$0x01
	 BYTE	$0x16
	 WORD	$tgdtptr(SB)
.
44,45c
/*
 *	move the next 63K down
 */
	MOVL	$0,CX
	INCL	CX
	SHLL	$(15-1),CX
	SUBL	BX,CX
	SHLL	$1,BX
	MOVL	BX,SI
	MOVL	BX,DI
	REP
	MOVSL
.
41,42c
TEXT	lowcore(SB),$0
.
37,39c
/*
 *	move the first 1k bytes down to low core and jump to them
 *	- looks wierd because it is being assembled by a 32 bit
 *	  assembler for a 16 bit world
 */
	MOVL	$0,BX
	INCL	BX
	SHLL	$(10-1),BX
	MOVL	BX,CX
	MOVL	$0,SI
	MOVW	SI,ES
	MOVL	SI,DI
	CLD
	REP
	MOVSL
/*	JMPFAR*	00:$lowcore(SB) /**/
	 BYTE	$0xEA
	 WORD	$lowcore(SB)
	 WORD	$0
.
34,35c
	CLI
.
32c
 *	about to walk all over ms/dos - turn off interrupts
.
30a
TEXT	start(SB),$0

.
28,29c
	DATA tgdtptr+0(SB)/2, $(3*8)
	DATA tgdtptr+2(SB)/4, $tgdt(SB)
.
26c
GLOBL	tgdtptr(SB),$6
.
20,21c
	DATA tgdt+16(SB)/4, $(0xFFFF)
	DATA tgdt+20(SB)/4, $(SEGG|SEGD|(0xF<<16)|SEGP|SEGPL(0)|SEGEXEC|SEGR)
.
16,17c
	DATA tgdt+8(SB)/4, $(0xFFFF)
	DATA tgdt+12(SB)/4, $(SEGG|SEGB|(0xF<<16)|SEGP|SEGPL(0)|SEGDATA|SEGW)
.
12,13c
	DATA tgdt+0(SB)/4, $0
	DATA tgdt+4(SB)/4, $0
.
9c
GLOBL	tgdt(SB),$(6*4)
.
3,5d
## diffname pc/l.s 1991/0702
## diff -e /n/bootesdump/1991/0629/sys/src/9/safari/l.s /n/bootesdump/1991/0702/sys/src/9/safari/l.s
177a

/*
 *  gdt to get us to 32-bit/segmented/unpaged mode
 */
TEXT	tgdt(SB),$0

	/* null descriptor */
	LONG	$0
	LONG	$0

	/* data segment descriptor for 4 gigabytes (PL 0) */
	LONG	$(0xFFFF)
	LONG	$(SEGG|SEGB|(0xF<<16)|SEGP|SEGPL(0)|SEGDATA|SEGW)

	/* exec segment descriptor for 4 gigabytes (PL 0) */
	LONG	$(0xFFFF)
	LONG	$(SEGG|SEGD|(0xF<<16)|SEGP|SEGPL(0)|SEGEXEC|SEGR)

/*
 *  pointer to initial gdt
 */
TEXT	tgdtptr(SB),$0

	WORD	$(3*8)
	LONG	$tgdt(SB)

/*
 *  input a byte
 */
TEXT	inb(SB),$0

	MOVL	p+0(FP),DX
	XORL	AX,AX
	INB
	RET

/*
 *  output a byte
 */
TEXT	outb(SB),$0

	MOVL	p+0(FP),DX
	MOVL	b+4(FP),AX
	OUTB
	RET
.
162,170d
138,151d
115,124d
50c
/*	JMPFAR	00:$lowcore(SB) /**/
.
32a
TEXT	origin(SB),$0

.
4,30d
## diffname pc/l.s 1991/0703
## diff -e /n/bootesdump/1991/0702/sys/src/9/safari/l.s /n/bootesdump/1991/0703/sys/src/9/safari/l.s
164a

/*
 *  test and set
 */
TEXT	tas(SB),$0
	MOVL	$0xdeadead,AX
	MOVL	l+0(FP),BX
	XCHGL	AX,(BX)
	RET

/*
 *  load the idt
 */
GLOBL	idtptr(SB),$6
TEXT	lidt(SB),$0
	MOVL	t+0(FP),AX
	MOVL	AX,idtptr+2(SB)
	MOVL	l+4(FP),AX
	MOVW	AX,idtptr(SB)
	MOVL	idtptr(SB),IDTR
	RET

/*
 *  load the gdt
 */
GLOBL	gdtptr(SB),$6
TEXT	lgdt(SB),$0
	MOVL	t+0(FP),AX
	MOVL	AX,gdtptr+2(SB)
	MOVL	l+4(FP),AX
	MOVW	AX,gdtptr(SB)
	MOVL	gdtptr(SB),GDTR
	RET

/*
 *  special traps
 */
TEXT	intr0(SB),$0
	PUSHL	$0
	PUSHL	$0
	JMP	intrcommon
TEXT	intr1(SB),$0
	PUSHL	$0
	PUSHL	$1
	JMP	intrcommon
TEXT	intr2(SB),$0
	PUSHL	$0
	PUSHL	$2
	JMP	intrcommon
TEXT	intr3(SB),$0
	PUSHL	$0
	PUSHL	$3
	JMP	intrcommon
TEXT	intr4(SB),$0
	PUSHL	$0
	PUSHL	$4
	JMP	intrcommon
TEXT	intr5(SB),$0
	PUSHL	$0
	PUSHL	$5
	JMP	intrcommon
TEXT	intr6(SB),$0
	PUSHL	$0
	PUSHL	$6
	JMP	intrcommon
TEXT	intr7(SB),$0
	PUSHL	$0
	PUSHL	$7
	JMP	intrcommon
TEXT	intr8(SB),$0
	PUSHL	$8
	JMP	intrscommon
TEXT	intr9(SB),$0
	PUSHL	$0
	PUSHL	$9
	JMP	intrcommon
TEXT	intr10(SB),$0
	PUSHL	$10
	JMP	intrscommon
TEXT	intr11(SB),$0
	PUSHL	$11
	JMP	intrscommon
TEXT	intr12(SB),$0
	PUSHL	$12
	JMP	intrscommon
TEXT	intr13(SB),$0
	PUSHL	$13
	JMP	intrscommon
TEXT	intr14(SB),$0
	PUSHL	$14
	JMP	intrscommon
TEXT	intr15(SB),$0
	PUSHL	$0
	PUSHL	$15
	JMP	intrcommon
TEXT	intr16(SB),$0
	PUSHL	$0
	PUSHL	$16
	JMP	intrcommon
TEXT	intrbad(SB),$0
	PUSHL	$0
	PUSHL	$0x1ff
	JMP	intrcommon

intrcommon:
	PUSHL	DS
	PUSHAL
	LEAL	0(SP),AX
	PUSHL	AX
	CALL	trap(SB)
	POPL	AX
	POPAL
	POPL	DS
	ADDL	$8,SP	/* error code and trap type */
	IRETL
	RET

intrscommon:
	PUSHL	DS
	PUSHAL
	LEAL	0(SP),AX
	PUSHL	AX
	CALL	trap(SB)
	POPL	AX
	POPAL
	POPL	DS
	ADDL	$8,SP	/* error code and trap type */
	IRETL
	RET

/*
 *  turn on interrupts
 */
TEXT	sti(SB),$0
	STI
	RET
.
## diffname pc/l.s 1991/0704
## diff -e /n/bootesdump/1991/0703/sys/src/9/safari/l.s /n/bootesdump/1991/0704/sys/src/9/safari/l.s
299a
	RET

/*
 *  turn interrupts and traps off
 */
TEXT	splhi(SB),$0
	CLI
.
298c
TEXT	spllo(SB),$0
.
296c
 *  turn interrupts and traps on
.
## diffname pc/l.s 1991/0705
## diff -e /n/bootesdump/1991/0704/sys/src/9/safari/l.s /n/bootesdump/1991/0705/sys/src/9/safari/l.s
307a

/*
 *  set interrupt level
 */
TEXT	splx(SB),$0
	RET
.
## diffname pc/l.s 1991/0706
## diff -e /n/bootesdump/1991/0705/sys/src/9/safari/l.s /n/bootesdump/1991/0706/sys/src/9/safari/l.s
313a

/*
 *	
 */
TEXT	idle(SB),$0
	HLT
.
263a
TEXT	intr17(SB),$0
	PUSHL	$0
	PUSHL	$17
	JMP	intrcommon
TEXT	intr18(SB),$0
	PUSHL	$0
	PUSHL	$18
	JMP	intrcommon
TEXT	intr19(SB),$0
	PUSHL	$0
	PUSHL	$19
	JMP	intrcommon
TEXT	intr20(SB),$0
	PUSHL	$0
	PUSHL	$20
	JMP	intrcommon
TEXT	intr21(SB),$0
	PUSHL	$0
	PUSHL	$21
	JMP	intrcommon
TEXT	intr22(SB),$0
	PUSHL	$0
	PUSHL	$22
	JMP	intrcommon
TEXT	intr23(SB),$0
	PUSHL	$0
	PUSHL	$23
	JMP	intrcommon
.
83c
/*	JMPFAR	SELECTOR(2, SELGDT, 0):$mode32bit(SB) /**/
.
## diffname pc/l.s 1991/0710
## diff -e /n/bootesdump/1991/0706/sys/src/9/safari/l.s /n/bootesdump/1991/0710/sys/src/9/safari/l.s
347a
	RET

/*
 *  label consists of a stack pointer and a PC
 */
TEXT	gotolabel(SB),$0
	MOVL	l+0(FP),AX
	MOVL	0(AX),SP	/* restore sp */
	MOVL	4(AX),AX	/* put return pc on the stack */
	MOVL	AX,0(SP)
	RET

TEXT	setlabel(SB),$0
	MOVL	l+0(FP),AX
	MOVL	SP,0(AX)	/* store sp */
	MOVL	0(SP),BX	/* store return pc */
	MOVL	BX,4(AX)
	RET
.
344c
 *  do nothing whatsoever till interrupt happens
.
340a
	MOVL	s+0(FP),AX
	PUSHL	AX
	POPFL
.
333a
	PUSHFL
	POPL	AX
.
326a
	PUSHFL
	POPL	AX
.
291a
TEXT	intr64(SB),$0
	PUSHL	$0
	PUSHL	$64
	JMP	intrcommon
.
144c
	LONG	$tgdt-KZERO(SB)
.
119a
GLOBL	tpt(SB), $(BY2PG*3)
.
103a
	 *  make a bottom level page table page that maps the first
	 *  4 meg of physical memory
	 */
	LEAL	tpt-KZERO(SB),AX	/* get phys addr of temporary page table */
	ADDL	$(BY2PG-1),AX		/* must be page alligned */
	ANDL	$(~(BY2PG-1)),AX	/* ... */
	MOVL	$1024,CX		/* pte's per page */
	MOVL	$(((1024-1)<<12)|PTEVALID|PTEKERNEL|PTEWRITE),BX
setpte:
	MOVL	BX,-4(AX)(CX*4)
	SUBL	$(1<<12),BX
	LOOP	setpte

	/*
	 *  make a top level page table page that maps the first
	 *  4 meg of memory to 0 thru 4meg and to KZERO thru KZERO+4meg
	 */
	MOVL	AX,BX
	ADDL	$BY2PG,AX
	MOVL	BX,0(AX)
	MOVL	BX,((KZERO>>22)&(BY2PG-1))(AX)

	/*
	 *  point processor to top level page & turn on paging
	 */
	MOVL	AX,CR3
	MOVL	CR0,AX
	ORL	$1,AX
	MOVL	AX,CR0

	/*
.
97c
	LEAL	end-KZERO(SB),CX
.
93,94c
	LEAL	edata-KZERO(SB),SI
	MOVL	SI,DI
	ADDL	$4,DI
.
85c
	 WORD	$mode32bit-KZERO(SB)
.
59c
	 WORD	$tgdtptr-KZERO(SB)
.
27c
	 WORD	$lowcore-KZERO(SB)
.
## diffname pc/l.s 1991/0711
## diff -e /n/bootesdump/1991/0710/sys/src/9/safari/l.s /n/bootesdump/1991/0711/sys/src/9/safari/l.s
408a
	RET

TEXT	touser(SB),$0
.
152c
GLOBL	tpt(SB), $(BY2PG*6)
.
132c
	ORL	$0X80000000,AX
.
125c
	MOVL	BX,((((KZERO>>1)&0x7FFFFFFF)>>(2*PGSHIFT-1-4))+0)(AX)
	ADDL	$BY2PG,BX
	MOVL	BX,4(AX)
	MOVL	BX,((((KZERO>>1)&0x7FFFFFFF)>>(2*PGSHIFT-1-4))+4)(AX)
	ADDL	$BY2PG,BX
	MOVL	BX,8(AX)
	MOVL	BX,((((KZERO>>1)&0x7FFFFFFF)>>(2*PGSHIFT-1-4))+8)(AX)
	ADDL	$BY2PG,BX
	MOVL	BX,12(AX)
	MOVL	BX,((((KZERO>>1)&0x7FFFFFFF)>>(2*PGSHIFT-1-4))+12)(AX)
.
123c
	ADDL	$(4*BY2PG),AX
	ADDL	$(PTEVALID|PTEKERNEL|PTEWRITE),BX
.
120c
	 *  16 meg of memory to 0 thru 16meg and to KZERO thru KZERO+16meg
.
115c
	SUBL	$(1<<PGSHIFT),BX
.
111,112c
	MOVL	$(4*1024),CX		/* pte's per page */
	MOVL	$((((4*1024)-1)<<PGSHIFT)|PTEVALID|PTEKERNEL|PTEWRITE),BX
.
106c
	 *  16 meg of physical memory
.
## diffname pc/l.s 1991/0715
## diff -e /n/bootesdump/1991/0711/sys/src/9/safari/l.s /n/bootesdump/1991/0715/sys/src/9/safari/l.s
88a

#endif BOOT
.
85c
	 LONG	$mode32bit-KZERO(SB)
.
83a
	 BYTE	$0x66
.
59c
	 WORD	$tgdtptr(SB)
.
49d
33,45d
27,28c
	 WORD	$lowcore(SB)
	 WORD	$0X8000
.
25c
/*	JMPFAR	0X8000:$lowcore(SB) /**/
.
20d
18a
	MOVW	BX,ES
.
17c
	SHLL	$15,BX
.
11c
 *	relocate everything to a half meg and jump there
.
9a
#ifdef BOOT
.
## diffname pc/l.s 1991/0716
## diff -e /n/bootesdump/1991/0715/sys/src/9/safari/l.s /n/bootesdump/1991/0716/sys/src/9/safari/l.s
412a

TEXT	fprestore(SB),$0
	RET

.
411a
	MOVL	$(USERADDR+BY2PG-5*BY2WD),AX
	MOVL	$(UTZERO+32),0(AX)	/* header is in text */
	MOVL	$(UESEL),4(AX)
	MOVL	$(IFLAG|2),8(AX)
	MOVL	$(USTKTOP-4*BY2WD),12(AX)
	MOVL	$(UDSEL),16(AX)
	MOVL	AX,SP
	IRETL

/*
 *  save/restore floating point
 *	- to be filled in at some future time
 */
TEXT	fpsave(SB),$0
.
378,380d
369,371d
361c
 *  interrupt level is interrupts on or off
.
358c
	RET		/* this has to be here because of ken */
.
345c
	RET		/* this has to be here because of ken */
.
## diffname pc/l.s 1991/0717
## diff -e /n/bootesdump/1991/0716/sys/src/9/safari/l.s /n/bootesdump/1991/0717/sys/src/9/safari/l.s
412a
	MOVL	$(UDSEL),AX		/* set up data segment */
	MOVW	AX,DS
.
406c
	MOVL	$(USERADDR+BY2PG-6*BY2WD),AX
.
231a
TEXT	lcr3(SB),$0
	MOVL	t+0(FP),AX
	MOVL	AX,CR3
	RET

TEXT	ltr(SB),$0
	MOVL	t+0(FP),AX
	MOVW	AX,TASK
	RET

.
220,222d
209c
 *  routines to load various system registers
.
135a
	 *  use a jump to an absolute location to get the PC into
	 *  KZERO.
	 */
	LEAL	tokzero(SB),AX
	JMP*	AX

TEXT	tokzero(SB),$0

	/*
.
## diffname pc/l.s 1991/0718
## diff -e /n/bootesdump/1991/0717/sys/src/9/safari/l.s /n/bootesdump/1991/0718/sys/src/9/safari/l.s
422,429c
	PUSHL	$(UDSEL)			/* old ss */
	PUSHL	$(USTKTOP-4*BY2WD)		/* old sp */
	PUSHFL					/* old flags */
	PUSHL	$(UESEL)			/* old cs */
	PUSHL	$(UTZERO+32)			/* old pc */
	MOVL	$(UDSEL),AX		/* set up user's data segment */
.
420a
/*
 *  Used to get to the first process.
 *  Set up an interrupt return frame and IRET to user level.
 */
.
418a
	MOVL	$0,AX		/* return 0 */
.
411a
	MOVL	$1,AX		/* return 1 */
.
374d
365a
	MOVL	$(KDSEL),AX
	MOVW	AX,DS
.
361d
352a
	MOVL	$(KDSEL),AX
	MOVW	AX,DS
.
247a
TEXT	getcr2(SB),$0		/* fault address */
	MOVL	CR2,AX
	RET

.
243c
TEXT	puttr(SB),$0		/* task register */
.
238c
TEXT	putcr3(SB),$0		/* top level page table pointer */
.
230c
TEXT	putgdt(SB),$0		/* global descriptor table */
.
221c
TEXT	putidt(SB),$0		/* interrupt descriptor table */
.
218c
 *  routines to load/read various system registers
.
## diffname pc/l.s 1991/0719
## diff -e /n/bootesdump/1991/0718/sys/src/9/safari/l.s /n/bootesdump/1991/0719/sys/src/9/safari/l.s
440a
	MOVW	AX,ES
.
439c
	MOVL	$(UDSEL),AX
.
435c
	PUSHL	$(USTKTOP-16)			/* old sp */
.
## diffname pc/l.s 1991/0720
## diff -e /n/bootesdump/1991/0719/sys/src/9/safari/l.s /n/bootesdump/1991/0720/sys/src/9/safari/l.s
434,438c
	PUSHL	$(UDSEL)		/* old ss */
	PUSHL	$(USTKTOP)		/* old sp */
	PUSHFL				/* old flags */
	PUSHL	$(UESEL)		/* old cs */
	PUSHL	$(UTZERO+32)		/* old pc */
.
11a
 *	This part of l.s is used only in the boot kernel.
 *	It assumes that we are in real address mode, i.e.,
 *	that we look like an 8086.
 */
/*
.
## diffname pc/l.s 1991/0731
## diff -e /n/bootesdump/1991/0720/sys/src/9/safari/l.s /n/bootesdump/1991/0731/sys/src/9/safari/l.s
349a
TEXT	intr24(SB),$0
	PUSHL	$0
	PUSHL	$24
	JMP	intrcommon
TEXT	intr25(SB),$0
	PUSHL	$0
	PUSHL	$25
	JMP	intrcommon
TEXT	intr26(SB),$0
	PUSHL	$0
	PUSHL	$26
	JMP	intrcommon
TEXT	intr27(SB),$0
	PUSHL	$0
	PUSHL	$27
	JMP	intrcommon
TEXT	intr28(SB),$0
	PUSHL	$0
	PUSHL	$28
	JMP	intrcommon
TEXT	intr29(SB),$0
	PUSHL	$0
	PUSHL	$29
	JMP	intrcommon
TEXT	intr30(SB),$0
	PUSHL	$0
	PUSHL	$30
	JMP	intrcommon
TEXT	intr31(SB),$0
	PUSHL	$0
	PUSHL	$31
	JMP	intrcommon
.
## diffname pc/l.s 1991/0806
## diff -e /n/bootesdump/1991/0731/sys/src/9/safari/l.s /n/bootesdump/1991/0806/sys/src/9/safari/l.s
490a

/*
 *  set configuration register
 */
TEXT	config(SB),$0
	MOVL	l+0(FP),AX
	MOVL	$0x3F3,DX
	OUTB
	OUTB
	RET
.
## diffname pc/l.s 1991/0807
## diff -e /n/bootesdump/1991/0806/sys/src/9/safari/l.s /n/bootesdump/1991/0807/sys/src/9/safari/l.s
414a
	POPL	ES
.
409a
	MOVW	AX,ES
.
406a
	PUSHL	ES
.
400a
	POPL	ES
.
395a
	MOVW	AX,ES
.
392a
	PUSHL	ES
.
## diffname pc/l.s 1991/0809
## diff -e /n/bootesdump/1991/0807/sys/src/9/safari/l.s /n/bootesdump/1991/0809/sys/src/9/safari/l.s
210a
	RET

/*
 *  input a string of shorts from a port
 */
TEXT	inss(SB),$0
	MOVL	p+0(FP),DX
	MOVL	a+4(FP),DI
	MOVL	c+8(FP),CX
	REP; OP16; INSL
	RET

/*
 *  output a string of shorts to a port
 */
TEXT	outss(SB),$0
	MOVL	p+0(FP),DX
	MOVL	a+4(FP),SI
	MOVL	c+8(FP),CX
	REP; OP16; OUTSL
.
2a
#define OP16	BYTE	$0x66

.
## diffname pc/l.s 1991/0821
## diff -e /n/bootesdump/1991/0809/sys/src/9/safari/l.s /n/bootesdump/1991/0821/sys/src/9/safari/l.s
231a
	CLD
.
221a
	CLD
.
## diffname pc/l.s 1991/0904
## diff -e /n/bootesdump/1991/0821/sys/src/9/safari/l.s /n/bootesdump/1991/0904/sys/src/9/safari/l.s
404a
	JMP	intrcommon
TEXT	intr32(SB),$0
	PUSHL	$0
	PUSHL	$16
	JMP	intrcommon
TEXT	intr33(SB),$0
	PUSHL	$0
	PUSHL	$33
	JMP	intrcommon
TEXT	intr34(SB),$0
	PUSHL	$0
	PUSHL	$34
	JMP	intrcommon
TEXT	intr35(SB),$0
	PUSHL	$0
	PUSHL	$35
	JMP	intrcommon
TEXT	intr36(SB),$0
	PUSHL	$0
	PUSHL	$36
	JMP	intrcommon
TEXT	intr37(SB),$0
	PUSHL	$0
	PUSHL	$37
	JMP	intrcommon
TEXT	intr38(SB),$0
	PUSHL	$0
	PUSHL	$38
	JMP	intrcommon
TEXT	intr39(SB),$0
	PUSHL	$0
	PUSHL	$39
.
346,373d
## diffname pc/l.s 1991/0906
## diff -e /n/bootesdump/1991/0904/sys/src/9/safari/l.s /n/bootesdump/1991/0906/sys/src/9/safari/l.s
514,524d
280a
#define	FPOFF\
	WAIT;\
	MOVL	CR0,AX;\
	ORL	$0x4,AX		/* EM=1 */;\
	MOVL	AX,CR0

#define	FPON\
	MOVL	CR0,AX;\
	ANDL	$~0x4,AX	/* EM=0 */;\
	MOVL	AX,CR0
	
TEXT	fpoff(SB),$0		/* turn off floating point */
	FPOFF
	RET

TEXT	fpinit(SB),$0		/* turn on & init the floating point */
	FPON
	FINIT
	WAIT
	RET

TEXT	fpsave(SB),$0		/* save floating point state and turn off */
	MOVL	p+0(FP),AX
	WAIT
	FSAVE	0(AX)
	FPOFF
	RET

TEXT	fprestore(SB),$0	/* turn on floating point and restore regs */
	FPON
	MOVL	p+0(FP),AX
	FRSTOR	0(AX)
	WAIT
	RET

.
276a
TEXT	getcr0(SB),$0		/* coprocessor bits */
	MOVL	CR0,AX
	RET

.
139a
	ANDL	$~(0x8|0x2),AX	/* TS=0, MP=0 */
.
## diffname pc/l.s 1991/0912
## diff -e /n/bootesdump/1991/0906/sys/src/9/safari/l.s /n/bootesdump/1991/0912/sys/src/9/safari/l.s
304a
	PUSHW	$0x0330
	FLDCW	0(SP)		/* ignore underflow/precision, signal others */
	POPW	AX
	WAIT
.
## diffname pc/l.s 1991/0913
## diff -e /n/bootesdump/1991/0912/sys/src/9/safari/l.s /n/bootesdump/1991/0913/sys/src/9/safari/l.s
324a
TEXT	fpstatus(SB),$0		/* get floating point status */
	FSTSW	AX
	RET

.
## diffname pc/l.s 1991/1211
## diff -e /n/bootesdump/1991/0913/sys/src/9/safari/l.s /n/bootesdump/1991/1211/sys/src/9/safari/l.s
560a
	MOVW	AX,GS
	MOVW	AX,FS
.
234,235c
	CLD; REP; OP16; OUTSL
.
223,224c
	CLD; REP; OP16; INSL
.
160a
	/*
	 *  clear flags
	 */
	MOVL	$0,AX
	PUSHL	AX
	POPFL

.
98,99c
	CLD; REP; MOVSL
.
30,32c
	CLD; REP; MOVSL
.
## diffname pc/l.s 1991/1214
## diff -e /n/bootesdump/1991/1211/sys/src/9/safari/l.s /n/bootesdump/1991/1214/sys/src/9/safari/l.s
497a
	POPL	GS
	POPL	FS
.
488a
	PUSHL	FS
	PUSHL	GS
.
480a
	POPL	GS
	POPL	FS
.
471a
	PUSHL	FS
	PUSHL	GS
.
73a
	MOVW	AX,FS
	MOVW	AX,GS
.
## diffname pc/l.s 1992/0323
## diff -e /n/bootesdump/1991/1214/sys/src/9/safari/l.s /n/bootesdump/1992/0323/sys/src/9/safari/l.s
566c
	MOVL	sp+0(FP),AX		/* old sp */
	PUSHL	AX
.
## diffname pc/l.s 1992/0425
## diff -e /n/bootesdump/1992/0323/sys/src/9/safari/l.s /n/bootesdump/1992/0425/sys/src/9/safari/l.s
57c
 *	clear prefetch queue (weird code to avoid optimizations)
.
## diffname pc/l.s 1992/0728
## diff -e /n/bootesdump/1992/0425/sys/src/9/safari/l.s /n/bootesdump/1992/0728/sys/src/9/safari/l.s
309c
	PUSHW	$0x033E
.
## diffname pc/l.s 1992/0805
## diff -e /n/bootesdump/1992/0728/sys/src/9/safari/l.s /n/bootesdump/1992/0805/sys/src/9/safari/l.s
293c
	ORL	$0x24,AX	/* EM=1, NE=1 */;\
.
## diffname pc/l.s 1992/0806
## diff -e /n/bootesdump/1992/0805/sys/src/9/safari/l.s /n/bootesdump/1992/0806/sys/src/9/safari/l.s
332a
TEXT	fpenv(SB),$0		/* save floating point environment without waiting */
	MOVL	p+0(FP),AX
	FSTENV	0(AX)
	RET

.
## diffname pc/l.s 1992/0911
## diff -e /n/bootesdump/1992/0808/sys/src/9/safari/l.s /n/bootesdump/1992/0911/sys/src/9/pc/l.s
222a
 * input a short
 */
TEXT ins(SB), $0
	MOVL	p+0(FP), DX
	XORL	AX, AX
	OP16; INSL
	RET

/*
 * output a short
 */
TEXT outs(SB), $0
	MOVL	p+0(FP), DX
	MOVL	s+4(FP), AX
	OP16; OUTSL
	RET

/*
.
## diffname pc/l.s 1992/0917
## diff -e /n/bootesdump/1992/0911/sys/src/9/pc/l.s /n/bootesdump/1992/0917/sys/src/9/pc/l.s
257a
	RET

/*
 *  output a string of longs to a port
 */
TEXT	outsl(SB),$0

	MOVL	p+0(FP),DX
	MOVL	a+4(FP),SI
	MOVL	c+8(FP),CX
	CLD; REP; OUTSL
.
253a

.
250a
 *  input a string of longs from a port
 */
TEXT	insl(SB),$0

	MOVL	p+0(FP),DX
	MOVL	a+4(FP),DI
	MOVL	c+8(FP),CX
	CLD; REP; INSL
	RET

/*
 * output a short to a port
 */
TEXT	outs(SB), $0
	MOVL	p+0(FP), DX
	MOVL	s+4(FP), AX
	OUTL
	RET

/*
.
243a

.
231,238d
228c
	INL
.
225c
TEXT	ins(SB), $0

.
223c
 * input a short from a port
.
## diffname pc/l.s 1992/0922
## diff -e /n/bootesdump/1992/0917/sys/src/9/pc/l.s /n/bootesdump/1992/0922/sys/src/9/pc/l.s
261c
	OP16; OUTL
.
229c
	OP16; INL
.
## diffname pc/l.s 1992/1107
## diff -e /n/bootesdump/1992/0922/sys/src/9/pc/l.s /n/bootesdump/1992/1107/sys/src/9/pc/l.s
635a

/*
 *  copy bytes to screen memory for ldepth 0 screen
 */
TEXT	l0update(SB),$0
	XORL	AX,AX
	MOVL	len+8(FP),CX
	MOVL	from+0(FP),BX
	MOVL	to+4(FP),DX
l00:
	MOVB	-1(BX)(CX*1),AL
	MOVB	cswizzle(SB)(AX*1),AL
	MOVB	AL,-1(DX)(CX*1)
	LOOP	l00
	RET
.
## diffname pc/l.s 1992/1108
## diff -e /n/bootesdump/1992/1107/sys/src/9/pc/l.s /n/bootesdump/1992/1108/sys/src/9/pc/l.s
649a
	RET

#define SRX	0x3C4		/* index to sequence registers */
#define	SR	0x3C5		/* sequence registers */
#define Smmask	0x02		/*  map mask */

/*
 *  same as l0update but for ldepth 1 (2 bit plane) screens
 */
TEXT	l1update(SB),$0
	MOVL	from+0(FP),SI
	MOVL	to+4(FP),DI
	MOVL	len+8(FP),CX
l10:
	XORL	DX,DX
	MOVB	-2(SI)(CX*2),DL		/* high order nibbles */
	MOVW	l1revsep(SB)(DX*2),BX
	SHLW	$4,BX
	MOVB	-1(SI)(CX*2),DL		/* low order nibbles */
	ORW	l1revsep(SB)(DX*2),BX
	MOVB	$(Smmask),AL		/* write hi order bits to bit planes 0 & 2 */
	MOVW	$(SRX),DX
	OUTB
	MOVB	$0xA,AL
	MOVW	$(SR),DX
	OUTB
	MOVB	BH,-1(DI)(CX*1)
	MOVB	$(Smmask),AL		/* write lo order bits to bit planes 1 & 3 */
	MOVW	$(SRX),DX
	OUTB
	MOVB	$0x5,AL
	MOVW	$(SR),DX
	OUTB
	MOVB	BL,-1(DI)(CX*1)
	LOOP	l10
.
647c
	MOVB	bitrevtab(SB)(AX*1),AL
.
638c
 *  copy bitmap changes to screen memory for ldepth 0 screen
 *  reverse the bits since the screen is big-endian
 *  and the bitmaps are little.
.
## diffname pc/l.s 1992/1109
## diff -e /n/bootesdump/1992/1108/sys/src/9/pc/l.s /n/bootesdump/1992/1109/sys/src/9/pc/l.s
679,683c
	MOVB	$0x5,AL			/* write lo order bits to bit planes 1 & 3 */
.
676a
l10:
	XORL	AX,AX
	MOVB	-2(SI)(CX*2),AL		/* high order nibbles */
	MOVW	l1revsep(SB)(AX*2),BX
	SHLW	$4,BX
	MOVB	-1(SI)(CX*2),AL		/* low order nibbles */
	ORW	l1revsep(SB)(AX*2),BX
	MOVB	$0xA,AL			/* write hi order bits to bit planes 0 & 2 */
.
675d
665,672c
	MOVB	$(Smmask),AL
.
## diffname pc/l.s 1992/1110
## diff -e /n/bootesdump/1992/1109/sys/src/9/pc/l.s /n/bootesdump/1992/1110/sys/src/9/pc/l.s
650c
	MOVB	AL,-1(DI)(CX*1)
.
648c
	MOVB	-2(SI)(CX*2),AL
.
645,646c
	MOVL	from+0(FP),SI
	MOVL	to+4(FP),DI
.
## diffname pc/l.s 1992/1111
## diff -e /n/bootesdump/1992/1110/sys/src/9/pc/l.s /n/bootesdump/1992/1111/sys/src/9/pc/l.s
681,682c
	MOVB	BX,-1(DI)(CX*1)
	MOVB	$0x2,AL			/* plane 2 */
	OUTB
	SHRL	$8,BX
	MOVB	BX,-1(DI)(CX*1)
	MOVB	$0x4,AL			/* plane 1 */
	OUTB
	SHRL	$8,BX
	MOVB	BX,-1(DI)(CX*1)
	MOVB	$0x8,AL			/* plane 0*/
	OUTB
	SHRL	$8,BX
	MOVB	BX,-1(DI)(CX*1)
	LOOP	l20
.
678,679c
l20:
	MOVL	-4(SI)(CX*4),DX
	MOVB	DL,AL
	MOVL	l2revsep(SB)(AX*4),BX
	SHLL	$2,BX
	SHRL	$8,DX
	MOVB	DL,AL
	ORL	l2revsep(SB)(AX*4),BX
	SHLL	$2,BX
	SHRL	$8,DX
	MOVB	DL,AL
	ORL	l2revsep(SB)(AX*4),BX
	SHLL	$2,BX
	SHRL	$8,DX
	MOVB	DL,AL
	ORL	l2revsep(SB)(AX*4),BX
	MOVW	$(SR),DX
	MOVB	$0x1,AL			/* plane 3 */
.
671,676c
	MOVL	from+0(FP),SI
	MOVL	to+4(FP),DI
	MOVL	len+8(FP),CX
	MOVB	$(Smmask),AL
	MOVW	$(SRX),DX
.
669a
	MOVL	-4(SI)(CX*2),DX
	MOVB	DL,AL
	MOVL	l1revsep(SB)(AX*4),BX
	SHLL	$4,BX
	RORL	$8,DX
	MOVB	DL,AL
	ORL	l1revsep(SB)(AX*4),BX
	RORL	$12,BX
	RORL	$8,DX
	MOVB	DL,AL
	ORL	l1revsep(SB)(AX*4),BX
	SHLL	$4,BX
	RORL	$8,DX
	MOVB	DL,AL
	ORL	l1revsep(SB)(AX*4),BX
	ROLL	$8,BX
	MOVW	$(SR),DX
	MOVB	$0x5,AL			/* write lo order bits to bit planes 1 & 3 */
	OUTB
	MOVW	BX,-2(DI)(CX*1)
	SHRL	$16,BX			/* write hi order bits to bit planes 1 & 3 */
	MOVB	$0xA,AL
	OUTB
	MOVW	BX,-2(DI)(CX*1)
	LOOP	l11
	RET
l11:	LOOP	l10
	RET

/*
 *  same as l0update but for ldepth 2 (4 bit plane) screens
 */
TEXT	l2update(SB),$0
.
668d
661a
	XORL	AX,AX
.
## diffname pc/l.s 1992/1112
## diff -e /n/bootesdump/1992/1111/sys/src/9/pc/l.s /n/bootesdump/1992/1112/sys/src/9/pc/l.s
690c
	SHRL	$16,BX			/* write hi order bits to bit planes 0 & 2 */
.
648c
	MOVB	-1(SI)(CX*1),AL
.
## diffname pc/l.s 1992/1115
## diff -e /n/bootesdump/1992/1112/sys/src/9/pc/l.s /n/bootesdump/1992/1115/sys/src/9/pc/l.s
649c
	MOVB	revtab0(SB)(AX*1),AL
.
## diffname pc/l.s 1992/1118
## diff -e /n/bootesdump/1992/1115/sys/src/9/pc/l.s /n/bootesdump/1992/1118/sys/src/9/pc/l.s
704,705c
	MOVL	from+4(FP),SI
	MOVL	to+0(FP),DI
.
663,664c
	MOVL	from+4(FP),SI
	MOVL	to+0(FP),DI
.
645,646c
	MOVL	from+4(FP),SI
	MOVL	to+0(FP),DI
.
## diffname pc/l.s 1992/1119
## diff -e /n/bootesdump/1992/1118/sys/src/9/pc/l.s /n/bootesdump/1992/1119/sys/src/9/pc/l.s
648,650c
	MOVW	-2(SI)(CX*2),DX
	MOVB	DH,AL
	MOVB	revtab0(SB)(AX*1),BX
	SHLL	$8,BX
	MOVB	DL,AL
	ORB	revtab0(SB)(AX*1),BX
	MOVW	BX,-2(DI)(CX*2)
.
646a
	XORL	AX,AX
.
644a
	SHRL	$1,CX
.
643d
638c
 *  copy bitmap changes to screen memory for ldepth 0 screen.
.
## diffname pc/l.s 1992/1121
## diff -e /n/bootesdump/1992/1119/sys/src/9/pc/l.s /n/bootesdump/1992/1121/sys/src/9/pc/l.s
699,701c
	LOOP	l10
.
## diffname pc/l.s 1992/1211
## diff -e /n/bootesdump/1992/1121/sys/src/9/pc/l.s /n/bootesdump/1992/1211/sys/src/9/pc/l.s
219a
	RET

/*
 *  output a string of bytes to a port
 */
TEXT	outsb(SB),$0

	MOVL	p+0(FP),DX
	MOVL	a+4(FP),SI
	MOVL	c+8(FP),CX
	CLD; REP; OUTSB
.
212a
 *  input a string of bytes from a port
 */
TEXT	insb(SB),$0

	MOVL	p+0(FP),DX
	MOVL	a+4(FP),DI
	MOVL	c+8(FP),CX
	CLD; REP; INSB
	RET

/*
.
## diffname pc/l.s 1993/0212
## diff -e /n/bootesdump/1992/1211/sys/src/9/pc/l.s /n/bootesdump/1993/0212/sys/src/9/pc/l.s
768a

/*
 * The DP8390 ethernet chip needs some time between
 * successive chip selects, so we force a jump into
 * the instruction stream to break the pipeline.
 */
TEXT dp8390inb(SB), $0
	MOVL	p+0(FP),DX
	XORL	AX,AX				/* CF = 0 */
	INB

	JCC	_dp8390inb0			/* always true */
	MOVL	AX,AX

_dp8390inb0:
	RET

TEXT dp8390outb(SB), $0
	MOVL	p+0(FP),DX
	MOVL	b+4(FP),AX
	OUTB

	CLC					/* CF = 0 */
	JCC	_dp8390outb0			/* always true */
	MOVL	AX,AX

_dp8390outb0:
	RET
.
## diffname pc/l.s 1993/0224
## diff -e /n/bootesdump/1993/0212/sys/src/9/pc/l.s /n/bootesdump/1993/0224/sys/src/9/pc/l.s
503c
	PUSHL	$32
.
## diffname pc/l.s 1993/0915
## diff -e /n/bootesdump/1993/0224/sys/src/9/pc/l.s /n/fornaxdump/1993/0915/sys/src/brazil/pc/l.s
795a
	RET

/*
 * dsp outb string called from devdsp.c
 */
	TEXT	dspoutb+0(SB), $0

	MOVL	a+4(FP), BX
	MOVL	n+8(FP), CX

	MOVL	base+0(FP), DX
	ADDL	$2, DX			/* Pcontrol */

	MOVL	c2+12(FP), DI
	MOVL	c3+16(FP), SI

dsploop:
	MOVL	DI, AX			/* normal */
	OUTB

	SUBL	$1, CX
	CMPL	CX, $0
	JLT	dspout

	SUBL	$2, DX			/* Pdata */
	MOVB	(BX), AX
	ADDL	$1, BX
	OUTB

	ADDL	$2, DX			/* Pcontrol */
	MOVL	SI, AX			/* strobe */
	OUTB

	JMP	dsploop

dspout:
.
580a
	NOP
.
576a
	NOP
.
559a
	NOP
.
555a
	NOP
.
297a
 * output a long to a port
 */
TEXT	outl(SB), $0
	MOVL	p+0(FP), DX
	MOVL	s+4(FP), AX
	OUTL
	RET

/*
.
266a
 * input a long from a port
 */
TEXT	inl(SB), $0

	MOVL	p+0(FP), DX
	XORL	AX, AX
	INL
	RET

/*
.
254d
175c
GLOBL	tpt(SB), $(BY2PG*3)
.
158c
	MOVL	$0, up(SB)
.
123,131d
119c
	ADDL	$(BY2PG),AX
.
107,108c
	MOVL	$(1024),CX		/* pte's per page */
	MOVL	$((((1024)-1)<<PGSHIFT)|PTEVALID|PTEKERNEL|PTEWRITE),BX
.
12,86d
6c
 *	We assume that b.com got us into 32 bit mode already.  We are now
 *	running with a PC == origin & ~KZERO.
.
3a
#define NOP	XCHGL	AX,AX
.
## diffname pc/l.s 1993/1027
## diff -e /n/fornaxdump/1993/0915/sys/src/brazil/pc/l.s /n/fornaxdump/1993/1027/sys/src/brazil/pc/l.s
91c
GLOBL	up(SB), $4
.
## diffname pc/l.s 1993/1113
## diff -e /n/fornaxdump/1993/1027/sys/src/brazil/pc/l.s /n/fornaxdump/1993/1113/sys/src/brazil/pc/l.s
708a
#endif /* notdef */
.
598a
#ifdef notdef
.
500a
TEXT forkret(SB), $0
	POPL	AX
	POPAL
	NOP
	POPL	GS
	POPL	FS
	POPL	ES
	POPL	DS
	NOP
	ADDL	$8,SP	/* error code and trap type */
	IRETL

.
## diffname pc/l.s 1993/1116
## diff -e /n/fornaxdump/1993/1113/sys/src/brazil/pc/l.s /n/fornaxdump/1993/1116/sys/src/brazil/pc/l.s
722d
611d
556a
TEXT	getstatus(SB),$0
	PUSHFL
	POPL	AX
	RET

.
## diffname pc/l.s 1993/1221
## diff -e /n/fornaxdump/1993/1116/sys/src/brazil/pc/l.s /n/fornaxdump/1993/1221/sys/src/brazil/pc/l.s
707c
	ORL	l2septab(SB)(AX*4),BX
.
703c
	ORL	l2septab(SB)(AX*4),BX
.
699c
	ORL	l2septab(SB)(AX*4),BX
.
695c
	MOVL	l2septab(SB)(AX*4),BX
.
682c
 *  separate ldepth 2 bitmap into 4 bit planes
.
668c
	ORL	l1septab(SB)(AX*4),BX
.
664c
	ORL	l1septab(SB)(AX*4),BX
.
660c
	ORL	l1septab(SB)(AX*4),BX
.
656c
	MOVL	l1septab(SB)(AX*4),BX
.
643c
 *  separate ldepth 1 bitmap into 2 bit planes
.
616,637d
## diffname pc/l.s 1993/1229
## diff -e /n/fornaxdump/1993/1221/sys/src/brazil/pc/l.s /n/fornaxdump/1993/1229/sys/src/brazil/pc/l.s
620a
 *  invert the ldepth 0 bitmap
 */
TEXT	l0update(SB),$0
	MOVL	from+4(FP),SI
	MOVL	to+0(FP),DI
	MOVL	len+8(FP),BX

	MOVL	BX,CX
	SHRL	$2,CX
	JZ	l01
l00:
	MOVL	-4(SI)(CX*4),AX
	NOTL	AX
	MOVL	AX,-4(DI)(CX*4)
	LOOP	l00
l01:
	MOVL	BX,CX
	ANDL	$(~3),BX
	ANDL	$3,CX
	JZ	l03
	ADDL	BX,SI
	ADDL	BX,DI
l02:
	MOVB	-1(SI)(CX*1),AL
	NOTL	AX
	MOVB	AL,-1(DI)(CX*1)
	LOOP	l02
l03:
	RET

/*
.
## diffname pc/l.s 1994/0130
## diff -e /n/fornaxdump/1993/1229/sys/src/brazil/pc/l.s /n/fornaxdump/1994/0130/sys/src/brazil/pc/l.s
761a
	RET
#endif

TEXT slowinb(SB), $0
	MOVL	$0x84, DX
	INB

	MOVL	p+0(FP),DX
	XORL	AX,AX
	INB
	RET

TEXT slowoutb(SB),$0
	MOVL	$0x84, DX
	INB

	MOVL	p+0(FP),DX
	MOVL	b+4(FP),AX
	OUTB

	MOVL	$0x84, DX
	INB

.
735a
#ifdef notdef
.
## diffname pc/l.s 1994/0201
## diff -e /n/fornaxdump/1994/0130/sys/src/brazil/pc/l.s /n/fornaxdump/1994/0201/sys/src/brazil/pc/l.s
776a
	INB
.
768a
	INB
.
## diffname pc/l.s 1994/0202
## diff -e /n/fornaxdump/1994/0201/sys/src/brazil/pc/l.s /n/fornaxdump/1994/0202/sys/src/brazil/pc/l.s
762,787c
_slowoutb0:
.
759c
	JCC	_slowoutb0			/* always true */
.
753c
TEXT slowoutb(SB), $0
.
750c
_slowinb0:
.
747c
	JCC	_slowinb0			/* always true */
.
742c
TEXT slowinb(SB), $0
.
736d
## diffname pc/l.s 1994/0227
## diff -e /n/fornaxdump/1994/0202/sys/src/brazil/pc/l.s /n/fornaxdump/1994/0227/sys/src/brazil/pc/l.s
56c
	ORL	$0X80010000,AX
.
## diffname pc/l.s 1994/0302
## diff -e /n/fornaxdump/1994/0227/sys/src/brazil/pc/l.s /n/fornaxdump/1994/0302/sys/src/brazil/pc/l.s
566a
	RET

/*
 *  return cpu type (what is a pentium?)
 */
TEXT	x86(SB),$0

	PUSHFL
	MOVL	0(SP),AX
	ORL	$0x40000,AX
	PUSHL	AX
	POPFL
	PUSHFL
	POPL	AX
	ANDL	$0x40000,AX
	JZ	is386
	MOVL	$486,AX
	JMP	done
is386:
	MOVL	$386,AX
done:
	POPFL
.
57c
	ANDL	$~(0x40000000|0x20000000|0x8|0x2),AX	/* CD=0, NW=0, TS=0, MP=0 */
.
## diffname pc/l.s 1994/0409
## diff -e /n/fornaxdump/1994/0302/sys/src/brazil/pc/l.s /n/fornaxdump/1994/0409/sys/src/brazil/pc/l.s
819a
	RET


	TEXT	damove(SB), $0

	MOVL	p1+0(FP), DI
	MOVL	p2+4(FP), SI
	MOVL	n+8(FP), BX
	CLD
/*
 * less than a word, just copy bytes
 */
	CMPL	BX, $4
	JLS	bybyte
/*
 * copy bytes till dest is word alligned
 */
	MOVL	DI, DX
	ANDL	$3, DX
	JEQ	byword
	MOVL	$4, CX
	SUBL	DX, CX
	SUBL	CX, BX
	REP;	MOVSB
/*
 * copy whole longs
 */
byword:
	MOVL	BX, CX
	SHRL	$2, CX
	REP;	MOVSL
/*
 * copy the rest, by bytes
 */
	ANDL	$3, BX
bybyte:
	MOVL	BX, CX
	REP;	MOVSB
.
585a
	POPL	AX
.
582a
	POPL	AX
	ANDL	$0x200000,AX
	JZ	is486
	MOVL	$586,AX
	JMP	done
is486
.
580c
	MOVL	0(SP),AX
.
576c
	ORL	$0x240000,AX
.
570c
 *  return cpu type (586 == pentium or better)
.
## diffname pc/l.s 1994/0412
## diff -e /n/fornaxdump/1994/0409/sys/src/brazil/pc/l.s /n/fornaxdump/1994/0412/sys/src/brazil/pc/l.s
648,763d
588c
is486:
.
## diffname pc/l.s 1994/0602
## diff -e /n/fornaxdump/1994/0412/sys/src/brazil/pc/l.s /n/fornaxdump/1994/0602/sys/src/brazil/pc/l.s
749a

/*
 * Fiber block copy routines
 */
TEXT	fwblock(SB),$0
	MOVL	p+0(FP),DX
	MOVL	a+4(FP),SI
	MOVL	$128,CX
	CLD; REP; OUTSL

	MOVL	p+0(FP),DX
	MOVL	$128,CX
	MOVL	csum+8(FP), AX
wcsum:
	XORL	0(DX), AX
	ADDL	$4,DX
	LOOP	rcsum	
	RET

TEXT	frblock(SB),$0
	MOVL	p+0(FP),DX
	MOVL	a+4(FP),SI
	MOVL	$128,CX
	CLD; REP; INSL

	MOVL	p+0(FP),DX
	MOVL	$128,CX
	MOVL	csum+8(FP), AX
rcsum:
	XORL	0(DX), AX
	ADDL	$4,DX
	LOOP	rcsum	
	RET
.
## diffname pc/l.s 1994/0603
## diff -e /n/fornaxdump/1994/0602/sys/src/brazil/pc/l.s /n/fornaxdump/1994/0603/sys/src/brazil/pc/l.s
560,566d
207a

.
189d
## diffname pc/l.s 1994/0607
## diff -e /n/fornaxdump/1994/0603/sys/src/brazil/pc/l.s /n/fornaxdump/1994/0607/sys/src/brazil/pc/l.s
768c
	MOVL	a+4(FP),DX
.
764c
	MOVL	a+4(FP),DI
.
759c
	LOOP	wcsum	
.
753c
	MOVL	a+4(FP),DX
.
## diffname pc/l.s 1994/0610
## diff -e /n/fornaxdump/1994/0607/sys/src/brazil/pc/l.s /n/fornaxdump/1994/0610/sys/src/brazil/pc/l.s
587a
	POPL	BX
.
585d
576,577c
	ANDL	$0x200000,AX	/* on 486 we can't change this bit */
.
574c
	XORL	4(SP),AX
	MOVL	AX, BX
	ANDL	$0x40000,BX	/* on 386 we can't change this bit */
.
569c
	XORL	$0x240000,AX
.
## diffname pc/l.s 1994/0622
## diff -e /n/fornaxdump/1994/0610/sys/src/brazil/pc/l.s /n/fornaxdump/1994/0622/sys/src/brazil/pc/l.s
291a
TEXT	getcr3(SB),$0		/* page directory base */
	MOVL	CR3,AX
	RET

.
## diffname pc/l.s 1994/0716
## diff -e /n/fornaxdump/1994/0622/sys/src/brazil/pc/l.s /n/fornaxdump/1994/0716/sys/src/brazil/pc/l.s
593a
	RET

/*
 *  basic timing loop to determine CPU frequency
 */
TEXT	aamloop(SB),$0

	MOVL	c+0(FP),CX
aaml1:
	AAM
	LOOP	aaml1
.
583a
	MOVL	$1,AX
	/* CPUID */
	 BYTE $0x0F
	 BYTE $0xA2
	SHLL	$20,AX
	SHRL	$28,AX
	CMPL	AX, $4
	JEQ	is486
.
582c
	ANDL	$0x200000,AX	/* if we can't change this, there's no CPUID */
.
## diffname pc/l.s 1994/1029
## diff -e /n/fornaxdump/1994/0716/sys/src/brazil/pc/l.s /n/fornaxdump/1994/1029/sys/src/brazil/pc/l.s
587a

	MOVL	AX, cpuidax(SB)
	MOVL	DX, cpuiddx(SB)

.
408a
TEXT	intr17(SB),$0
	PUSHL	$17
	JMP	intrscommon
TEXT	intr18(SB),$0
	PUSHL	$16
	JMP	intrscommon
.
## diffname pc/l.s 1994/1031
## diff -e /n/fornaxdump/1994/1029/sys/src/brazil/pc/l.s /n/fornaxdump/1994/1031/sys/src/brazil/pc/l.s
609a
	MOVL	AX, a+0(FP)
	MOVL	DX, d+4(FP)
.
608c
	MOVL	$(3<<8),AX
	MOVL	$0,DX
.
605c
	MOVL	$(4<<8),AX
	MOVL	$0,DX
.
594,602d
575c
TEXT	x86cpuid(SB),$0
.
## diffname pc/l.s 1994/1101
## diff -e /n/fornaxdump/1994/1031/sys/src/brazil/pc/l.s /n/fornaxdump/1994/1101/sys/src/brazil/pc/l.s
606a
	POPL	BX
.
603,605c
	MOVL	a+0(FP),CX
	MOVL	AX,0(CX)
	MOVL	d+4(FP),CX
	MOVL	DX,0(CX)
.
## diffname pc/l.s 1994/1114
## diff -e /n/fornaxdump/1994/1101/sys/src/brazil/pc/l.s /n/fornaxdump/1994/1114/sys/src/brazil/pc/l.s
253a
 *  xchgw(v, *p) short for the avanstar stargate driver
 */
TEXT	xchgw(SB),$0
	MOVL	v+4(FP),AX
	MOVL	p+0(FP),BX
	XCHGW	AX,(BX)
	RET

/*
.
## diffname pc/l.s 1995/0426
## diff -e /n/fornaxdump/1994/1114/sys/src/brazil/pc/l.s /n/fornaxdump/1995/0426/sys/src/brazil/pc/l.s
56c
	ORL	$0X80010000,AX				/* PG=1, WP=1 */
.
## diffname pc/l.s 1995/0822
## diff -e /n/fornaxdump/1995/0426/sys/src/brazil/pc/l.s /n/fornaxdump/1995/0822/sys/src/brazil/pc/l.s
573a
	RET

TEXT	spllo(SB),$0
	PUSHFL
	POPL	AX
	STI
TEXT spldone(SB), $0
.
570a
	MOVL	m(SB), AX 			/* save PC in m->splpc */
	MOVL	(SP), BX
	MOVL	BX, 4(AX)

.
564a
	MOVL	m(SB), AX 			/* save PC in m->splpc */
	MOVL	(SP), BX
	MOVL	BX, 4(AX)

.
558,563d
## diffname pc/l.s 1997/0327
## diff -e /n/fornaxdump/1995/0822/sys/src/brazil/pc/l.s /n/emeliedump/1997/0327/sys/src/brazil/pc/l.s
817,824c
TEXT forkret(SB), $0
	POPL	AX
	POPAL
	POPL	GS
	POPL	FS
	POPL	ES
	POPL	DS
	ADDL	$8, SP				/* pop error code and trap type */
	IRETL

TEXT vectortable(SB), $0
	CALL strayintr(SB); BYTE $0x00		/* divide error */
	CALL strayintr(SB); BYTE $0x01		/* debug exception */
	CALL strayintr(SB); BYTE $0x02		/* NMI interrupt */
	CALL strayintr(SB); BYTE $0x03		/* breakpoint */
	CALL strayintr(SB); BYTE $0x04		/* overflow */
	CALL strayintr(SB); BYTE $0x05		/* bound */
	CALL strayintr(SB); BYTE $0x06		/* invalid opcode */
	CALL strayintr(SB); BYTE $0x07		/* no coprocessor available */
	CALL strayintrx(SB); BYTE $0x08		/* double fault */
	CALL strayintr(SB); BYTE $0x09		/* coprocessor segment overflow */
	CALL strayintrx(SB); BYTE $0x0A		/* invalid TSS */
	CALL strayintrx(SB); BYTE $0x0B		/* segment not available */
	CALL strayintrx(SB); BYTE $0x0C		/* stack exception */
	CALL strayintrx(SB); BYTE $0x0D		/* general protection error */
	CALL strayintrx(SB); BYTE $0x0E		/* page fault */
	CALL strayintr(SB); BYTE $0x0F		/*  */
	CALL strayintr(SB); BYTE $0x10		/* coprocessor error */
	CALL strayintrx(SB); BYTE $0x11		/* alignment check */
	CALL strayintr(SB); BYTE $0x12		/* machine check */
	CALL strayintr(SB); BYTE $0x13
	CALL strayintr(SB); BYTE $0x14
	CALL strayintr(SB); BYTE $0x15
	CALL strayintr(SB); BYTE $0x16
	CALL strayintr(SB); BYTE $0x17
	CALL strayintr(SB); BYTE $0x18
	CALL strayintr(SB); BYTE $0x19
	CALL strayintr(SB); BYTE $0x1A
	CALL strayintr(SB); BYTE $0x1B
	CALL strayintr(SB); BYTE $0x1C
	CALL strayintr(SB); BYTE $0x1D
	CALL strayintr(SB); BYTE $0x1E
	CALL strayintr(SB); BYTE $0x1F
	CALL strayintr(SB); BYTE $0x20		/* VectorLAPIC */
	CALL strayintr(SB); BYTE $0x21
	CALL strayintr(SB); BYTE $0x22
	CALL strayintr(SB); BYTE $0x23
	CALL strayintr(SB); BYTE $0x24
	CALL strayintr(SB); BYTE $0x25
	CALL strayintr(SB); BYTE $0x26
	CALL strayintr(SB); BYTE $0x27
	CALL strayintr(SB); BYTE $0x28
	CALL strayintr(SB); BYTE $0x29
	CALL strayintr(SB); BYTE $0x2A
	CALL strayintr(SB); BYTE $0x2B
	CALL strayintr(SB); BYTE $0x2C
	CALL strayintr(SB); BYTE $0x2D
	CALL strayintr(SB); BYTE $0x2E
	CALL strayintr(SB); BYTE $0x2F
	CALL strayintr(SB); BYTE $0x30
	CALL strayintr(SB); BYTE $0x31
	CALL strayintr(SB); BYTE $0x32
	CALL strayintr(SB); BYTE $0x33
	CALL strayintr(SB); BYTE $0x34
	CALL strayintr(SB); BYTE $0x35
	CALL strayintr(SB); BYTE $0x36
	CALL strayintr(SB); BYTE $0x37
	CALL strayintr(SB); BYTE $0x38
	CALL strayintr(SB); BYTE $0x39
	CALL strayintr(SB); BYTE $0x3A
	CALL strayintr(SB); BYTE $0x3B
	CALL strayintr(SB); BYTE $0x3C
	CALL strayintr(SB); BYTE $0x3D
	CALL strayintr(SB); BYTE $0x3E
	CALL strayintr(SB); BYTE $0x3F
	CALL strayintr(SB); BYTE $0x40		/* VectorSYSCALL */
	CALL strayintr(SB); BYTE $0x41
	CALL strayintr(SB); BYTE $0x42
	CALL strayintr(SB); BYTE $0x43
	CALL strayintr(SB); BYTE $0x44
	CALL strayintr(SB); BYTE $0x45
	CALL strayintr(SB); BYTE $0x46
	CALL strayintr(SB); BYTE $0x47
	CALL strayintr(SB); BYTE $0x48
	CALL strayintr(SB); BYTE $0x49
	CALL strayintr(SB); BYTE $0x4A
	CALL strayintr(SB); BYTE $0x4B
	CALL strayintr(SB); BYTE $0x4C
	CALL strayintr(SB); BYTE $0x4D
	CALL strayintr(SB); BYTE $0x4E
	CALL strayintr(SB); BYTE $0x4F
	CALL strayintr(SB); BYTE $0x50
	CALL strayintr(SB); BYTE $0x51
	CALL strayintr(SB); BYTE $0x52
	CALL strayintr(SB); BYTE $0x53
	CALL strayintr(SB); BYTE $0x54
	CALL strayintr(SB); BYTE $0x55
	CALL strayintr(SB); BYTE $0x56
	CALL strayintr(SB); BYTE $0x57
	CALL strayintr(SB); BYTE $0x58
	CALL strayintr(SB); BYTE $0x59
	CALL strayintr(SB); BYTE $0x5A
	CALL strayintr(SB); BYTE $0x5B
	CALL strayintr(SB); BYTE $0x5C
	CALL strayintr(SB); BYTE $0x5D
	CALL strayintr(SB); BYTE $0x5E
	CALL strayintr(SB); BYTE $0x5F
	CALL strayintr(SB); BYTE $0x60
	CALL strayintr(SB); BYTE $0x61
	CALL strayintr(SB); BYTE $0x62
	CALL strayintr(SB); BYTE $0x63
	CALL strayintr(SB); BYTE $0x64
	CALL strayintr(SB); BYTE $0x65
	CALL strayintr(SB); BYTE $0x66
	CALL strayintr(SB); BYTE $0x67
	CALL strayintr(SB); BYTE $0x68
	CALL strayintr(SB); BYTE $0x69
	CALL strayintr(SB); BYTE $0x6A
	CALL strayintr(SB); BYTE $0x6B
	CALL strayintr(SB); BYTE $0x6C
	CALL strayintr(SB); BYTE $0x6D
	CALL strayintr(SB); BYTE $0x6E
	CALL strayintr(SB); BYTE $0x6F
	CALL strayintr(SB); BYTE $0x70
	CALL strayintr(SB); BYTE $0x71
	CALL strayintr(SB); BYTE $0x72
	CALL strayintr(SB); BYTE $0x73
	CALL strayintr(SB); BYTE $0x74
	CALL strayintr(SB); BYTE $0x75
	CALL strayintr(SB); BYTE $0x76
	CALL strayintr(SB); BYTE $0x77
	CALL strayintr(SB); BYTE $0x78
	CALL strayintr(SB); BYTE $0x79
	CALL strayintr(SB); BYTE $0x7A
	CALL strayintr(SB); BYTE $0x7B
	CALL strayintr(SB); BYTE $0x7C
	CALL strayintr(SB); BYTE $0x7D
	CALL strayintr(SB); BYTE $0x7E
	CALL strayintr(SB); BYTE $0x7F
	CALL strayintr(SB); BYTE $0x80		/* Vector[A]PIC */
	CALL strayintr(SB); BYTE $0x81
	CALL strayintr(SB); BYTE $0x82
	CALL strayintr(SB); BYTE $0x83
	CALL strayintr(SB); BYTE $0x84
	CALL strayintr(SB); BYTE $0x85
	CALL strayintr(SB); BYTE $0x86
	CALL strayintr(SB); BYTE $0x87
	CALL strayintr(SB); BYTE $0x88
	CALL strayintr(SB); BYTE $0x89
	CALL strayintr(SB); BYTE $0x8A
	CALL strayintr(SB); BYTE $0x8B
	CALL strayintr(SB); BYTE $0x8C
	CALL strayintr(SB); BYTE $0x8D
	CALL strayintr(SB); BYTE $0x8E
	CALL strayintr(SB); BYTE $0x8F
	CALL strayintr(SB); BYTE $0x90
	CALL strayintr(SB); BYTE $0x91
	CALL strayintr(SB); BYTE $0x92
	CALL strayintr(SB); BYTE $0x93
	CALL strayintr(SB); BYTE $0x94
	CALL strayintr(SB); BYTE $0x95
	CALL strayintr(SB); BYTE $0x96
	CALL strayintr(SB); BYTE $0x97
	CALL strayintr(SB); BYTE $0x98
	CALL strayintr(SB); BYTE $0x99
	CALL strayintr(SB); BYTE $0x9A
	CALL strayintr(SB); BYTE $0x9B
	CALL strayintr(SB); BYTE $0x9C
	CALL strayintr(SB); BYTE $0x9D
	CALL strayintr(SB); BYTE $0x9E
	CALL strayintr(SB); BYTE $0x9F
	CALL strayintr(SB); BYTE $0xA0
	CALL strayintr(SB); BYTE $0xA1
	CALL strayintr(SB); BYTE $0xA2
	CALL strayintr(SB); BYTE $0xA3
	CALL strayintr(SB); BYTE $0xA4
	CALL strayintr(SB); BYTE $0xA5
	CALL strayintr(SB); BYTE $0xA6
	CALL strayintr(SB); BYTE $0xA7
	CALL strayintr(SB); BYTE $0xA8
	CALL strayintr(SB); BYTE $0xA9
	CALL strayintr(SB); BYTE $0xAA
	CALL strayintr(SB); BYTE $0xAB
	CALL strayintr(SB); BYTE $0xAC
	CALL strayintr(SB); BYTE $0xAD
	CALL strayintr(SB); BYTE $0xAE
	CALL strayintr(SB); BYTE $0xAF
	CALL strayintr(SB); BYTE $0xB0
	CALL strayintr(SB); BYTE $0xB1
	CALL strayintr(SB); BYTE $0xB2
	CALL strayintr(SB); BYTE $0xB3
	CALL strayintr(SB); BYTE $0xB4
	CALL strayintr(SB); BYTE $0xB5
	CALL strayintr(SB); BYTE $0xB6
	CALL strayintr(SB); BYTE $0xB7
	CALL strayintr(SB); BYTE $0xB8
	CALL strayintr(SB); BYTE $0xB9
	CALL strayintr(SB); BYTE $0xBA
	CALL strayintr(SB); BYTE $0xBB
	CALL strayintr(SB); BYTE $0xBC
	CALL strayintr(SB); BYTE $0xBD
	CALL strayintr(SB); BYTE $0xBE
	CALL strayintr(SB); BYTE $0xBF
	CALL strayintr(SB); BYTE $0xC0
	CALL strayintr(SB); BYTE $0xC1
	CALL strayintr(SB); BYTE $0xC2
	CALL strayintr(SB); BYTE $0xC3
	CALL strayintr(SB); BYTE $0xC4
	CALL strayintr(SB); BYTE $0xC5
	CALL strayintr(SB); BYTE $0xC6
	CALL strayintr(SB); BYTE $0xC7
	CALL strayintr(SB); BYTE $0xC8
	CALL strayintr(SB); BYTE $0xC9
	CALL strayintr(SB); BYTE $0xCA
	CALL strayintr(SB); BYTE $0xCB
	CALL strayintr(SB); BYTE $0xCC
	CALL strayintr(SB); BYTE $0xCD
	CALL strayintr(SB); BYTE $0xCE
	CALL strayintr(SB); BYTE $0xCF
	CALL strayintr(SB); BYTE $0xD0
	CALL strayintr(SB); BYTE $0xD1
	CALL strayintr(SB); BYTE $0xD2
	CALL strayintr(SB); BYTE $0xD3
	CALL strayintr(SB); BYTE $0xD4
	CALL strayintr(SB); BYTE $0xD5
	CALL strayintr(SB); BYTE $0xD6
	CALL strayintr(SB); BYTE $0xD7
	CALL strayintr(SB); BYTE $0xD8
	CALL strayintr(SB); BYTE $0xD9
	CALL strayintr(SB); BYTE $0xDA
	CALL strayintr(SB); BYTE $0xDB
	CALL strayintr(SB); BYTE $0xDC
	CALL strayintr(SB); BYTE $0xDD
	CALL strayintr(SB); BYTE $0xDE
	CALL strayintr(SB); BYTE $0xDF
	CALL strayintr(SB); BYTE $0xE0
	CALL strayintr(SB); BYTE $0xE1
	CALL strayintr(SB); BYTE $0xE2
	CALL strayintr(SB); BYTE $0xE3
	CALL strayintr(SB); BYTE $0xE4
	CALL strayintr(SB); BYTE $0xE5
	CALL strayintr(SB); BYTE $0xE6
	CALL strayintr(SB); BYTE $0xE7
	CALL strayintr(SB); BYTE $0xE8
	CALL strayintr(SB); BYTE $0xE9
	CALL strayintr(SB); BYTE $0xEA
	CALL strayintr(SB); BYTE $0xEB
	CALL strayintr(SB); BYTE $0xEC
	CALL strayintr(SB); BYTE $0xED
	CALL strayintr(SB); BYTE $0xEE
	CALL strayintr(SB); BYTE $0xEF
	CALL strayintr(SB); BYTE $0xF0
	CALL strayintr(SB); BYTE $0xF1
	CALL strayintr(SB); BYTE $0xF2
	CALL strayintr(SB); BYTE $0xF3
	CALL strayintr(SB); BYTE $0xF4
	CALL strayintr(SB); BYTE $0xF5
	CALL strayintr(SB); BYTE $0xF6
	CALL strayintr(SB); BYTE $0xF7
	CALL strayintr(SB); BYTE $0xF8
	CALL strayintr(SB); BYTE $0xF9
	CALL strayintr(SB); BYTE $0xFA
	CALL strayintr(SB); BYTE $0xFB
	CALL strayintr(SB); BYTE $0xFC
	CALL strayintr(SB); BYTE $0xFD
	CALL strayintr(SB); BYTE $0xFE
	CALL strayintr(SB); BYTE $0xFF
.
811,815c
intrcommon:
	PUSHL	DS
	PUSHL	ES
	PUSHL	FS
	PUSHL	GS
	PUSHAL
	MOVL	$(KDSEL),AX
	MOVW	AX, DS
	MOVW	AX, ES
	PUSHL	SP
	CALL	trap(SB)
.
802,809c
TEXT strayintrx(SB), $0
	XCHGL	AX, (SP)			/* exchange AX with pointer to trap type */
	MOVBLZX	(AX), AX			/* trap type -> AX */
	XCHGL	AX, (SP)			/* exchange trap type with AX */
.
796,800c
TEXT strayintr(SB), $0
	PUSHL	AX				/* save AX */
	MOVL	4(SP), AX			/* return PC from vectortable(SB) */
	MOVBLZX	(AX), AX			/* trap type */
	XCHGL	AX, (SP)			/* restore AX and put the type on the stack */
	JMP	intrcommon
.
794c
 * Interrupt/exception handling.
 * Each entry in the vector table calls either strayintr or strayintrx depending
 * on whether an error code has beemn automatically pushed onto the stack
 * (strayintrx) or not, in which case a dummy entry must be pushed before retrieving
 * the trap type from the vector table entry and placing it on the stack as part
 * of the Ureg structure.
 * The size of each entry in the vector table (6 bytes) is known in trapinit().
.
755,790c
TEXT setlabel(SB), $0
	MOVL	label+0(FP), AX
	MOVL	SP, 0(AX)			/* store sp */
	MOVL	0(SP), BX			/* store return pc */
	MOVL	BX, 4(AX)
	MOVL	$0, AX				/* return 0 */
.
722,752c
TEXT gotolabel(SB), $0
	MOVL	label+0(FP), AX
	MOVL	0(AX), SP			/* restore sp */
	MOVL	4(AX), AX			/* put return pc on the stack */
	MOVL	AX, 0(SP)
	MOVL	$1, AX				/* return 1 */
.
720c
 *  label consists of a stack pointer and a PC
.
701,718d
696,699d
686,694d
660,684c
TEXT xchgl(SB), $0
	MOVL	v+4(FP), AX
	MOVL	p+0(FP), BX
	XCHGL	AX, (BX)
.
651,658d
640,648c
TEXT xchgw(SB), $0
	MOVL	v+4(FP), AX
	MOVL	p+0(FP), BX
	XCHGW	AX, (BX)
.
629,637c
TEXT wbflush(SB), $0
	CPUID
.
593,626c
TEXT tas(SB), $0
	MOVL	$0xDEADDEAD, AX
	MOVL	lock+0(FP), BX
	XCHGL	AX, (BX)			/* lock->key */
.
591c
 * Test-And-Set
.
587a
	ANDL	$0x200, AX			/* interrupt enable flag */
.
585c
TEXT islo(SB), $0
.
581a
	RET

.
578c
TEXT spllo(SB), $0
.
573c
	MOVL	s+0(FP), AX
.
571c
	MOVL	BX, (AX)
.
568,569c
TEXT splx(SB), $0
	MOVL	$(MACHADDR+0x04), AX 		/* save PC in m->splpc */
.
561c
	MOVL	BX, (AX)
.
356,559c
TEXT splhi(SB), $0
	MOVL	$(MACHADDR+0x04), AX 		/* save PC in m->splpc */
.
354d
348,349c
TEXT fpenv(SB), $0				/* save state without waiting */
	MOVL	p+0(FP), AX
.
344c
TEXT fpstatus(SB), $0				/* get floating point status */
.
339c
	MOVL	p+0(FP), AX
.
337c
TEXT fprestore(SB), $0				/* enable and restore state */
.
330,331c
TEXT fpsave(SB), $0				/* save state and disable */
	MOVL	p+0(FP), AX
.
325c
	FLDCW	0(SP)				/* ignore underflow/precision, signal others */
.
320c
TEXT fpinit(SB), $0				/* enable and init */
.
316c
TEXT fpoff(SB), $0				/* disable */
.
311,314c
#define	FPON								;\
	MOVL	CR0, AX							;\
	ANDL	$~0x4, AX			/* EM=0 */		;\
	MOVL	AX, CR0
.
305,309c
/*
 * Floating point.
 */
#define	FPOFF								;\
	WAIT								;\
	MOVL	CR0, AX							;\
	ORL	$0x24, AX			/* EM=1, NE=1 */	;\
	MOVL	AX, CR0
.
301,302c
/*
 * Basic timing loop to determine CPU frequency.
 */
TEXT aamloop(SB), $0
	MOVL	count+0(FP), CX
_aamloop:
	AAM
	LOOP	_aamloop
.
297,298c
	MOVL	$1, AX
	CPUID
	JMP	_cpuid

_cpu486:
	MOVL	$0x400, AX
	MOVL	$0, DX
	JMP	_cpuid

_cpu386:
	MOVL	$0x300, AX
	MOVL	$0, DX

_cpuid:
	MOVL	ax+4(FP), BP
	MOVL	AX, 0(BP)
	MOVL	dx+8(FP), BP
	MOVL	DX, 0(BP)
.
293,295c
	MOVL	$0, AX
	CPUID
	MOVL	id+0(FP), BP
	MOVL	BX, 0(BP)			/* "Genu" "Auth" "Cyri" */
	MOVL	DX, 4(BP)			/* "ineI" "enti" "xIns" */
	MOVL	CX, 8(BP)			/* "ntel" "cAMD" "tead" */
.
288,291c
	PUSHFL
	POPL	AX				/* retrieve value */
	XORL	BX, AX
	TESTL	$0x040000, AX			/* Ac */
	JZ	_cpu386				/* can't set this bit on 386 */
	TESTL	$0x200000, AX			/* Id */
	JZ	_cpu486				/* can't toggle this bit on some 486 */
.
283,286c
	MOVL	$0, AX
	PUSHL	AX
	POPFL					/* clear Id|Ac, EFLAGS initialised */
.
274,281c
	PUSHFL
	POPL	BX				/* retrieve value */
.
265,272c
TEXT cpuid(SB), $0
	MOVL	$0x240000, AX
	PUSHL	AX
	POPFL					/* set Id|Ac */
.
263c
 * Try to determine the CPU type which requires fiddling with EFLAGS.
 * If the Id bit can be toggled then the CPUID instruciton can be used
 * to determine CPU identity and features. First have to check if it's
 * a 386 (Ac bit can't be set). If it's not a 386 and the Id bit can't be
 * toggled then it's an older 486 of some kind.
 *
 *	cpuid(id[], &ax, &dx);
.
253,259c
TEXT wbinvd(SB), $0
	WBINVD
.
251a
	
TEXT wrmsr(SB), $0
	MOVL	index+0(FP), CX
	MOVL	hi+4(FP), DX
	MOVL	lo+8(FP), AX
	WRMSR
	RET
.
244,250c
TEXT rdmsr(SB), $0				/* model-specific register */
	MOVL	index+0(FP), CX
	RDMSR
	MOVL	hi+4(FP), CX
	MOVL	DX, (CX)
	MOVL	lo+8(FP), CX
	MOVL	AX, (CX)
.
238,241c
TEXT putcr4(SB), $0
	MOVL	cr4+0(FP), AX
	MOVL	AX, CR4
.
233,236c
TEXT getcr4(SB), $0				/* CR4 - extensions */
	MOVL	CR4, AX
	RET
.
224,230c
TEXT putcr3(SB), $0
	MOVL	cr3+0(FP), AX
	MOVL	AX, CR3
.
218,221c
TEXT getcr3(SB), $0				/* CR3 - page directory base */
	MOVL	CR3, AX
.
213,216c
TEXT getcr2(SB), $0				/* CR2 - page fault linear address */
	MOVL	CR2, AX
	RET
.
208,210c
TEXT getcr0(SB), $0				/* CR0 - processor control */
	MOVL	CR0, AX
.
203,206c
TEXT ltr(SB), $0				/* TR - task register */
	MOVL	tptr+0(FP), AX
	MOVW	AX, TASK
	RET
.
197,200c
TEXT lidt(SB), $0				/* IDTR - interrupt descriptor table */
	MOVL	idtptr+0(FP), AX
	MOVL	(AX), IDTR
.
195c
TEXT lgdt(SB), $0				/* GDTR - global descriptor table */
	MOVL	gdtptr+0(FP), AX
	MOVL	(AX), GDTR
	RET
.
193c
 * Read/write various system registers.
 * CR4 and the 'model specific registers' should only be read/written
 * after it has been determined the processor supports them
.
183,189c
TEXT outsl(SB), $0
	MOVL	port+0(FP), DX
	MOVL	address+4(FP), SI
	MOVL	count+8(FP), CX
	CLD
	REP;	OUTSL
.
177,180c
TEXT outl(SB), $0
	MOVL	port+0(FP), DX
	MOVL	long+4(FP), AX
	OUTL
.
172,175c
TEXT outss(SB), $0
	MOVL	port+0(FP), DX
	MOVL	address+4(FP), SI
	MOVL	count+8(FP), CX
	CLD
	REP;	OP16; OUTSL
	RET
.
167,169c
TEXT outs(SB), $0
	MOVL	port+0(FP), DX
	MOVL	short+4(FP), AX
	OP16;	OUTL
.
162,165c
TEXT outsb(SB),$0
	MOVL	port+0(FP), DX
	MOVL	address+4(FP), SI
	MOVL	count+8(FP), CX
	CLD
	REP;	OUTSB
	RET
.
156,159c
TEXT outb(SB), $0
	MOVL	port+0(FP), DX
	MOVL	byte+4(FP), AX
	OUTB
.
151,154c
TEXT insl(SB), $0
	MOVL	port+0(FP), DX
	MOVL	address+4(FP), DI
	MOVL	count+8(FP), CX
	CLD
	REP;	INSL
	RET
.
146,148c
TEXT inl(SB), $0
	MOVL	port+0(FP), DX
	INL
.
141,144c
TEXT inss(SB), $0
	MOVL	port+0(FP), DX
	MOVL	address+4(FP), DI
	MOVL	count+8(FP), CX
	CLD
	REP;	OP16; INSL
	RET
.
135,138c
TEXT ins(SB), $0
	MOVL	port+0(FP), DX
	XORL	AX, AX
	OP16;	INL
.
130,133c
TEXT insb(SB), $0
	MOVL	port+0(FP), DX
	MOVL	address+4(FP), DI
	MOVL	count+8(FP), CX
	CLD
	REP;	INSB
	RET
.
125,126c
/*
 * Port I/O.
 *	in[bsl]		input a byte|short|long
 *	ins[bsl]	input a string of bytes|shorts|longs
 *	out[bsl]	output a byte|short|long
 *	outs[bsl]	output a string of bytes|shorts|longs
 */
TEXT inb(SB), $0
	MOVL	port+0(FP), DX
	XORL	AX, AX
.
123c
TEXT idle(SB), $0
_idle:
	HLT
	JMP	_idle
.
121c
 * Park a processor. Should never fall through a return from main to here,
 * should only be called by application processors when shutting down.
.
117,118c
	CALL	main(SB)
.
115c
	MOVL	$0, AX
	PUSHL	AX
	POPFL
.
113c
 * Need to do one final thing to ensure a clean machine enviroment,
 * clear the EFLAGS register, which can only be done once there is a stack.
.
111a
	ADDL	$(MACHSIZE-4), SP		/* initialise stack */

.
108,110c
	MOVL	$MACHADDR, SP
	MOVL	SP, m(SB)			/* initialise global Mach pointer */
	MOVL	$0, 0(SP)			/* initialise m->machno */
.
104,106c
	CLD
	REP;	STOSL				/* clear BSS */
.
100,102c
_clearbss:
	MOVL	$edata(SB), DI
	XORL	AX, AX
	MOVL	$end(SB), CX
	SUBL	DI, CX				/* end-edata bytes */
	SHRL	$2, CX				/* end-edata doublewords */
.
98c
TEXT _startpg(SB), $0
	MOVL	CX, AX				/* physical address of PDB */
	ORL	$KZERO, AX
	MOVL	$0, (PDO(0))(AX)		/* undo double-map of KZERO at 0 */
	MOVL	CX, CR3				/* load and flush the mmu */
.
96c
 * Basic machine environment set, can clear BSS and create a stack.
 * The stack starts at the top of the page containing the Mach structure.
 * The x86 architecture forces the use of the same virtual address for
 * each processor's Mach structure, so the global Mach pointer 'm' can
 * be initialised here.
.
90,94d
87,88c
	MOVL	$_startpg(SB), AX
	MOVL	DX, CR0				/* turn on paging */
	JMP*	AX
.
85c
	MOVL	CR0, DX
	ORL	$0x80010000, DX			/* PG|WP */
	ANDL	$~0x6000000A, DX		/* ~(CD|NW|TS|MP) */
.
78,83c
/*
 * Now ready to use the new map. Make sure the processor options are what is wanted.
 * It is necessary on some processors to follow mode switching with a JMP instruction
 * to clear the prefetch queues.
 * There's a little mystery here - the Pentium Pro appears to need an identity
 * mmu map for the switch to virtual mode. The manual doesn't say this is necessary
 * and it isn't required on the Pentium.
 * To this end double map KZERO at virtual 0 and undo the mapping once virtual
 * nirvana has been attained.
 */
	MOVL	$PADDR(CPU0PDB), CX		/* load address of page directory */
	MOVL	CX, BX
	MOVL	(PDO(KZERO))(BX), DX		/* double-map KZERO at 0 */
	MOVL	DX, (PDO(0))(BX)
	MOVL	CX, CR3
	DELAY					/* JMP .+2 */
.
69,76c
	MOVL	$CPU0MACHPTE, AX
	ADDL	$PTO(MACHADDR), AX		/* page table entry offset for MACHADDR */
	MOVL	$PADDR(CPU0MACH), (AX)		/* PTE for Mach */
	MOVL	$(PTEWRITE|PTEVALID), BX	/* page permissions */
	ORL	BX, (AX)
.
67c
	MOVL	$CPU0PDB, AX
	ADDL	$PDO(MACHADDR), AX		/* page directory offset for MACHADDR */
	MOVL	$PADDR(CPU0MACHPTE), (AX)	/* PTE's for 4MB containing MACHADDR */
	MOVL	$(PTEWRITE|PTEVALID), BX	/* page permissions */
	ORL	BX, (AX)
.
60,65c
	MOVL	$CPU0PTE, AX			/* first page of page table */
	MOVL	$1024, CX			/* 1024 pages in 4MB */
_setpte:
	MOVL	BX, (AX)
	ADDL	$(1<<PGSHIFT), BX
	ADDL	$4, AX
	LOOP	_setpte
.
51,58c
	MOVL	$CPU0PDB, AX
	ADDL	$PDO(KZERO), AX			/* page directory offset for KZERO */
	MOVL	$PADDR(CPU0PTE), (AX)		/* PTE's for 0x80000000 */
	MOVL	$(PTEWRITE|PTEVALID), BX	/* page permissions */
	ORL	BX, (AX)
.
41,49c
	CLD
	REP;	STOSL
.
27,39c
	MOVL	$CPU0PDB, DI			/* clear 4 pages for the tables etc. */
	XORL	AX, AX
	MOVL	$(4*BY2PG), CX
	SHRL	$2, CX
.
14,25c
/*
 * First check if the bootstrap programme left the first 4MB nicely mapped, otherwise
 * make the basic page tables for processor 0. Four pages are needed for the basic set:
 * a page directory, a page table for mapping the first 4MB of physical memory, a page
 * table for mapping the Mach page, and a page for the Mach structure itself.
 * The remaining PTEs will be allocated later when memory is sized.
 */
TEXT _start0x80100020(SB), $0
	MOVL	CR3, AX				/* check the page directory base */
	CMPL	AX, $PADDR(CPU0PDB)
	JEQ	_clearbss
.
12a
	MOVL	$_start0x80100020(SB), AX
	JMP*	AX
.
11a
/*
 * Macros for calculating offsets within the page directory base
 * and page tables. Note that these are assembler-specific hence
 * the '<<2'.
 */
#define PDO(a)		(((((a))>>22) & 0x03FF)<<2)
#define PTO(a)		(((((a))>>12) & 0x03FF)<<2)

/*
 * Entered here from the bootstrap programme possibly via a jump to 0x00100020, so
 * need to make another jump to set the correct virtual address.
 * In protected mode with paging turned on, the first 4MB of physical memory mapped
 * to KZERO and up.
 */
TEXT _start0x00100020(SB),$0
.
10c
#define OP16		BYTE $0x66
#define	DELAY		BYTE $0xEB; BYTE $0x00	/* JMP .+2 */
#define CPUID		BYTE $0x0F; BYTE $0xA2	/* CPUID, argument in AX */
#define WRMSR		BYTE $0x0F; BYTE $0x30	/* WRMSR, argument in AX/DX (lo/hi) */
#define RDMSR		BYTE $0x0F; BYTE $0x32	/* RDMSR, result in AX/DX (lo/hi) */
#define WBINVD		BYTE $0x0F; BYTE $0x09
.
7,8c
 * Some machine instructions not handled by 8[al].
.
3,4c
#define PADDR(a)	((a) & ~KZERO)
#define KADDR(a)	(KZERO|(a))
.
## diffname pc/l.s 1997/1101
## diff -e /n/emeliedump/1997/0327/sys/src/brazil/pc/l.s /n/emeliedump/1997/1101/sys/src/brazil/pc/l.s
554,809c
	CALL _strayintr(SB); BYTE $0x00		/* divide error */
	CALL _strayintr(SB); BYTE $0x01		/* debug exception */
	CALL _strayintr(SB); BYTE $0x02		/* NMI interrupt */
	CALL _strayintr(SB); BYTE $0x03		/* breakpoint */
	CALL _strayintr(SB); BYTE $0x04		/* overflow */
	CALL _strayintr(SB); BYTE $0x05		/* bound */
	CALL _strayintr(SB); BYTE $0x06		/* invalid opcode */
	CALL _strayintr(SB); BYTE $0x07		/* no coprocessor available */
	CALL _strayintrx(SB); BYTE $0x08	/* double fault */
	CALL _strayintr(SB); BYTE $0x09		/* coprocessor segment overflow */
	CALL _strayintrx(SB); BYTE $0x0A	/* invalid TSS */
	CALL _strayintrx(SB); BYTE $0x0B	/* segment not available */
	CALL _strayintrx(SB); BYTE $0x0C	/* stack exception */
	CALL _strayintrx(SB); BYTE $0x0D	/* general protection error */
	CALL _strayintrx(SB); BYTE $0x0E	/* page fault */
	CALL _strayintr(SB); BYTE $0x0F		/*  */
	CALL _strayintr(SB); BYTE $0x10		/* coprocessor error */
	CALL _strayintrx(SB); BYTE $0x11	/* alignment check */
	CALL _strayintr(SB); BYTE $0x12		/* machine check */
	CALL _strayintr(SB); BYTE $0x13
	CALL _strayintr(SB); BYTE $0x14
	CALL _strayintr(SB); BYTE $0x15
	CALL _strayintr(SB); BYTE $0x16
	CALL _strayintr(SB); BYTE $0x17
	CALL _strayintr(SB); BYTE $0x18
	CALL _strayintr(SB); BYTE $0x19
	CALL _strayintr(SB); BYTE $0x1A
	CALL _strayintr(SB); BYTE $0x1B
	CALL _strayintr(SB); BYTE $0x1C
	CALL _strayintr(SB); BYTE $0x1D
	CALL _strayintr(SB); BYTE $0x1E
	CALL _strayintr(SB); BYTE $0x1F
	CALL _strayintr(SB); BYTE $0x20		/* VectorLAPIC */
	CALL _strayintr(SB); BYTE $0x21
	CALL _strayintr(SB); BYTE $0x22
	CALL _strayintr(SB); BYTE $0x23
	CALL _strayintr(SB); BYTE $0x24
	CALL _strayintr(SB); BYTE $0x25
	CALL _strayintr(SB); BYTE $0x26
	CALL _strayintr(SB); BYTE $0x27
	CALL _strayintr(SB); BYTE $0x28
	CALL _strayintr(SB); BYTE $0x29
	CALL _strayintr(SB); BYTE $0x2A
	CALL _strayintr(SB); BYTE $0x2B
	CALL _strayintr(SB); BYTE $0x2C
	CALL _strayintr(SB); BYTE $0x2D
	CALL _strayintr(SB); BYTE $0x2E
	CALL _strayintr(SB); BYTE $0x2F
	CALL _strayintr(SB); BYTE $0x30
	CALL _strayintr(SB); BYTE $0x31
	CALL _strayintr(SB); BYTE $0x32
	CALL _strayintr(SB); BYTE $0x33
	CALL _strayintr(SB); BYTE $0x34
	CALL _strayintr(SB); BYTE $0x35
	CALL _strayintr(SB); BYTE $0x36
	CALL _strayintr(SB); BYTE $0x37
	CALL _strayintr(SB); BYTE $0x38
	CALL _strayintr(SB); BYTE $0x39
	CALL _strayintr(SB); BYTE $0x3A
	CALL _strayintr(SB); BYTE $0x3B
	CALL _strayintr(SB); BYTE $0x3C
	CALL _strayintr(SB); BYTE $0x3D
	CALL _strayintr(SB); BYTE $0x3E
	CALL _strayintr(SB); BYTE $0x3F
	CALL _syscallintr(SB); BYTE $0x40	/* VectorSYSCALL */
	CALL _strayintr(SB); BYTE $0x41
	CALL _strayintr(SB); BYTE $0x42
	CALL _strayintr(SB); BYTE $0x43
	CALL _strayintr(SB); BYTE $0x44
	CALL _strayintr(SB); BYTE $0x45
	CALL _strayintr(SB); BYTE $0x46
	CALL _strayintr(SB); BYTE $0x47
	CALL _strayintr(SB); BYTE $0x48
	CALL _strayintr(SB); BYTE $0x49
	CALL _strayintr(SB); BYTE $0x4A
	CALL _strayintr(SB); BYTE $0x4B
	CALL _strayintr(SB); BYTE $0x4C
	CALL _strayintr(SB); BYTE $0x4D
	CALL _strayintr(SB); BYTE $0x4E
	CALL _strayintr(SB); BYTE $0x4F
	CALL _strayintr(SB); BYTE $0x50
	CALL _strayintr(SB); BYTE $0x51
	CALL _strayintr(SB); BYTE $0x52
	CALL _strayintr(SB); BYTE $0x53
	CALL _strayintr(SB); BYTE $0x54
	CALL _strayintr(SB); BYTE $0x55
	CALL _strayintr(SB); BYTE $0x56
	CALL _strayintr(SB); BYTE $0x57
	CALL _strayintr(SB); BYTE $0x58
	CALL _strayintr(SB); BYTE $0x59
	CALL _strayintr(SB); BYTE $0x5A
	CALL _strayintr(SB); BYTE $0x5B
	CALL _strayintr(SB); BYTE $0x5C
	CALL _strayintr(SB); BYTE $0x5D
	CALL _strayintr(SB); BYTE $0x5E
	CALL _strayintr(SB); BYTE $0x5F
	CALL _strayintr(SB); BYTE $0x60
	CALL _strayintr(SB); BYTE $0x61
	CALL _strayintr(SB); BYTE $0x62
	CALL _strayintr(SB); BYTE $0x63
	CALL _strayintr(SB); BYTE $0x64
	CALL _strayintr(SB); BYTE $0x65
	CALL _strayintr(SB); BYTE $0x66
	CALL _strayintr(SB); BYTE $0x67
	CALL _strayintr(SB); BYTE $0x68
	CALL _strayintr(SB); BYTE $0x69
	CALL _strayintr(SB); BYTE $0x6A
	CALL _strayintr(SB); BYTE $0x6B
	CALL _strayintr(SB); BYTE $0x6C
	CALL _strayintr(SB); BYTE $0x6D
	CALL _strayintr(SB); BYTE $0x6E
	CALL _strayintr(SB); BYTE $0x6F
	CALL _strayintr(SB); BYTE $0x70
	CALL _strayintr(SB); BYTE $0x71
	CALL _strayintr(SB); BYTE $0x72
	CALL _strayintr(SB); BYTE $0x73
	CALL _strayintr(SB); BYTE $0x74
	CALL _strayintr(SB); BYTE $0x75
	CALL _strayintr(SB); BYTE $0x76
	CALL _strayintr(SB); BYTE $0x77
	CALL _strayintr(SB); BYTE $0x78
	CALL _strayintr(SB); BYTE $0x79
	CALL _strayintr(SB); BYTE $0x7A
	CALL _strayintr(SB); BYTE $0x7B
	CALL _strayintr(SB); BYTE $0x7C
	CALL _strayintr(SB); BYTE $0x7D
	CALL _strayintr(SB); BYTE $0x7E
	CALL _strayintr(SB); BYTE $0x7F
	CALL _strayintr(SB); BYTE $0x80		/* Vector[A]PIC */
	CALL _strayintr(SB); BYTE $0x81
	CALL _strayintr(SB); BYTE $0x82
	CALL _strayintr(SB); BYTE $0x83
	CALL _strayintr(SB); BYTE $0x84
	CALL _strayintr(SB); BYTE $0x85
	CALL _strayintr(SB); BYTE $0x86
	CALL _strayintr(SB); BYTE $0x87
	CALL _strayintr(SB); BYTE $0x88
	CALL _strayintr(SB); BYTE $0x89
	CALL _strayintr(SB); BYTE $0x8A
	CALL _strayintr(SB); BYTE $0x8B
	CALL _strayintr(SB); BYTE $0x8C
	CALL _strayintr(SB); BYTE $0x8D
	CALL _strayintr(SB); BYTE $0x8E
	CALL _strayintr(SB); BYTE $0x8F
	CALL _strayintr(SB); BYTE $0x90
	CALL _strayintr(SB); BYTE $0x91
	CALL _strayintr(SB); BYTE $0x92
	CALL _strayintr(SB); BYTE $0x93
	CALL _strayintr(SB); BYTE $0x94
	CALL _strayintr(SB); BYTE $0x95
	CALL _strayintr(SB); BYTE $0x96
	CALL _strayintr(SB); BYTE $0x97
	CALL _strayintr(SB); BYTE $0x98
	CALL _strayintr(SB); BYTE $0x99
	CALL _strayintr(SB); BYTE $0x9A
	CALL _strayintr(SB); BYTE $0x9B
	CALL _strayintr(SB); BYTE $0x9C
	CALL _strayintr(SB); BYTE $0x9D
	CALL _strayintr(SB); BYTE $0x9E
	CALL _strayintr(SB); BYTE $0x9F
	CALL _strayintr(SB); BYTE $0xA0
	CALL _strayintr(SB); BYTE $0xA1
	CALL _strayintr(SB); BYTE $0xA2
	CALL _strayintr(SB); BYTE $0xA3
	CALL _strayintr(SB); BYTE $0xA4
	CALL _strayintr(SB); BYTE $0xA5
	CALL _strayintr(SB); BYTE $0xA6
	CALL _strayintr(SB); BYTE $0xA7
	CALL _strayintr(SB); BYTE $0xA8
	CALL _strayintr(SB); BYTE $0xA9
	CALL _strayintr(SB); BYTE $0xAA
	CALL _strayintr(SB); BYTE $0xAB
	CALL _strayintr(SB); BYTE $0xAC
	CALL _strayintr(SB); BYTE $0xAD
	CALL _strayintr(SB); BYTE $0xAE
	CALL _strayintr(SB); BYTE $0xAF
	CALL _strayintr(SB); BYTE $0xB0
	CALL _strayintr(SB); BYTE $0xB1
	CALL _strayintr(SB); BYTE $0xB2
	CALL _strayintr(SB); BYTE $0xB3
	CALL _strayintr(SB); BYTE $0xB4
	CALL _strayintr(SB); BYTE $0xB5
	CALL _strayintr(SB); BYTE $0xB6
	CALL _strayintr(SB); BYTE $0xB7
	CALL _strayintr(SB); BYTE $0xB8
	CALL _strayintr(SB); BYTE $0xB9
	CALL _strayintr(SB); BYTE $0xBA
	CALL _strayintr(SB); BYTE $0xBB
	CALL _strayintr(SB); BYTE $0xBC
	CALL _strayintr(SB); BYTE $0xBD
	CALL _strayintr(SB); BYTE $0xBE
	CALL _strayintr(SB); BYTE $0xBF
	CALL _strayintr(SB); BYTE $0xC0
	CALL _strayintr(SB); BYTE $0xC1
	CALL _strayintr(SB); BYTE $0xC2
	CALL _strayintr(SB); BYTE $0xC3
	CALL _strayintr(SB); BYTE $0xC4
	CALL _strayintr(SB); BYTE $0xC5
	CALL _strayintr(SB); BYTE $0xC6
	CALL _strayintr(SB); BYTE $0xC7
	CALL _strayintr(SB); BYTE $0xC8
	CALL _strayintr(SB); BYTE $0xC9
	CALL _strayintr(SB); BYTE $0xCA
	CALL _strayintr(SB); BYTE $0xCB
	CALL _strayintr(SB); BYTE $0xCC
	CALL _strayintr(SB); BYTE $0xCD
	CALL _strayintr(SB); BYTE $0xCE
	CALL _strayintr(SB); BYTE $0xCF
	CALL _strayintr(SB); BYTE $0xD0
	CALL _strayintr(SB); BYTE $0xD1
	CALL _strayintr(SB); BYTE $0xD2
	CALL _strayintr(SB); BYTE $0xD3
	CALL _strayintr(SB); BYTE $0xD4
	CALL _strayintr(SB); BYTE $0xD5
	CALL _strayintr(SB); BYTE $0xD6
	CALL _strayintr(SB); BYTE $0xD7
	CALL _strayintr(SB); BYTE $0xD8
	CALL _strayintr(SB); BYTE $0xD9
	CALL _strayintr(SB); BYTE $0xDA
	CALL _strayintr(SB); BYTE $0xDB
	CALL _strayintr(SB); BYTE $0xDC
	CALL _strayintr(SB); BYTE $0xDD
	CALL _strayintr(SB); BYTE $0xDE
	CALL _strayintr(SB); BYTE $0xDF
	CALL _strayintr(SB); BYTE $0xE0
	CALL _strayintr(SB); BYTE $0xE1
	CALL _strayintr(SB); BYTE $0xE2
	CALL _strayintr(SB); BYTE $0xE3
	CALL _strayintr(SB); BYTE $0xE4
	CALL _strayintr(SB); BYTE $0xE5
	CALL _strayintr(SB); BYTE $0xE6
	CALL _strayintr(SB); BYTE $0xE7
	CALL _strayintr(SB); BYTE $0xE8
	CALL _strayintr(SB); BYTE $0xE9
	CALL _strayintr(SB); BYTE $0xEA
	CALL _strayintr(SB); BYTE $0xEB
	CALL _strayintr(SB); BYTE $0xEC
	CALL _strayintr(SB); BYTE $0xED
	CALL _strayintr(SB); BYTE $0xEE
	CALL _strayintr(SB); BYTE $0xEF
	CALL _strayintr(SB); BYTE $0xF0
	CALL _strayintr(SB); BYTE $0xF1
	CALL _strayintr(SB); BYTE $0xF2
	CALL _strayintr(SB); BYTE $0xF3
	CALL _strayintr(SB); BYTE $0xF4
	CALL _strayintr(SB); BYTE $0xF5
	CALL _strayintr(SB); BYTE $0xF6
	CALL _strayintr(SB); BYTE $0xF7
	CALL _strayintr(SB); BYTE $0xF8
	CALL _strayintr(SB); BYTE $0xF9
	CALL _strayintr(SB); BYTE $0xFA
	CALL _strayintr(SB); BYTE $0xFB
	CALL _strayintr(SB); BYTE $0xFC
	CALL _strayintr(SB); BYTE $0xFD
	CALL _strayintr(SB); BYTE $0xFE
	CALL _strayintr(SB); BYTE $0xFF
.
537c
	MOVL	$(KDSEL), AX
.
526c
TEXT _strayintrx(SB), $0
.
519c
TEXT _strayintr(SB), $0
.
514c
 * (_strayintrx) or not, in which case a dummy entry must be pushed before retrieving
.
512c
 * Each entry in the vector table calls either _strayintr or _strayintrx depending
.
449,454d
443a
TEXT _splx(SB), $0				/* for iunlock */
.
438a
TEXT spllo(SB), $0
	PUSHFL
	POPL	AX
	STI
	RET

.
69,75c
	MOVL	$CPU0PTE, AX
.
## diffname pc/l.s 1998/0130
## diff -e /n/emeliedump/1997/1101/sys/src/brazil/pc/l.s /n/emeliedump/1998/0130/sys/src/brazil/pc/l.s
38,39c
 * a page directory, a page table for mapping the first 4MB of physical memory, and
 * virtual and physical pages for mapping the Mach structure.
.
## diffname pc/l.s 1998/0401
## diff -e /n/emeliedump/1998/0130/sys/src/brazil/pc/l.s /n/emeliedump/1998/0401/sys/src/brazil/pc/l.s
295,296c
	MOVL	lo+4(FP), AX
	MOVL	hi+8(FP), DX
.
287,290c
	MOVL	vlong+4(FP), CX			/* &vlong */
	MOVL	AX, (CX)			/* lo */
	MOVL	DX, 4(CX)			/* hi */
.
## diffname pc/l.s 1998/0430
## diff -e /n/emeliedump/1998/0401/sys/src/brazil/pc/l.s /n/emeliedump/1998/0430/sys/src/brazil/pc/l.s
130c
 * Need to do one final thing to ensure a clean machine environment,
.
## diffname pc/l.s 1998/0603
## diff -e /n/emeliedump/1998/0430/sys/src/brazil/pc/l.s /n/emeliedump/1998/0603/sys/src/brazil/pc/l.s
507c
 * on whether an error code has been automatically pushed onto the stack
.
## diffname pc/l.s 1998/0605
## diff -e /n/emeliedump/1998/0603/sys/src/brazil/pc/l.s /n/emeliedump/1998/0605/sys/src/brazil/pc/l.s
144a
	STI
.
## diffname pc/l.s 1998/0606
## diff -e /n/emeliedump/1998/0605/sys/src/brazil/pc/l.s /n/emeliedump/1998/0606/sys/src/brazil/pc/l.s
444c
TEXT splxpc(SB), $0				/* for iunlock */
.
## diffname pc/l.s 1998/0916
## diff -e /n/emeliedump/1998/0606/sys/src/brazil/pc/l.s /n/emeliedump/1998/0916/sys/src/brazil/pc/l.s
400,401c
	FSAVE	0(AX)				/* no WAIT */
.
## diffname pc/l.s 1999/0528
## diff -e /n/emeliedump/1998/0916/sys/src/brazil/pc/l.s /n/emeliedump/1999/0528/sys/src/brazil/pc/l.s
520a

	/* time stamp for interrupt */
	PUSHL	AX
	PUSHL	DX
	PUSHL	CX
	MOVL	$0x10, CX
	RDMSR
	MOVL	AX, intrts(SB)
	MOVL	DX, intrts+4(SB)
	POPL	CX
	POPL	DX
	POPL	AX

.
514a
	PUSHL	DX
	PUSHL	CX
	MOVL	$0x10, CX
	RDMSR
	MOVL	AX, intrts(SB)
	MOVL	DX, intrts+4(SB)
	POPL	CX
	POPL	DX

.
513a

	/* time stamp for interrupt */
.
## diffname pc/l.s 1999/0609
## diff -e /n/emeliedump/1999/0528/sys/src/brazil/pc/l.s /n/emeliedump/1999/0609/sys/src/brazil/pc/l.s
532,544d
517,525d
514,515d
## diffname pc/l.s 1999/1008
## diff -e /n/emeliedump/1999/0609/sys/src/brazil/pc/l.s /n/emeliedump/1999/1008/sys/src/brazil/pc/l.s
381c
	ANDL	$~0xC, AX			/* EM=0, TS=0 */	;\
.
376c
	ANDL	$~0x4, AX			/* EM=0 */		;\
	ORL	$0x28, AX			/* NE=1, TS=1 */	;\
.
## diffname pc/l.s 1999/1020
## diff -e /n/emeliedump/1999/1008/sys/src/brazil/pc/l.s /n/emeliedump/1999/1020/sys/src/brazil/pc/l.s
532,535c

	PUSHL	SP			/* Ureg* argument to trap */
.
527,529c
	PUSHL	DS			/* save DS */
	PUSHL	$(KDSEL)
	POPL	DS			/* fix up DS */
	MOVBLZX	(AX), AX		/* trap type -> AX */
	XCHGL	AX, 4(SP)		/* exchange trap type with saved AX */

	PUSHL	ES			/* save ES */
	PUSHL	$(KDSEL)
	POPL	ES			/* fix up ES */

	PUSHL	FS			/* save the rest of the Ureg struct */
.
522,525c
	XCHGL	AX, (SP)		/* swap AX with vectortable CALL PC */
.
515,518c
	PUSHL	AX			/* save AX */
	MOVL	4(SP), AX		/* return PC from vectortable(SB) */
.
## diffname pc/l.s 2000/0929
## diff -e /n/emeliedump/1999/1020/sys/src/brazil/pc/l.s /n/emeliedump/2000/0929/sys/src/9/pc/l.s
393,394c
	/* setfcr(FPPDBL|FPRNR|FPINVAL|FPZDIV|FPOVFL) */
	/* note that low 6 bits are masks, not enables, on this chip */
	PUSHW	$0x0232
	FLDCW	0(SP)
.
## diffname pc/l.s 2000/1221
## diff -e /n/emeliedump/2000/0929/sys/src/9/pc/l.s /n/emeliedump/2000/1221/sys/src/9/pc/l.s
504a
	RET

/*
 * Attempt at power saving. -rsc
 */
TEXT halt(SB), $0
	HLT
.
14a
#define HLT		BYTE $0xF4
.
## diffname pc/l.s 2001/0527
## diff -e /n/emeliedump/2000/1221/sys/src/9/pc/l.s /n/emeliedump/2001/0527/sys/src/9/pc/l.s
511a
	CLI
	CMPL	nrdy(SB), $0
	JEQ	_nothingready
	STI
	RET

_nothingready:
	STI
.
## diffname pc/l.s 2001/1130
## diff -e /n/emeliedump/2001/0527/sys/src/9/pc/l.s /n/emeliedump/2001/1130/sys/src/9/pc/l.s
290c
	MOVL	AX, 0(CX)			/* lo */
.
285a
TEXT rdtsc(SB), $0				/* time stamp counter; cycles since power up */
	RDTSC
	MOVL	vlong+0(FP), CX			/* &vlong */
	MOVL	AX, 0(CX)			/* lo */
	MOVL	DX, 4(CX)			/* hi */
	RET

.
13a
#define RDTSC 		BYTE $0x0F; BYTE $0x31
.
## diffname pc/l.s 2002/0109
## diff -e /n/emeliedump/2001/1130/sys/src/9/pc/l.s /n/emeliedump/2002/0109/sys/src/9/pc/l.s
127a

.
110,112c
	MOVL	$0, (PDO(0))(CX)		/* undo double-map of KZERO at 0 */
.
100c
	JMP*	AX				/* jump to the virtual nirvana */
.
98c
	MOVL	$_startpg(SB), AX		/* this is a virtual address */
.
88,90c
	MOVL	(PDO(KZERO))(CX), DX		/* double-map KZERO at 0 */
	MOVL	DX, (PDO(0))(CX)
.
81,85d
79c
 * It is necessary on some processors to immediately follow mode switching with a JMP instruction
.
71c
	MOVL	$PADDR(CPU0PTE), AX
.
63c
	MOVL	$PADDR(CPU0PTE), AX		/* first page of page table */
.
57c
	MOVL	$PADDR(CPU0PDB), AX
.
49c
	MOVL	$PADDR(CPU0PDB), DI		/* clear 4 pages for the tables etc. */
.
44,47c
TEXT _start0x00100020(SB),$0
	CLI					/* make sure interrupts are off */
.
42a
 * An identity mmu map is also needed for the switch to virtual mode.  This
 * identity mapping is removed once the MMU is going and the JMP has been made
 * to virtual memory.
.
38,41c
 * In protected mode with paging turned off and segment registers setup to linear map all memory.
 * Entered via a jump to 0x00100020, the physical address of the virtual kernel entry point of 0x80100020
 * Make the basic page tables for processor 0. Four pages are needed for the basic set:
 * a page directory, a page table for mapping the first 4MB of physical memory to KZERO,
 * and virtual and physical pages for mapping the Mach structure.
.
36d
32,34c
TEXT _start0x80100020(SB),$0
	MOVL	$_start0x00100020(SB), AX
	ANDL	$~KZERO, AX
.
27,30c
 * For backwards compatiblity with 9load - should go away when 9load is changed
 * 9load currently sets up the mmu, however the first 16MB of memory is identity
 * mapped, so behave as if the mmu was not setup
.
## diffname pc/l.s 2002/0413
## diff -e /n/emeliedump/2002/0109/sys/src/9/pc/l.s /n/emeliedump/2002/0413/sys/src/9/pc/l.s
497a
	MOVL	$1, AX				/* return 1 */
	RET

TEXT swaplabel(SB), $0
	MOVL	label+0(FP), AX
	MOVL	pc+4(FP), BX
	MOVL	0(AX), SP			/* restore sp */
	MOVL	4(AX), CX			/* put return pc on the stack */
	MOVL	CX, 0(SP)
	MOVL	BX, 4(AX)			/* put caller pc where return pc was */
.
305a
TEXT sfence(SB), $0
	SFENCE
	RET

.
16a
#define SFENCE		BYTE $0x0F; BYTE $0xAE; BYTE $0xF8
.
## diffname pc/l.s 2002/0703
## diff -e /n/emeliedump/2002/0413/sys/src/9/pc/l.s /n/emeliedump/2002/0703/sys/src/9/pc/l.s
506,515d
## diffname pc/l.s 2003/0401
## diff -e /n/emeliedump/2002/0703/sys/src/9/pc/l.s /n/emeliedump/2003/0401/sys/src/9/pc/l.s
829a

TEXT realmode(SB), $0
	RET

.
10c
#define DELAY		BYTE $0xEB; BYTE $0x00	/* JMP .+2 */
.
## diffname pc/l.s 2003/0402
## diff -e /n/emeliedump/2003/0401/sys/src/9/pc/l.s /n/emeliedump/2003/0402/sys/src/9/pc/l.s
831,833d

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].