Guest User

FDC driver pmode

a guest
Jul 24th, 2014
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. org 7c00h
  2.  
  3. use16
  4.  
  5. cli
  6. lgdt[gdt]
  7. lidt[idt]
  8. mov eax,cr0
  9. or al,1
  10. mov cr0,eax
  11. jmp code32-table1:kernel
  12.  
  13. use32
  14.  
  15. kernel:
  16. mov ax,data32-table1
  17. mov gs,ax
  18. mov fs,ax
  19. mov ds,ax
  20. mov es,ax
  21. mov ss,ax
  22. mov esp,9fffch
  23. mov al,0
  24. out 21h,al
  25. mov eax,isr_fdc
  26. mov [table2+49*8],ax
  27. mov word[table2+49*8+2],code32-table1
  28. mov word[table2+49*8+4],8e00h
  29. shr eax,16
  30. mov [table2+49*8+6],ax
  31. int 49
  32. jmp $
  33.  
  34. isr_fdc:
  35. mov dx,3f2h
  36. mov al,1ch
  37. out dx,al
  38. call readmsr
  39. mov dx,3f7h
  40. mov al,0
  41. out dx,al
  42. call readmsr
  43. mov dx,3f5h
  44. mov al,0fh
  45. out dx,al
  46. mov al,0
  47. out dx,al
  48. mov al,0
  49. out dx,al
  50. call readmsr
  51. mov al,6
  52. out 0ah,al
  53. mov al,0ffh
  54. out 0ch,al
  55. mov ax,start
  56. out 4,al
  57. mov al,ah
  58. out 4,al
  59. mov al,0ffh
  60. out 0ch,al
  61. out 5,al
  62. mov al,1
  63. out 5,al
  64. mov al,code32-table1
  65. out 81h,al
  66. mov al,2
  67. out 0ah,al
  68. call readmsr
  69. mov dx,3f5h
  70. mov al,66h
  71. out dx,al
  72. mov al,0
  73. out dx,al
  74. mov al,0
  75. out dx,al
  76. mov al,0
  77. out dx,al
  78. mov al,2
  79. out dx,al
  80. mov al,2
  81. out dx,al
  82. mov al,18
  83. out dx,al
  84. mov al,27
  85. out dx,al
  86. mov al,0ffh
  87. out dx,al
  88. call readmsr
  89. mov dx,3f5h
  90. mov al,8
  91. out dx,al
  92. read_int_status:
  93. mov dx,3f5h
  94. in al,dx
  95. test al,20h
  96. jz read_int_status
  97. iret
  98.  
  99. readmsr:
  100. mov dx,3f4h
  101. in al,dx
  102. and al,0c0h
  103. cmp al,80h
  104. jne readmsr
  105. ret
  106.  
  107. gdt:
  108. dw end_gdt-table1-1
  109. dd table1
  110.  
  111. table1:
  112. dq 0
  113.  
  114. code32:
  115. dw 0ffffh
  116. dw 0
  117. db 0
  118. db 9ah
  119. db 0cfh
  120. db 0
  121.  
  122. data32:
  123. dw 0ffffh
  124. dw 0
  125. db 0
  126. db 92h
  127. db 0cfh
  128. db 0
  129.  
  130. end_gdt:
  131.  
  132. idt:
  133. dw end_idt-(50*8)-1
  134. dd table2
  135.  
  136. table2:
  137. dd 50*2
  138.  
  139. end_idt:
  140.  
  141. times 510-($-$$) db 0
  142. dw 0aa55h
  143.  
  144. start:
  145. mov di,0b800h
  146. mov es,di
  147. mov di,0
  148. mov byte[es:di],42h
  149.  
  150. times 512-($-start) db 0
Advertisement
Add Comment
Please, Sign In to add comment