• Aucun résultat trouvé

iAPX 286 SYSTEM INITIALIZATION

Dans le document MANUAL PROGRAMMER'S iAPX 286 (Page 184-194)

Stltle('Swltch the 80286 from Reel Addre55 Mode to Protected Mode') neme

pub 1 1 c

5wltch 80286_mode5 1 d t_d e 5 c , 9 d t_d e 5 c

Swltch the 80286 from reel eddre55 mode lnto protected mode.

The lnltlel EPROM GOT, lOT, TSS, end LOT (If eny) con5tructed by BL0286 wlll be copled from EPROM lnto RAM. The RAM eree5 ere defined by dete 5egment5 elloceted e5 flxed entrle5 ln the GOT. The CPU reg15ter5 for the GOT, lOT, TSS, end LOT wlll be 5et to polnt et the RAM-be5ed 5egment5. The be5e fleld5 ln the RAM-be5ed GOT wlll e150 be updeted to polnt et the RAM-be5ed 5egmentL

Th15 code 15 u5ed by eddlng lt to the i15t of object module5 glven to BL0286. BL0286 mU5t then be told to pIece the 5egment

lnlt_code et eddre55 FFFE10H. Executlon of the mode 5wltch code begln5 efter RESET. Th15 heppen5 beceu5e the mode 5wltch code wlll 5tert et phy51cel eddre55 FFFFFOH, whlch 15 the power up eddre55. Th15 code then 5et5 up RAM cople5 of the EPROM-be5ed 5egment5 before jumplng to the lnltlel te5k pIeced et e flxed GOT entry. After the jump, the CPU execute5 ln the 5tete of the flr5t te5k deflned by BL0286.

Th15 code wlll not U5e eny of the EP~3M-be5ed teble5 dlrectly.

Such U5e would re5ult in the 80286 wrltlng lnto EPROM to 5et the A blt. Any U5e of e GOT or TSS wlll elweY5 be ln the RAM copy.

The llmlt end 51ze of the EPROM-be5ed GOT end lOT mU5t be 5tored et the publlc 5ymbo15 ldt_de5c end gdt_de5c. The locetlon commend5 of BL0286 provlde thi5 function

Interrupt5 ere d15ebled durlng th15 mode 5wltchlng code. Full error checklng 15 mede of the EPROM-be5ed GOT, lOT, TSS, end LOT to e55ure they ere velld before copylng them to RAM. If eny of the RAM-be5ed elle5 5egment5 ere 5meller then the EPROM 5egment5 they are to hold, helt or 5hutdown wlll occur. In generel, eny exception or NMI wlll ceU5e 5hutdown to occur until the fir5t te5k 15 invoked.

If the RAM 5egment 15 lerger then the EPROM 5egment, the RAM 5egment wlll be expended wlth. zer05. If the lnltlel TSS 5peclfle5 an LOT, the LOT wlll e150 be copled 1nto ldt_elle5 wlth zero flll lf needed.

The EPROM-be5ed or RAM-be5ed GOT, lOT, TSS, end LOT !egment! may be located enywhere ln phy!lcel memory.

star t

startl:

rep

IAPX 286 SYSTEM INITIALIZATION

Form an adj~stment 1actor from the real CS base of FFOOOOH to the segment base address assumed by ASM286. Any data reference made

lnto CS must add an lndexlng term IBP) to compensate for the dlfference between the offset generated by ASM286 and the offset requlred from the base of FFOOOOH.

pro c

c II 1 1 startl pop bp

sub bp,off5et s tar t 1 11 d t 1 n 1 t 1 a Lg d t I b P )

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

Get true offset of startl

Subtract ASM286 offset of sta~tl

leaving adjustment factor ln BP Setup null lOT to force shutdown

on any protectlon error or ,1nterrupt Copy the EPROM-based temporary GOT lnto RAM.

1 e a mov movs

sl,lnltlal_gdtlbpl j Setup pointer to temporary GOT template ln EPROM

c x, (e n d_g d t - 1 n 1 t 1 a l_g d t ) / 2 Set 1 eng t h

es:word ptr Idl1,cs:lsl)j Put lrito reserved RAM area Look for 80287 processor extenslon. Assume all ones wll1 be read lf an 80287 is not present.

f n 1 n 1 t mov 15 t sw or j n z 15 e t pm moy

b x, EM ax ,a 1 , a 1

set_mode

bx,MP

Inltlallze 80287 lfpresent A55ume no 80287

Look at status of 80287 Ho errors should be present Jump lf no 80287

Put 80287 lnto protected mode

SWitch to protected mode and setup a stack, GOT, and LOT.

set_mode:

smsw or or lmsw jmp

ax a x, P E ax,bx ax

• + 2

Get current MSW , Set PE blt

Set HPX status flags Enter protected mode!

Clear queue of instructlons decoded whlle ln Real Address Mode

CPL ls now 0, CS stll1 points at FFFE10 in physical memory

IAPX 286 SYSTEM INITIALIZATION

Define the template for a temporary GOT u5ed to locate the Initial GOT and 5tack. Thl5 data will be copied to location O.

Thl5 5pace 15 al,o u5ed for a temporary ,tack and finally 5erve5 a5 the TSS written Into when entering the Initial TSS.

or 9 P I ace remaining cod e bel 0 w power_up

Inltlal_gdt de 5 c ( ) F I I Ie r and null lOT descriptor

gdt_de5c de 5 c ( ) Descriptor for EPROM GOT

Idt_desc de 5 c ( ) De5crlptor for EPROM lOT

temp_de5c de 5 c ( ) Temporary de5crlptor

Define a descriptor that will point the GOT at location O.

Thl, de5crlptor will al50 be loaded Into SS to define the Initial protected mode 5tack 5egment.

temp_5tack de 5 C (e n d_g d t - I nit I a I_g d t - 1 ,0,0,0 S_A C C E S S , 0)

Define the TSS descriptor u,ed to allow the ta5k 5wltch to the flr5t ta5k to overwrite thl5 region of memory. The TSS will overlay the Initial GOT and ,tack at location O.

de 5 C ( e n d_g d t - I nit I a I_g d t - 1 , 0 , 0 , T S S_A C C E S S , 0 )

Define the Initial !ltllck splice lind filler for the end of the TSS.

end_gdt 5tart_polnter

dw I abe I III bel dw

8 dup (0) word dword

O,5tllrt_tll5k i Pointer to Initial ta5k Define template for the tll5k definition 1151.

ta'k_entry TS S_H I TSS_alla, LOT_alia, ta5k_entry

re5et_5tartup:

c I I c I d x 0 r mov

5 t r u c dw dw dw end 5

mov e5,dl

55 , d I

Define layout of ta5k de5crlptlon Selector for TSS

Dlltll 5egment 1111115 for TSS

Dlltll 5egment 1111115 for LOT If IIny

(5tart_ta5k,5tart_TSS_aII1l5,5tllrt_LDT_1I111l5.

i Terminllte 115t

Ho Interrupt5 1I110wed!

U5e lIutolncrement mode

Point ES:DI lit phy51cIII IIddre55 OOOOOOH

Set stllck lit end of reserved IIrell mov

mov s P , en d_g d t - I nit 11I1_g d t

desc 11 m 1 t base_low base_hlgh access res desc

IAPX 286 SYSTEM INITIALIZATION

Deflne layout of a descrlptor.

s t r u c dw dw db db dw ends

Offset of last byte ln segment Low 16 blts of 24-bit address High 8 bits of 24-blt address Access rlghts byte

Reserved word

Deflne the fixed GDT selector values for the descriptors that define the EPROM-based tables. BLD286 must be instructed to place the appropriate descrlptors into the GDT.

gdt_alias equ 1 • s 1 z e des c GDT(1) 1 s data segment in RAM for GDT 1 d t_a 1 i as equ 2·s1ze des c GDT(2) 1 s data segment in RAM for I D T s tar t_ T S S_a 11 as equ 3·s1ze des c GDT(3) i s data segment 1 n RAM for TSS start_task equ 4·s1ze desc GDT(4) i s TSS for starting t ask start_LDT_allas equ S·slze des c GDT<S) i s data segment 1 n RAM for LDT

Deflne machine status word bit positlons.

PE equ Protection enable

MP equ Monltor processor extension

EM equ Emulate processor extension

Define partlcular values of descriptor access r 1 9 h t s by t e .

DT_ACCESS equ 82H Access by t e value for an LDT

DS_ACCESS equ S2H Access by t e val u e for data segment which i s grow up, at 1 eve 1 o , writeable TSS_ACCESS equ 81 H Access byte val u e for an i die TSS

DPL equ SOH Privilege 1 eve 1 fie 1 d of access rights

ACCESSED equ Define accessed bit

T I equ Posltion of T I bit

TSS_SIZE equ 44 S i z e of a TSS

L D T _0 FF SET equ 42 Position of LDT 1 n TSS TIRPL_MASK equ s i z e desc-1 T I and RPL f 1 e 1 d mask

Pass control from the power-up address to the mode swltch code.

The segment contalning this code must be at physlcal address FFFE10H to place the JMP instruction at physical address FFFFFOH. The base address is chosen according to the size of thls segment.

segment er equ

or 9 l m p

OFE10H Low 16 bits of starting address OFFFOH-cs_offset; Start at address FFFFFOH

reset_startup Do not change CS!

IAPX 286 SYSTEM INITIALIZATION

19 d t

ax, temp_5tack-ln1t1al_gdt i Setup SS w1th val1d protected mode

55,ax 5elector to the RAM GDT and 5tack

aX,ax Set the current LDT to null

ax Any reference5 to 1t w111 c8u5e

an except10n cau51ng 5hutdown ax,uve_t55-1n1t1al_gdt Set 1n1t1al TSS 1nto the low RAM

IAPX 286 SYSTEM INITIALIZATION

Tnt the descrlptor tllble slze ln AX to verlfy thllt lt 15 lin even number of descrlptors ln length.

tes t_dt_llml t proc

push IIX Silve length

lind II 1 , 7 L 0 0 k II t low or de r b 1 t s

cmp II 1 , 7 Must be 1111 one s

pop IIX Restore length

J n e b II d_d t_ll m 1 t

ret All OK

blld_dt_llml t:

hIt D 1 e !

t e s t_d t_ll m 1 t endp

Copy the EPROM DT lit selector BX in the temporllry GDT to the IIlllls dlltll segment lit selector SI. Any lmproper des,crlptors or 11mlts wl11 clluse shutdown!

mov mov mov mov 1 s 1 mov c II 1 1 mov mov mov push lodsw c II 11 s t 0 s w movsw movsw movsw pop mov

pro c II X , S s e s , II X

es:[bxl.llccess,DS_ACCESS;

es:[bx].res,O II x, b x

c x , II X

test_dt_llmlt

d 1 , 9 d t_d esc - 1 n 1 t 111 l_g d t d s , d 1

d 1 , t em p_d esc - 1 n 1 t 111 l_g d t ; d 1

endp

Polnt ES:DI lit temporllry descrlptor Mllrk descrlptor liS II dlltll segment Clellr reserved word

Get 11mlt of EPROM DT Silve for Illter

Verify lt ls II proper 11mlt Address EPROM GDTln DS

Get selector for temporllry descrlptor Silve offset for Illter use liS selector Get IIlllls segment slze

Verlfy lt ls lin even multlple of descrlptors ln length

Put length lnto temporllry

Copy remlllnlng entrles lnto temporllry

ES now polnts lit the GDT IIlllls IIrell DS now polnts lit EPROM DT liS dlltll Copy segment to 1I1111S wlth zero fl11 CX ls copy count, AX-CX ls fl11 count FilII lnto copy_wlth_fl11

IAPX286 SYSTEM INITIALIZATION

See lf a valld LDT 1~ ~peclfled for "the ~tartup ta~k

If ~o then copy the EPROM ver~lon into the RAM alla~.

mov d~,c~:[bx).t~~_alla~ Addre~5 TSS to get LDT mov 51,d5:word ptr LDT_OffSET

and ~l,not TIRPL_MAS~ Ignore TI and RPL

Re~tore GDT addre5s1ng

Move the RAM LDT llmlt

IAPX 286 SYSTEM INITIALIZATION

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

F111 the end w1th AX-CX zer05. U5e word operat10n5 for 5peed but allow odd byte operat10n5.

cop y_w 1 t h_ f 1 1 1 x 0 r x 0 r 5 U b add r c r rep mOV5W

xchg J n c mov5b or Jz 5 t 0 5 b dec even_copy:

5 h r rep 5t05w

J n c 5 t 0 5 b ex1t_copy:

ret cop y_w 1 t h_ f 1 1 1 1n1t_code

pro c 51 I 5 1 d 1 I d 1 a x I c x c x I 1 c x I 1 a x I c x even_copy

c x I C x ex1t_copy

c x c x I 1 ex1t_copy

endp end 5 end

Start at beg1nn1ng of 5egment5 Form f1ll count

Convert l1m1t to count Allow full 64K move Copy DT 1nto a11a5 area Get f1ll count and zero AX Jump 1f even byte count on copy Copy odd byte

Ex1t 1f no f1l1

Even out the 5egment off5et AdJu5t rema1n1ng f1ll count Form word count on f1ll Clear unu5ed word5 at end Ex1t 1f no odd byte rema1n5 Clear la5t odd byte

Append~ J3

Dans le document MANUAL PROGRAMMER'S iAPX 286 (Page 184-194)