Subversion Repositories Kolibri OS

Rev

Rev 110 | Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. Advanced Power Management
  2.  
  3. SYSTEM CALL
  4.  
  5. eax = 49
  6. dx = íîìåð ôóíêöèè APM BIOS (àíàëîãè÷åí ax â ðåàëüíîì ðåæèìå)
  7. îñòàëüíûå (bx, cx) ðåãèñòðû ïî ñïåöèôèêàöèè (ñì. apm.txt)
  8. ðåçóëüòàò : ïî ñïåöèôèêàöèè (âêëþ÷àÿ CF), ñòàðøàÿ ÷àñòü 32 áèòíûõ ðåãèñòðîâ íå îïðåäåëåíà
  9.  
  10.  
  11. MEMORY MAP
  12.  
  13. Boot:
  14.         0x9040 - dword - entry point of APM BIOS
  15.         0x9044 -  word - version (BCD)
  16.         0x9046 -  word - flags
  17.  
  18.  
  19. ÈÇÌÅÍÅÍÈß
  20.  
  21. bootcode.inc
  22. syscall.inc
  23. kernel.asm
  24. bootcode.inc
  25. shutdown.inc
  26.  
  27. ##############[boot\bootcode.inc]##################
  28.  
  29. Òðè íîâûõ äåñêðèïòîðà
  30.  
  31. .............
  32. .............
  33.  
  34. ; GDT TABLE
  35.  
  36. gdts:
  37.  
  38.         dw     gdte-$-1
  39.         dd     gdts
  40.         dw     0
  41.  
  42. int_code_l:
  43. os_code_l:
  44.  
  45.         dw     0xffff
  46.         dw     0x0000
  47.         db     0x00
  48.         dw     11011111b *256 +10011010b
  49.         db     0x00
  50.  
  51. int_data_l:
  52. os_data_l:
  53.  
  54.         dw     0xffff
  55.         dw     0x0000
  56.         db     0x00
  57.         dw     11011111b *256 +10010010b
  58.         db     0x00
  59. ; --------------- APM ---------------------
  60. apm_code_32:
  61.         dw     0x0f        ; limit 64kb
  62.         db     0, 0, 0
  63.         dw     11010000b *256 +10011010b
  64.         db     0x00
  65. apm_code_16:
  66.         dw     0x0f
  67.         db     0, 0, 0
  68.         dw     10010000b *256 +10011010b
  69.         db     0x00
  70. apm_data_16:
  71.         dw     0x0f
  72.         db     0, 0, 0
  73.         dw     10010000b *256 +10010010b
  74.         db     0x00
  75. ; -----------------------------------------
  76. app_code_l:
  77.       dw ((0x80000000-std_application_base_address) shr 12) and 0xffff
  78.       dw 0
  79.       db 0
  80.       dw 11010000b*256+11111010b+256*((0x80000000-std_application_base_address) shr 28)
  81.       db std_application_base_address shr 24
  82.  
  83. app_data_l:
  84.       dw (0x80000000-std_application_base_address) shr 12 and 0xffff
  85.       dw 0
  86.       db 0
  87.       dw 11010000b*256+11110010b+256*((0x80000000-std_application_base_address) shr 28)
  88.       db std_application_base_address shr 24
  89.  
  90. graph_data_l:
  91.  
  92.         dw     0x3ff
  93.         dw     0x0000
  94.         db     0x00
  95.         dw     11010000b *256 +11110010b
  96.         db     0x00
  97.  
  98. tss0_l:
  99.  
  100. .............
  101. .............
  102.  
  103. ##############[core\syscall.inc]###################
  104.  
  105. .............
  106. .............
  107.  
  108.  
  109.       dd display_number          ; 47-WriteNum
  110.       dd display_settings        ; 48-SetRedrawType and SetButtonType
  111.       dd sys_apm                 ; 49-Advanced Power Management (APM)
  112.       dd random_shaped_window    ; 50-Window shape & scale
  113.       dd syscall_threads         ; 51-Threads
  114.  
  115.  
  116. .............
  117. .............
  118.  
  119. ##############[kernel.asm]#########################
  120.  
  121.  
  122. ×àñòü 1 (ïîñëå ìåòêè "; SAVE REAL MODE VARIABLES"):
  123.  
  124. .............
  125. .............
  126.  
  127. ; SAVE REAL MODE VARIABLES
  128.  
  129. ; --------------- APM ---------------------
  130.         mov     eax, [0x2f0000 + 0x9040]        ; entry point
  131.         mov     dword[apm_entry], eax
  132.         mov     word [apm_entry + 4], apm_code_32 - gdts
  133.  
  134.         mov     eax, [0x2f0000 + 0x9044]        ; version & flags
  135.         mov     [apm_vf], eax
  136. ; -----------------------------------------
  137.  
  138. .............
  139. .............
  140.  
  141. ×àñòü 2 (ñèñòåìíûé âûçîâ, ðàñïîëîæåíèå íå êðèòè÷íî,
  142. ÿ ðàñïîëîæèë ïåðåä ìåòêîé "undefined_syscall:")
  143.  
  144. .............
  145. .............
  146.  
  147. ; --------------- APM ---------------------
  148. apm_entry       dp      0
  149. apm_vf          dd      0
  150. align 4
  151. sys_apm:
  152.         cmp     word [apm_vf], 0        ; Check APM BIOS enable
  153.         jne     @f
  154.         or      [esp + 56], byte 1      ; error
  155.         mov     [esp + 36], dword 8     ; 32-bit protected-mode interface not supported
  156.         ret
  157.        
  158. @@:     xchg    eax, ecx
  159.         xchg    ebx, ecx
  160.        
  161.         cmp     al, 3
  162.         ja      @f
  163.         and     [esp + 56], byte 0xfe   ; emulate func 0..3 as func 0
  164.         mov     eax, [apm_vf]
  165.         mov     [esp + 36], eax
  166.         shr     eax, 16
  167.         mov     [esp + 32], eax
  168.         ret
  169.        
  170. @@:     call    pword [apm_entry]       ; call APM BIOS
  171.         mov     [esp + 8 ], edi
  172.         mov     [esp + 12], esi
  173.         mov     [esp + 24], ebx
  174.         mov     [esp + 28], edx
  175.         mov     [esp + 32], ecx
  176.         mov     [esp + 36], eax
  177.         setc    al
  178.         and     [esp + 56], byte 0xfe
  179.         or      [esp + 56], al
  180.         ret
  181. ; -----------------------------------------
  182.  
  183. align 4
  184.  
  185. undefined_syscall:                      ; Undefined system call
  186.  
  187. .............
  188. .............
  189.  
  190. ##############[boot\bootcode.inc]##################
  191.  
  192. Ïåðåä ìåòêîé "; DISPLAY VESA INFORMATION"
  193.  
  194. .............
  195. .............
  196.  
  197. ; --------------- APM ---------------------
  198.         push    0
  199.         pop     es
  200.         mov     word [es : 0x9044], 0           ; ver = 0.0 (APM not found)
  201.         mov     ax, 0x5300
  202.         xor     bx, bx
  203.         int     0x15
  204.         jc      apm_end                         ; APM not found
  205.         test    cx, 2
  206.         jz      apm_end                         ; APM 32-bit protected-mode interface not supported
  207.         mov     [es : 0x9044], ax               ; Save APM Version
  208.         mov     [es : 0x9046], cx               ; Save APM flags
  209.        
  210.         ; Write APM ver ----
  211.         jmp     @f
  212. msg_apm:db      ' APM x.x ', 0
  213. @@:     and     ax, 0xf0f
  214.         add     ax, '00'
  215.         mov     si, msg_apm - 0x10000
  216.         mov     [si + 5], ah
  217.         mov     [si + 7], al
  218.         _setcursor 0, 3
  219.         call    printplain
  220.         _setcursor d80x25_top_num,0
  221.         ; ------------------
  222.        
  223.         mov     ax, 0x5304                      ; Disconnect interface
  224.         xor     bx, bx
  225.         int     0x15
  226.         mov     ax, 0x5303                      ; Connect 32 bit mode interface
  227.         xor     bx, bx
  228.         int     0x15
  229.         ; init selectors
  230.         movzx   eax, ax ; real-mode segment base address of protected-mode 32-bit code segment
  231.         shl     eax, 4
  232.         mov     [apm_code_32 - 0x10000 + 2], ax
  233.         shr     eax, 16
  234.         mov     [apm_code_32 - 0x10000 + 4], al
  235.         movzx   ecx, cx ; real-mode segment base address of protected-mode 16-bit code segment
  236.         shl     ecx, 4
  237.         mov     [apm_code_16 - 0x10000 + 2], cx
  238.         shr     ecx, 16
  239.         mov     [apm_code_16 - 0x10000 + 4], cl
  240.         movzx   edx, dx ; real-mode segment base address of protected-mode 16-bit data segment
  241.         shl     edx, 4
  242.         mov     [apm_data_16 - 0x10000 + 2], dx
  243.         shr     edx, 16
  244.         mov     [apm_data_16 - 0x10000 + 4], dl
  245.         mov     [es : 0x9040], ebx              ; offset of APM entry point
  246. apm_end:
  247. ; -----------------------------------------
  248.  
  249.  
  250. ; DISPLAY VESA INFORMATION
  251.  
  252. .............
  253. .............
  254.  
  255. ##############[boot\shutdown.inc]##################
  256.  
  257. Ðåøåíèå ïðîáëåìû APM poweroff
  258.  
  259. .............
  260. .............
  261.  
  262. APM_PowerOff:
  263.         mov     ax, 5304h
  264.         xor     bx, bx
  265.         int     15h
  266. ;!!!!!!!!!!!!!!!!!!!!!!!!
  267. mov ax,0x5300
  268. xor bx,bx
  269. int 0x15
  270. push ax
  271.  
  272. .............
  273. .............
  274.