Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to the forum
Board view  Mix view

AHCICD.SYS alternatives? (Users)

posted by Japheth Homepage, Germany (South), 13.01.2021, 13:43

> I think, a diff file produced with -U2 (default) would be
> okay. Maybe -U1 is already enough.

I'm afraid this is no useful approach - because the first thing I did with the original was to "reformat" the source: indent reduced to 4, code labels and opcodes separated to 2 lines.

But the changes are indeed minimal - one can see from this that Mr. Loew was a master.

Here's the changes, in case anyone desperately needs such a driver:

    OUT     DX,EAX
    POP     EBX
    POP     EDX
    RET

    include hbap.inc

GETHBA:
    @setint0d
    PUSH    EDX                     ;AX = ADDR
    MOV     EDX,CS:[HBA]
if 0
    AND     EDX,EDX
    JS      GHP
    OUT     DX,AX
    ADD     DX,4
    IN      EAX,DX
    JMP     GHE
GHP:
    CALL    PUTPCI
    ADD     EDX,4
    CALL    GETPCI
GHE:
else
    movzx eax,ax
    mov eax,[edx+eax]
endif
    POP     EDX
    @restint0d
    RET

PUTHBA:
    @setint0d
    PUSH    EDX                     ;AX = ADDR  ECX = VALUE
    MOV     EDX,CS:[HBA]
if 0
    AND     EDX,EDX
    JS      PHP
    OUT     DX,AX
    ADD     DX,4
    MOV     EAX,ECX
    OUT     DX,EAX
    JMP     PHE
PHP:
    CALL    PUTPCI
    ADD     EDX,4
    MOV     EAX,ECX
    CALL    PUTPCI
PHE:
else
    movzx eax,ax
    mov [edx+eax], ecx
endif
    POP     EDX
    @restint0d
    RET


and, in the init section:


GOTHBA:
    DEC     BP
    JNZ     NXTHBA
if 0 ;don't search for SATA compatibility header
    MOV     DL,34H
    CALL    GETPCI
GETCAP:
    AND     AL,AL
    JZ      NG
    MOV     DL,AL
    CALL    GETPCI
    CMP     AL,12H
    JZ      GOTCAP
    MOV     AL,AH
    JMP     GETCAP
GOTCAP:
    ADD     DL,4
    CALL    GETPCI
    CMP     AL,0FH
    JNZ     IOPORT
    ADD     DL,4
    MOV     DS:[HBA],EDX
    JMP     ENDHBA
IOPORT:
    MOV     CX,AX
    SHR     CL,2
    AND     CL,0FCH
    AND     AL,0FH
    SHL     AL,2
    MOV     DL,AL
    CALL    GETPCI
    TEST    AL,1
    JZ      NG
    AND     AL,0FEH
    ADD     AX,CX
    MOV     DS:[HBA],EAX
ENDHBA:
else
    smsw ax
    test ax,1
    jz @F
    mov dx,offset msg6
    jmp NG1
msg6 db "ahcicdp driver can't work in V86 mode!",13,10,13,10,'$'
@@:
    mov dl,24h  ;get ABAR5
    call getpci
    mov ds:[HBA],eax
    mov eax,cs
    shl eax,4
    add eax,offset gdt-8
    mov dword ptr ds:[gdtr+2],eax       ;set linear address of GDT
endif
    MOV     AX,4
    CALL    GETHBA



my changes are easy to identify, they are in lower case.

Finally, there's a new file, named hbap.inc, where I put the "unreal" stuff into:



;--- define macros @setint0d and @restint0d
;--- these macros activate unreal mode

    align 8
gdt label qword
        dw -1,0,9200h,0CFh      ; 32-bit flat data descriptor
;       dw -1,0,9200h,0         ; 16-bit data descriptor

SEL_FLAT equ 8
;SEL_DATA16 equ 16

gdtr dw 3*8-1,0,0

;--- exception 0D: no need to check if it's a real exception,
;--- since interrupts were disabled.

int0d:
        push ds
        push eax
        lgdt fword ptr cs:[gdtr]
        mov eax,cr0
        inc ax
        mov cr0,eax
        jmp @F
@@:
        dec ax
        push SEL_FLAT
        pop ds
        mov cr0,eax
        pop eax
        pop ds
        iret

@setint0d macro
        pushf
        cli
        push ds
        push 0
        pop ds
        push ebx
        push cs
        push offset int0d
        mov  ebx,ds:[13*4]
        pop  dword ptr ds:[13*4]
endm
@restint0d macro
        mov ds:[13*4],ebx
        pop ebx
        pop ds
        popf
endm


to assemble, enter:


jwasm -bin -Foahcicd.sys ahcicd.asm


Hint: better do NOT move the XBDA if you load this driver. In my machine, several HBA data regions are located in this area.

Also, be aware that this driver runs in real-mode only. There's a check, but it's in the init phase only, so if you load the driver before loading jemm386, you won't get a warning.

---
MS-DOS forever!

 

Complete thread:

Back to the forum
Board view  Mix view
22049 Postings in 2034 Threads, 396 registered users, 119 users online (0 registered, 119 guests)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum