FAT32 search on GPT partition (Announce)
This code may be added to EDR-DOS sources.
GPT_Signature equ 00h
GPT_Revision equ 08h
GPT_HeaderSize equ 0Ch
GPT_HeaderCRC equ 10h
GPT_Reserved equ 14h
GPT_CurrentLBA equ 18h
GPT_BackupLBA equ 20h
GPT_FirstUsableLBA equ 28h
GPT_LastUsableLBA equ 30h
GPT_DiskGUID equ 38h
GPT_PartitionsLBA equ 48h
GPT_PartitionNumber equ 50h
GPT_PartitionEntrySize equ 54h
GPTEntry_PartitionGUID equ 00h
GPTEntry_uniqGUID equ 10h
GPTEntry_StartLBA equ 20h
GPTEntry_EndLBA equ 28h
GPTEntry_Attributes equ 30h
GPTEntry_Name equ 38h
db 'GPT',0 ;gpt code flag
gpt_init:
nop ;to modify by hex editor to "ret" - 0xC3
mov dl,80h ;start from 1st hard disk
;push di
ya_gpt:
xor di,di ;\ start from zero partition
xor bx,bx ;/
again_gpt:
cmp nunits,MAXPART ; do we already have the maximum?
jae lt_gpt ; skip if space for more units
lea si,diskaddrpack ; pointer to disk address packet
mov word ptr [si+ 8],1 ;\ make dword = 1
and word ptr [si+10],0 ;/
push bx
call login_read_dx_lba ; read sector
pop bx
jc no_gpt
mov si,CG:local_buffer ; check if sector start
lodsw ; with "EFI PART" string
cmp ax,"FE"
jnz no_gpt
lodsw
cmp ax," I"
jnz no_gpt
lodsw
cmp ax,"AP"
jnz no_gpt
lodsw
cmp ax,"TR"
jnz no_gpt
; start from, qword = 2?
cmp word ptr [si+GPT_PartitionsLBA-4*2+0],2
jnz no_gpt
xor ax,ax
cmp [si+GPT_PartitionsLBA-4*2+2],ax
jnz no_gpt
cmp [si+GPT_PartitionsLBA-4*2+4],ax
jnz no_gpt
cmp [si+GPT_PartitionsLBA-4*2+6],ax
jnz no_gpt
; partition size, qword = 80h?
cmp word ptr [si+GPT_PartitionEntrySize-4*2+0],0080h
jnz no_gpt
cmp word ptr [si+GPT_PartitionEntrySize-4*2+2],ax
jnz no_gpt
; save number of partitons
push word ptr [si+GPT_PartitionNumber-4*2+2]
push word ptr [si+GPT_PartitionNumber-4*2+0]
; save LBA sector number (dword)
push word ptr [si+GPT_PartitionsLBA-4*2+2]
push word ptr [si+GPT_PartitionsLBA-4*2+0]
lea si,diskaddrpack
; copy LBA sector number to packet and load this sector
pop word ptr [si+ 8]
pop word ptr [si+10]
; make partition number division by 4
mov ax,di
mov cx,bx
shr cx,1
rcr ax,1
shr cx,1
rcr ax,1
; add division result to the sector number
add word ptr [si+ 8],ax
adc word ptr [si+10],cx
push bx
call login_read_dx_lba ; read sector
pop bx
jc er_gpt
; make pointer to 128 bytes structure in sector (512/128=4)
mov ax,di
and ax,3
mov cl,80h
mul cl
add ax,CG:local_buffer
mov si,ax
; load LBA disk starting sector number
mov ax,[si+GPTEntry_StartLBA+0*8+0]
mov cx,[si+GPTEntry_StartLBA+0*8+2]
; save partition start
mov word ptr [partstart+0],ax
mov word ptr [partstart+2],cx
; zero ?
or ax,cx
jz nx_gpt
; if partition finish (dword +4)<>0 then skip
mov ax,[si+GPTEntry_EndLBA+4+2]
or ax,[si+GPTEntry_EndLBA+4+0]
jnz nx_gpt
; save partition finish
mov ax,[si+GPTEntry_EndLBA+2]
mov word ptr [partend+2],ax
mov ax,[si+GPTEntry_EndLBA+0]
mov word ptr [partend+0],ax
mov ax,word ptr [partstart+0]
mov cx,word ptr [partstart+2]
; compute partition size
mov si,word ptr [partend+0]
sub si,ax
mov word ptr [part_size+0],si
mov si,word ptr [partend+2]
sbb si,cx
mov word ptr [part_size+2],si
add word ptr [part_size+0],1
adc word ptr [part_size+2],0
lea si,diskaddrpack ; pointer to disk address packet
mov word ptr [si+ 8],ax
mov word ptr [si+10],cx
push bx
call login_read_dx_lba ; read 1st partition sector
pop bx
jc nx_gpt
mov si,CG:local_buffer
mov ax,[si+52h] ;\
cmp ax,"AF" ; \
jnz nx_gpt ; > = "FAT"? to skip NTFS
mov al,[si+54h] ; /
cmp al,"T" ;/
jnz nx_gpt
mov [parttype],FAT32X_ID
pushx <di,bx,dx>
call login_p0 ; add and register new disk
popx <dx,bx,di>
nx_gpt:
add di,1 ;\ next partition
adc bx,0 ;/
pop ax ;\ left partitions
pop cx ;/
cmp cx,bx
jnz again_gpt
cmp ax,di
jnz again_gpt
jmp no_gpt
er_gpt:
add sp,2*2
no_gpt:
inc dl ; next hard disk to check
jnz ya_gpt ; if ZF=0 jump
lt_gpt:
;pop di
ret
Complete thread:
- Enhanced DR-DOS single-file load (2023 December revision) - ecm, 07.01.2024, 20:43 (Announce)
- Enhanced DR-DOS single-file load (2023 December revision) - roytam, 08.01.2024, 07:26
- Enhanced DR-DOS single-file load (2023 December revision) - Guti, 10.01.2024, 17:09
- Enhanced DR-DOS single-file load (2023 December revision) - Ro2003, 13.01.2024, 09:28
- Enhanced DR-DOS development - ecm, 14.01.2024, 22:58
- lDebug boot loading other kernels - ecm, 20.01.2024, 13:24
- Enhanced DR-DOS development - ecm, 14.01.2024, 22:58
- Enhanced DR-DOS single-file load (2023 December revision) - CandyMan, 07.06.2024, 16:19
- Enhanced DR-DOS single-file load (2023 December revision) - ecm, 07.06.2024, 17:12
- Enhanced DR-DOS single-file load (2023 December revision) - CandyMan, 07.06.2024, 18:56
- Enhanced DR-DOS - CD bug - ecm, 07.06.2024, 19:42
- Enhanced DR-DOS - CD bug - ecm, 07.06.2024, 19:47
- Enhanced DR-DOS - CD bug - CandyMan, 07.06.2024, 22:10
- Enhanced DR-DOS - CD bug - ecm, 07.06.2024, 23:17
- Enhanced DR-DOS - CD bug - ecm, 07.06.2024, 23:24
- FAT32 search on GPT partition - CandyMan, 03.07.2024, 18:54
- FAT32 search on GPT partition - tom, 03.07.2024, 19:48
- FAT32 search on GPT partition - tom, 03.07.2024, 19:51
- FAT32 search on GPT partition - CandyMan, 03.07.2024, 20:55
- Kernel ported to JWasm - boeckmann, 08.07.2024, 22:31
- Kernel ported to JWasm - boeckmann, 09.07.2024, 18:22
- Kernel ported to JWasm - Japheth, 10.07.2024, 17:32
- EDR-DOS kernel ported to JWasm - ident86 validated DRBIO port - ecm, 14.07.2024, 21:03
- EDR-DOS kernel ported to JWasm - ident86 validated DRBIO port - boeckmann, 14.07.2024, 22:37
- EDR-DOS kernel ported to JWasm - ident86 validated DRBIO port - CandyMan, 22.07.2024, 16:57
- EDR-DOS kernel ported to JWasm - ident86 validated DRBIO port - boeckmann, 23.07.2024, 20:50
- EDR-DOS kernel ported to JWasm - ident86 validated DRBIO port - ecm, 23.07.2024, 21:34
- EDR-DOS kernel ported to JWasm - ident86 validated DRBIO port - Rugxulo, 24.07.2024, 00:25
- EDR-DOS kernel ported to JWasm - ident86 validated DRBIO port - CandyMan, 22.07.2024, 16:57
- EDR-DOS kernel ported to JWasm - ident86 validated DRBIO port - boeckmann, 14.07.2024, 22:37
- Kernel ported to JWasm - boeckmann, 09.07.2024, 18:22
- Kernel ported to JWasm - boeckmann, 08.07.2024, 22:31
- FAT32 search on GPT partition - CandyMan, 03.07.2024, 20:55
- FAT32 search on GPT partition - tom, 03.07.2024, 19:51
- FAT32 search on GPT partition - tom, 03.07.2024, 19:48
- FAT32 search on GPT partition - CandyMan, 03.07.2024, 18:54
- Enhanced DR-DOS - CD bug - CandyMan, 08.06.2024, 09:59
- Enhanced DR-DOS - CD bug - boeckmann, 20.06.2024, 18:00
- Enhanced DR-DOS - CD bug - boeckmann, 30.06.2024, 16:57
- Enhanced DR-DOS - CD bug - boeckmann, 20.06.2024, 18:00
- ? - CandyMan, 19.06.2024, 19:45
- ? - glennmcc, 22.06.2024, 02:13
- ? - nico7550, 23.06.2024, 08:18
- unnecessary "stc" - CandyMan, 03.07.2024, 17:55
- ? - glennmcc, 22.06.2024, 02:13
- Enhanced DR-DOS - CD bug - ecm, 07.06.2024, 23:24
- Enhanced DR-DOS - CD bug - ecm, 07.06.2024, 23:17
- Enhanced DR-DOS - CD bug - CandyMan, 07.06.2024, 22:10
- Enhanced DR-DOS - CD bug - ecm, 07.06.2024, 19:47
- Enhanced DR-DOS - CD bug - ecm, 07.06.2024, 19:42
- Enhanced DR-DOS single-file load (2023 December revision) - CandyMan, 07.06.2024, 18:56
- Enhanced DR-DOS single-file load (2023 December revision) - ecm, 07.06.2024, 17:12