⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pt.inc

📁 控制APIC的汇编源程序
💻 INC
字号:
null        equ  0
SCR_MAT     equ   7		; Mode/attribute
SCR_COL     equ  50h		; Columns per row
SCR_ROW     equ  19h		; Rows per screen
;
; BIOS Data Area locations.
;
BDA_MEM      equ  413h		; Free memory
BDA_KEYFLAGS equ  417h		; Keyboard shift-state flags
BDA_SCR      equ  449h		; Video mode
BDA_POS      equ  450h		; Cursor position
BDA_BOOT     equ  472h		; Boot howto flag

;
; Paging control.
;
PAG_SIZ  EQU 1000h		; Page size
PAG_CNT  EQU 1000h		; Pages to map
MEM_DIR  EQU 110000h              ; Page directory
MEM_TBL  EQU 111000h		; Page tables

long_call macro selector,destination
          db  9ah
          dd  offset destination
	  dw  selector
	  endm
far_call  macro selector,destination
          db 9ah
	  dw offset destination
	  dw selector
	  endm

far_jump  macro selector,destination
          db  0eah
	  dw  offset destination
	  dw  selector
	  endm
long_jump  macro selector,destination
          db  0eah
          dd  destination
	  dw  selector
	  endm
seg_desc struct
limit_0_15  dw  0
base_0_15   dw  0
base_16_23  db  0
p_dpl_s_type db 0
g_d_a_limit  db 0
base_24_31   db 0
seg_desc ends

gate struct
entry_0_15 dw  0
selector   dw  0
param_count db 0
p_dpl_s_type db 0
entry_16_31  dw 0
gate ends

task_gate struct
padding  dw     0
tss_sel  dw     0
pad      db     0
p_dpl_s_type db 0
padd     dw     0
task_gate ends

pseudo_desc struct
limit   dw   0
base_address dd 0
pseudo_desc ends

task_state struct
link       DW  0
link_h     DW  0
ESP0       DD  0
SS0        DW  0
SS0_h      DW  0
ESP1       DD  0
SS1        DW  0
SS1_h      DW  0
ESP2       DD  0
SS2        DW  0
SS2_h      DW  0
CR3_reg    DD  0
EIP_reg    DD  0
EFLAGS_reg DD  0
EAX_reg    DD  0
ECX_reg    DD  0
EDX_reg    DD  0
EBX_reg    DD  0
ESP_reg    DD  0
EBP_reg    DD  0
ESI_reg    DD  0
EDI_reg    DD  0
ES_reg     DW  0
ES_h       DW  0
CS_reg     DW  0
CS_h       DW  0
SS_reg     DW  0
SS_h       DW  0
DS_reg     DW  0
DS_h       DW  0
FS_reg     DW  0
FS_h       DW  0
GS_reg     DW  0
GS_h       DW  0
LDT_reg    DW  0
LDT_h      DW  0
TRAP_reg   DW  0
IO_map_base DW 0
TASK_STATE ENDS
;
; Local && I/O APIC definitions.
;

;
 ; Pentium P54C+ Build-in APIC
 ; (Advanced programmable Interrupt Controller)
 ; 
 ; Base Address of Build-in APIC in memory location
 ; is 0xfee00000.
 ; 
 ; Map of APIC REgisters:
 ; 
 ; Offset (hex)    Description                     Read/Write state
 ; 000             Reserved
 ; 010             Reserved
 ; 020 ID          Local APIC ID                   R/W
 ; 030 VER         Local APIC Version              R
 ; 040             Reserved
 ; 050             Reserved
 ; 060             Reserved
 ; 070             Reserved
 ; 080             Task Priority Register          R/W
 ; 090             Arbitration Priority Register   R
 ; 0A0             Processor Priority Register     R
 ; 0B0             EOI Register                    W
 ; 0C0 RRR         Remote read                     R
 ; 0D0             Logical Destination             R/W
 ; 0E0             Destination Format Register     0..27 R;  28..31 R/W
 ; 0F0 SVR         Spurious Interrupt Vector Reg.  0..3  R;  4..9   R/W
 ; 100             ISR  000-031                    R
 ; 110             ISR  032-063                    R
 ; 120             ISR  064-095                    R
 ; 130             ISR  095-128                    R
 ; 140             ISR  128-159                    R
 ; 150             ISR  160-191                    R
 ; 160             ISR  192-223                    R
 ; 170             ISR  224-255                    R
 ; 180             TMR  000-031                    R
 ; 190             TMR  032-063                    R
 ; 1A0             TMR  064-095                    R
 ; 1B0             TMR  095-128                    R
 ; 1C0             TMR  128-159                    R
 ; 1D0             TMR  160-191                    R
 ; 1E0             TMR  192-223                    R
 ; 1F0             TMR  224-255                    R
 ; 200             IRR  000-031                    R
 ; 210             IRR  032-063                    R
 ; 220             IRR  064-095                    R
 ; 230             IRR  095-128                    R
 ; 240             IRR  128-159                    R
 ; 250             IRR  160-191                    R
 ; 260             IRR  192-223                    R
 ; 270             IRR  224-255                    R
 ; 280             Error Status Register           R
 ; 290             Reserved
 ; 2A0             Reserved
 ; 2B0             Reserved
 ; 2C0             Reserved
 ; 2D0             Reserved
 ; 2E0             Reserved
 ; 2F0             Reserved
 ; 300 ICR_LOW     Interrupt Command Reg. (0-31)   R/W
 ; 310 ICR_HI      Interrupt Command Reg. (32-63)  R/W
 ; 320             Local Vector Table (Timer)      R/W
 ; 330             Reserved
 ; 340             Reserved
 ; 350 LVT1        Local Vector Table (LINT0)      R/W
 ; 360 LVT2        Local Vector Table (LINT1)      R/W
 ; 370 LVT3        Local Vector Table (ERROR)      R/W
 ; 380             Initial Count Reg. for Timer    R/W
 ; 390             Current Count of Timer          R
 ; 3A0             Reserved
 ; 3B0             Reserved
 ; 3C0             Reserved
 ; 3D0             Reserved
 ; 3E0             Timer Divide Configuration Reg. R/W
 ; 3F0             Reserved
 ;/
pci_read macro index,data
     mov	ax,8000H	;enable PCI config.
     shl	eax,16
     mov	ax,cx
     and	al,NOT 03h	;32 bit access for PCI
     mov	dx,0cf8 	;index is 0cf8h
     out	dx,eax
     add	dl,4		;start from 0cfch
     mov	al,cl
     and	al,03h
     add	dl,al	  	;byte index to read
     in	        eax,dx
     endm


;MP Floating Pointer Structure
mpfps struct
signature  dd  0
phy_addr   dd  0
leng       db  0
spec_rev   db  0
checksum   db  0
mpfb1      db  0
mpfb2      db  0
mpfb3      db  0
mpfb4      db  0
mpfb5      db  0
mpfps ends
;/* MP Configuration Table Header */
mpcth struct
signature    dd  0
base_table_length dw  0
spec_rev     db  0 
checksum     db  0
oem_id       dq  0
product_id   dd  0
pid_1        dd  0
pid_2	     dd  0
oem_table_pointer  dd   0
oem_table_size   dw  0
entry_count      dw  0
apic_address     dd  0
extended_table_length dw 0
extended_table_checksum  db 0
reserved         db     0
mpcth  ends

procentry struct
type0    db     0
apicid  db     0
apicversion  db 0
cpuflags     db 0
cpusignature dd 0
featureFlags dd 0
reserved1    dd 0
reserved2    dd 0
procentry ends

busentry struct
type0   db   0
busid   db   0
bustype df   0
busentry ends

ioapicentry struct
type0   db   0
apicid  db   0
apicversion db  0
apicflags   db  0
apicaddress dd  0
ioapicentry ends

intentry struct
type0   db   0
inttype db   0
intflags db  0
reserved db  0
srcbusid db  0
srcbusirq db  0
dstapicid db  0
dstapicint db 0
intentry ends

TASK_LINK STRUC
WAKE_UP_TIME   DD 0 ;Wakeup value
TASK_OFFSET    DD 0 ;Dummy offset placeholder
TASK_SEL       DW 0 ;Selector to this task
NEXT_TASK_LINK DD 0 ;Pointer to next task link
TASK_LINK ENDS

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -