• Aucun résultat trouvé

iAPX 286 SYSTEM INITIALIZATION

Dans le document 1986 HANDBOOKS LITERATURE (Page 189-199)

$tltle('Swltch the 80286 from Real Address Mode to Protected Mode'}

name 'witch 80286_mode, pub I I c

Switch the 80286 from real address mode Into protected mode.

The Inltlol EPROM GOT, lOT, TSS, and LOT (If any) con,tructed by BL0286 will be copied from EPROM Into RAM. The RAM area, are defined by data .egment. allocated a. fixed entrle, In the GOT. The CPU regl,ter, for the GOT, lOT, TSS, and LOT will be 50t to point at the RAM-ba,ed .egment •. The ba.e field. In the RAM-ba,ed GOT will al50 be updated to point at the RAM-ba,ed .egment"

Thl, code I, u,ed by adding It to the 115t of object module, given to BL0286. BL0286 mu,t then be told to place the 50gment

Inlt_code at addre" FFFE10H. Execution of the mode 'witch code begin' after RESET. Thl, happen, because the mode 'witch code will , t a r t at phy.lcal addres, FFFFFOH, which I, the power up addre". Thl, code then , e t , up RAM cople, of the EPROM-ba,ed ,egment, before Jumping to the Initial task placed at a fixed GOT entry. After the Jump, the CPU executes In the ,tate of the first ta,k defined by BL0286.

Thl. code will not u,e any of the EPROM-ba,ed table, directly.

Such u,e would re,ult In the 80286 writing Into EPROM to set the A bit. Any U50 of a GOT or TSS will alway' be In the RAM copy.

The limit and ,Ize of the EPROM-ba,ed GOT and lOT mu,t be ,tored at the public 'ymbol' Idt_de,c and gdt_de,c. The location command, of BL0286 provide thl, function

Interrupt' are dl,abled during thl, mode 'Witching code. Full error checking I, made of the EPROM-ba,ed GOT, lOT, TSS, and LOT to a"ure they are valid before copying them to RAM. If any of the RAM-ba,ed alia • • egment, are ,maIler than the EPROM ,egment, they are to hold, halt or ,hutdown will occur. In general, any exception or NMI will cau.e ,hutdown to occur until the f l r , t ta,k I, Invoked.

If the RAM .egment I, larger than the EPROM ,egment, the RAM ,egment will be expanded with zero,. If the Initial TSS specifie, an LOT, the LOT will al,o be copied Into Idt~alla, with zero f i l l if needed.

The EPROM-ba,ed or RAM-ba,ed GOT, lOT, TSS, and LOT ,egment, may be located anywhere in physical memory.

O.f I ne layoul

de.c • I r u c

I I m I I dw

base_low dw

ba.e_hlgh db

acc!!! db

res dw

desc end.

of

0 0 0 0 O'

iAPX 286 SYSTEM INITIALIZATION

de.crlplor .

Offs.1 of last byle In segment Low 16 blls of 24-bll addrep High 8 bll. of 24-bll addre.s Acce.s rlghls byle

Reserved word

Oeflne the fixed GOT .elector value. for Ihe d •• crlptor. that define Ih. EPROM-ba.ed lable •. BL0286 must be Inslrucled 10 place Ihe approprlale d~scrlplors Inlo Ihe GOT.

gdt_alla. equ 1I.lze desc GOT! 1 ) I • dala .egmenl I n RAM for GOT I d I_a II a • equ 2 • • I z e de.c GOT(2) I • dala .egmenl I n RAM for lOT

• I art _ T 5 S_. I I a • equ 3 • • I z e d •• c GOT(3) I • dala .egmenl In RAM for TSS start_Ia.k equ 4' • I z e desc GOT(4) I • TSS for slarllng I ask slarl_LOT_alla. equ S • • I z e de.c GOTCS) I • data .egmenl I n RAM for LOT

O.fln. machine • I a I u • word b I I posilions.

P E .qu Prolectlon enable

MP .qu Monllor proce.sor extension

EM .qu Emulale processor exlen.lon

Oeflne parllcular valu •• of d •• crlplor I!!ICCI!55 r'Ighls by I •.

OT_ACCESS equ 82H A c c e •• byl. val u. for an LOT OS_ACCESS equ 92H A c c e •• by I. valu. for dala •• gm.nl

w hi c h I • grow up. a I I . v. I o • wrlte.bl.

TSS_ACCESS .qu 81 H A c c ••• by I. val u. for an I d I • TSS OPL • qu 60H Prlvll.g. I. v. I fl. I d of I!I C C e !I !I rig hI •

ACCESSEO .qu O.fln. acc •••• d b I I

T I .qu Po.llion of T I b I I

TSS_SIZE .qu 44 S I z. of a TSS

LOT_OFFSET equ 42 Po.llion of LOT I n TSS

TIRPL_MASK .qu • I z. d •• c -1 T I and RPL fl. I d ma.k

Pa •• conlrol from Ihe pow.r-up addr ••• 10 Ih. mod • • wllch code.

Th. "gm.nl' containing Ihl. code mu~1 b. al phy.lcal addr ••• FFFE10H 10 place Ih. JMP In.lrucllon al phy.lcal addr ••• FFFFFOH. Th. ba ••

addre~. I. cho.en according 10 Ih • • Ize of thl • • egmenl .

•• gmenl .r e q u

or 9 J m p

OFE10H Low 16 bll. of .I.rllng addr •••

OFF F 0 H - c '_0 f f. e I; S I a r I a I add r e.. F F F F F 0 H re •• I_.tarlup 00 not chang. CS!

A-2

iAPX 286 SYSTEM INITIALIZATION

Define the template for a temporary GDT used to locate the initial GDT and stack. This data will be copied to location O.

This space is also used for a temporary stack and finally serve, a, Ihe T55 wrillen into when enlering Ihe inilial TSS.

or 9 P I ace remaining code below power_up

initiBI_gdt des c ( ) F i I I e r and nul I ! DT descriptor

gdl_desc des c ( ) Descriptor for [PROM GDT

idl_desc des C ( ) Descriptor for [ PRO M ! 0 T

temp_de,c des c ( ) Temporary descriptor

Define a descriptor Ihat will point the GDT at local ion O.

This descriptor will also be loaded into SS to define the initial protected mode stack segment.

temp_stack des C (e n d_g d t - i nit i a I_g d t -1 , 0 , 0 , D S_A C C [S S , 0) Define the TSS descriptor

first task to overwrite this the initial GDT and stack at

used to allow the region of memory.

location O.

task switch to the The T5S will overlay

des c ( e n d_g d t - i nit i a I_g d t -1 , 0 , 0 , T S S_A C C [ S 5 , 0 )

Define the initial stack space and filler for the end of the T55.

start_pointer dw I abe I I abe I dw

8 dup (0)

III a r d d w 0 r d

O,start_task Pointer to initial task Define template for the task definition l i s t .

task_entry T5S_sel T S S_a I i a s LDT_alias task_entry

reset_startup:

C I i c I d x 0 r

5 t rue dw d w dw end s task_entry

d w 0

d i , d i mov ds,di mov es,di

5 5 I d i

Define layout of task description Selector for TSS

Data segment alias for T55

Data segment alias for LDT if any

( s tar t_ to s k , s tar t_ T S S_a I i as, s tar t_L D T _a I i as) Terminate list

No interrupts allowed!

Use autoincrement mode

Point [S:D! at physical address OOOOOOH

Set stack at end of reserved area mov

mov s P , en d_g d t - 1 nil 1 a I_g d t

• tar t

. t a r t , :

rep

iAPX 286 SYSTEM INITIALIZATION

Form an adjustment factor from the real CS base of FFOOOOH to the .e9ment ba.e address assumed by ASM286. Any data reference made

Into CS must add an Indexln9 term IBPI to compensate for the difference between the offset generated by ASM286 and the offset reqUired from the ba.e of FFOOOOH.

pro c

c a I I s tar t , pop bp

sub bp,offset start' I I d t Inltlal_9 dtIb pI

The value of IP at run time will not be the same as the one used by ASM286!

Get true offset of start'

Subtract ASM286 offset of s t a r t ' leavin9 adjustment factor in BP Setup null IDT to force shutdown

on any protection error or Interrupt Copy the EPROM-based temporary GDT into RAM.

I e a sl,inltlal_9dtIbpl Setup pointer to temporary GDT template in EPROM

mov c x , ( en d_9 d t - i nit i a 1-9 d t ) I 2 Set len 9 t h

m 0 v 5 e"word ptr IdiI,cs:[sII; Put Into reserved RAM area Look for 80287 proces.or extension. Assume all ones will be read I f . n 8 0 2 8 7 I • no t pre se n t .

f n I nit mov f. t • w or J n z f.etpm mov

b x , EM

• x a I , a I set_mode

bx,MP

Initialize 80287 If present Assume no 80287

Look at status of 80287 No errors should be present Jump if no 80287

Put 80287 into protected mode

Switch to protected mode and setup a stack, GDT, and LDT.

set_mode:

5 m 9 W

or or 1m s w

J m p a x a x , P E a x I b x

ax I + 2

Get current MSW Set PE bit

Set NPX status fla9s Enter protected mode!

Clear queue of Instructions decoded while in Real Addre . . Mode

CPL is now 0, CS stilI points at FFFE'O in physical memory

A-4

iAPX 286 SYSTEM INITIALIZATION an exception causing shutdown mov a x ,sa v e_ t 5 5 - I nit I a I_g d t 5 e t I n I I I a I T 5 5 I n I 0 I h e low RAM

o tar t

bad_tss:

IAPX 286 SYSTEM INITIALIZATION

end p

Restore GDT addressing

Get TSS selector

IAPX 286 SYSTEM INITIALIZATION

.I,d"word plr LDT_OFFSET

• I , no I T I R P L_M ASK Reslore LDT seleclor Reslore GDT addressing

Move Ihe RAM LOT Ilmil

iAPX 286 SYSTEM INITIALIZATION

Test the descriptor table size in AX to verify that it is an even number of descriptor. in length.

test_dt_Iimit pro c

p u • h a x S a v e len 9 t h

and a I , 7 L 0 0 k a t low or d e r bit 5 cmp a I , 7 Mus t be • I I one 5

pop a x Restore len 9 t h

J n e bad_dt_Iimit

ret A I I OK

bad_dt_1 imi t:

hit Die!

test_dt_Iimit end p

Copy the EPROM DT at selector EX in the temporary GDT to the alias data .egment at selector sr. Any improper descriptors or limits will cause shutdown!

pro c

mov Point ES:DI at temporary descriptor

mov eS,Bx

mov es:lbxl.access,DS_ACCESS; Mark de.criptor as a data segment mov es:(bxJ.res,O Clear reserved word

151 ax,bx Get limit of EPROM DT

mov c a I I mov mov mov pus h I 0 d 5 W C a I I

5 t 0 5 W m 0 v 5 IN

movsw movsw pop mov

eX,ax

test_dt_Iimit

d i , 9 d t_d esc - i nit i a I_g d t d 5 I d i

d i , t em p_d esc - i nit i a I_g d t ; d i

e 5

ds,bx

end p

Save for later

Verify it is a proper limit Address EPROM GOT in DS

Get .elector for temporary descriptor Save offset for later use as selector Get alias segment size

Verify it is an even multiple of descriptors In length

Put length into temporary

Copy remaining entries into temporary

ES now point. at the GDT alias area DS now point. at EPROM DT as data Copy .egment to alia. with zero f i l l CX i. copy count, AX-CX i. f i l l count Fall into copy_with_fill

A-a

IAPX 286 SYSTEM INITIALIZATION

Copy the .egment at DS to the .egment at ES for length CX.

Fill the end with AX-CX zeros. U.e word operation. for speed but allow odd byte operation ••

copy_wi th_f III pro c xor s 1 , 9 1 xor d I , d I .ub B x I ex add ex, 1 r c r ex 1 1 rep mov!lw

xchg B x 1 ex

1 n c even_copy mov.b

or C x I ex jZ exit_copy

• to. b dec c x even_copy:

• h r C x I 1 rep • to. w

1 n c ex It_copy

• to. b eXit_copy:

ret

copy_wi th_f III endp

Inlt_code end.

end

Start at beginning of segment.

Form fill count

Convert limit to count Allow full 64K move Copy DT Into alias area Get fill count and zero AX Jump If even byte count on copy Copy odd byte

Exit If no fill

Even out the .egment offset Adju.t remaining fill count Form word count on fill Clear unused word. at end Exit If no odd byte remain.

Clear la.t odd byte

Appendix B

Dans le document 1986 HANDBOOKS LITERATURE (Page 189-199)