Subversion Repositories Kolibri OS

Rev

Rev 2455 | Rev 5363 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

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