Subversion Repositories Kolibri OS

Rev

Rev 7122 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;;                                                              ;;
  3. ;; Copyright (C) KolibriOS team 2008-2015. All rights reserved. ;;
  4. ;; Distributed under terms of the GNU General Public License    ;;
  5. ;;                                                              ;;
  6. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7.  
  8. $Revision: 7132 $
  9.  
  10.  
  11. ; Detect all BIOS hard drives.
  12. ; diamond, 2008
  13. ; Do not include USB mass storages. CleverMouse, 2013
  14. ; Read the number of sectors, bytes per sector. dunkaist, 2017
  15.  
  16.         xor     cx, cx
  17.         mov     es, cx
  18.         mov     di, BOOT_LO.bios_hd
  19.         mov     byte [es:di-1], cl
  20.         cmp     [preboot_biosdisk], 1
  21.         jnz     bdde
  22.         mov     dl, 80h
  23. bdds:
  24.         mov     ah, 15h
  25.         push    cx dx di
  26.         int     13h
  27.         pop     di dx cx
  28.         jc      bddc
  29.         test    ah, ah
  30.         jz      bddc
  31.         inc     cx
  32. ; We are going to call int 13h/func 48h, Extended get drive parameters.
  33. ; The latest version of the EDD specification is 3.0.
  34. ; There are two slightly incompatible variants for version 3.0;
  35. ; original one from Phoenix in 1998, see e.g.
  36. ; http://www.t10.org/t13/technical/d98120r0.pdf, and T13 draft,
  37. ; http://www.t13.org/documents/UploadedDocuments/docs2004/d1572r3-EDD3.pdf
  38. ; T13 draft addresses more possible buses, so it gives additional 8 bytes
  39. ; for device path.
  40. ; Most BIOSes follow Phoenix, but T13 version is also known to be used
  41. ; (e.g. systems based on AMD Geode).
  42. ; Fortunately, there is an in/out length field, so
  43. ; it is easy to tell what variant was selected by the BIOS:
  44. ; Phoenix-3.0 has 42h bytes, T13-3.0 has 4Ah bytes.
  45. ; Note that 2.0 has 1Eh bytes, 1.1 has 1Ah bytes; both variants of 3.0 have
  46. ; the same structure for first 1Eh bytes, compatible with previous versions.
  47. ; Note also that difference between Phoenix-3.0 and T13-3.0 starts near the
  48. ; end of the structure, so the current code doesn't even need to distinguish.
  49. ; It needs, however, give at least 4Ah bytes as input and expect that BIOS
  50. ; could return 42h bytes as output while still giving all the information.
  51.         mov     ah, 48h
  52.         push    ds
  53.         push    es
  54.         pop     ds
  55.         mov     si, 0xA000
  56.         mov     word [si], 4Ah
  57.         mov     ah, 48h
  58.         int     13h
  59.         pop     ds
  60.         jc      bddc2
  61.         cmp     word [es:si], 1Eh
  62.         jb      .noide
  63.         cmp     word [es:si+1Ah], 0xFFFF
  64.         jz      .noide
  65.         inc     byte [es:BOOT_LO.bios_hd_cnt]
  66.         mov     al, dl
  67.         stosb
  68.         push    ds
  69.         push    si
  70.         lds     si, [es:si+1Ah]
  71.         mov     al, [si+6]
  72.         and     al, 0xF
  73.         stosb
  74.         mov     al, byte [si+4]
  75.         shr     al, 4
  76.         and     ax, 1
  77.         cmp     word [si], 1F0h
  78.         jz      @f
  79.         inc     ax
  80.         inc     ax
  81.         cmp     word [si], 170h
  82.         jz      @f
  83.         or      ax, -1
  84. ;        mov     ax, -1
  85. @@:
  86.         stosw
  87.         pop     si
  88.         pop     ds
  89.         jmp     bddc3
  90. .noide:
  91.         cmp     word [es:si], 42h
  92.         jb      .nousb
  93.         cmp     word [es:si+28h], 'US'
  94.         jnz     .nousb
  95.         cmp     byte [es:si+2Ah], 'B'
  96.         jz      bddc2
  97. .nousb:
  98.         inc     byte [es:BOOT_LO.bios_hd_cnt]
  99.         mov     al, dl
  100.         stosb
  101.         xor     ax, ax
  102.         stosb
  103.         dec     ax
  104.         stosw
  105. ;        mov     al, 0
  106. ;        stosb
  107. ;        mov     ax, -1
  108. ;        stosw
  109. bddc3:
  110.         movzx   eax, word[es:si+24]
  111.         stosd
  112.         mov     eax, [es:si+16]
  113.         stosd
  114.         mov     eax, [es:si+20]
  115.         stosd
  116. bddc2:
  117.         cmp     cl, [es:0x475]
  118.         jae     bdde
  119. bddc:
  120.         inc     dl
  121.         jnz     bdds
  122. bdde:
  123.