Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Rmdisk Driver

Janib SoomroJanib Soomro Member Posts: 49
Hell 2 All!
This time i want to make a ramdisk device driver, does anyone has idea?
and i've seen few ramdisk drivers [too big to understand], they make a new drive in my pc [like c: d: e: 'H:'] 160k,
so where from that space comes!

Comments

  • ASHLEY4ASHLEY4 Member Posts: 254
    : Hell 2 All!
    : This time i want to make a ramdisk device driver, does anyone has idea?
    : and i've seen few ramdisk drivers [too big to understand], they make a new drive in my pc [like c: d: e: 'H:'] 160k,
    : so where from that space comes!
    :
    It emulats a harddrive in RAM.
    \\|////
    @)
    ASHLEY4.
  • Janib SoomroJanib Soomro Member Posts: 49
    Ok! It emulates Harddisk Space in RAM,
    So do you know how a small ramdisk is made, i've few big examples,
    i need a small example, or teach me via msgs!
  • Janib SoomroJanib Soomro Member Posts: 49
    [b][red]This message was edited by Janib Soomro at 2004-8-24 7:46:5[/red][/b][hr]
    [code]
    ;--------------------------------------------------------
    ;
    ; rdsk1.asm
    ; ramdisk device driver
    ; compiled with a86 assembler
    ;
    ;--------------------------------------------------------

    org 00
    nextDevice dd -1
    devAttr dw 6000h
    dw offset strategy
    dw offset command
    deviceName db 01, 07 dup(0)
    db 10 dup(0) ; extras
    bpb_ptr dw offset bpb, 00
    rm_seg dw 00
    volume db 'Jb-Soomro ',8
    db 05 dup(0) ; extras
    even
    boot_sector db 03 dup(0)
    db 'JbSoomro'
    bpb dw 512 ; bytes per sector
    db 1 ; sector per cluster
    dw 1 ; reserved sector
    db 1 ; fat
    dw 64 ; max file entries in root dir
    dw 320 ; total sectors
    db 0FEh ; media descriptor
    db 2 ; sectors occupied by fat
    db 10 dup(0) ; extras

    even
    devRequest dd 0 ; request header es:bx
    start_sec dw 00
    total_sec dw 00
    datacount dw 00

    even
    dosaddr label dword
    dosoff dw 00
    dosseg dw 00

    even
    dskaddr label dword
    dskoff dw 00
    dskseg dw 00
    jump_table db offset init
    db offset media_chk
    db offset build_bpb
    db offset bad_function
    db offset read
    db offset bad_function
    db offset bad_function
    db offset write
    db offset write
    db offset bad_function

    ;--------------------------------------------------------
    proc1:
    nop
    even
    les bx, cs:devRequest
    mov ax, es:[bx+18] ; sector count
    mov ah, al ; or shl ax, 8
    xor al, al ; or sec# * 512
    mov datacount, ax

    mov ax, es:[bx+20] ; starting sector
    mov cl, 05 ; convert to paragraphs
    shl ax, cl ; sec# * 32
    add ax, cs:rm_seg ; add rm_seg
    mov dskseg, ax ;
    mov dskoff, 00

    mov ax, es:[bx+14] ; dos dta offset
    mov cs:dosoff, ax
    mov ax, es:[bx+16] ; dos dta segment
    mov cs:dosseg, ax
    ret


    ;--------------------------------------------------------
    strategy:
    mov word ptr cs:DevRequest, bx
    mov word ptr cs:DevRequest+2, es
    retf


    ;--------------------------------------------------------
    command:
    even
    push ax
    push bx
    push cx
    push dx
    push es
    push ds
    push di
    push si
    push cs
    pop ds
    les bx, cs:DevRequest
    mov al, es:[bx+2]
    cmp al, 10
    jle function_ok
    bad_function: mov word ptr es:[bx+3], 8102h ; error
    jmp done_func

    function_ok: rol al, 01
    mov si, offset jump_table
    xor ah, ah
    add si, ax
    call word ptr [si]
    mov word ptr es:[bx+3], 100h
    done_func:
    pop si
    pop di
    pop ds
    pop es
    pop dx
    pop cx
    pop bx
    pop ax
    retf

    ;--------------------------------------------------------
    media_chk:
    even
    mov byte ptr es:[bx+14],01
    ret
    ;--------------------------------------------------------
    build_bpb:
    even
    mov word ptr es:[bx+12h],offset bpb ; address of bpb cs:ip
    mov es:[bx+14h],cs
    ret

    read:
    even
    call proc1
    mov cx, datacount
    les di, cs:dosaddr
    lds si, cs:dskaddr
    rep movsb
    ret

    ;--------------------------------------------------------
    write:
    even
    call proc1
    mov cx, datacount
    les di, cs:dskaddr
    lds si, cs:dosaddr
    rep movsb
    ret

    ;--------------------------------------------------------
    init:
    even
    push cs
    pop ds

    mov ax, cs
    mov dx, offset end_of
    mov cl, 4
    shr dx, cl
    add ax, dx

    mov cs:rm_seg, ax
    add ax, 2800h
    mov dx, ax
    mov byte ptr es:[bx+0Dh], 1
    mov word ptr es:[bx+12h], offset bpb_ptr
    mov es:[bx+14h], cs
    mov word ptr es:[bx+0Eh], 00
    mov es:[bx+10h], dx
    mov cs:bpb_ptr+02, cs

    ;
    ; adding bootsector in 00 sector
    ; and cleaning other bytes
    ;

    mov ax, cs:rm_seg
    mov es, ax
    xor di, di
    mov si, offset boot_sector
    mov cx, 30
    rep movsb
    mov di, 30
    mov cx, 512
    sub cx, 30
    mov al, 00
    rep stosb

    ;
    ; adding 0feh 0ffh 0ffh to fat
    ; sector 01, sector 02 also fat
    ; and cleaning other bytes
    ;
    mov di, 512
    mov al, 0feh
    stosb
    mov al, 0ffh
    stosb
    stosb
    mov cx, 512
    sub cx, 03
    mov di, 512+03
    mov al, 00
    rep stosb


    ;
    ; adding volume name in sector 03
    ; and cleaning other bytes
    ;
    mov ax, es ; 3rd sector = directory
    mov dx, 512*3 ; 3 * 512 bytes
    shr dx, 04 ;
    add ax, dx
    mov es, ax ; es:di = es:00
    xor di, di
    mov si, offset volume
    mov cx, 07
    rep movsw
    mov cx, 512
    sub cx, 14
    mov di, 14
    mov al, 00
    rep stosb

    mov word ptr es:[bx+3], 100h
    mov al, es:[bx+16h]
    add al, 'a'
    mov byte ptr cs:drive, al
    mov dx, offset msg
    mov ah, 9
    int 21h
    even
    ret

    even
    msg db 'Installing Soomros Ramdisk Driver 160kbs In '
    drive db 00
    db 0Dh,0ah
    db 'Do not run in windows, only for real dos!'
    db 0Dh,0ah
    db 'for more details use [email protected]'
    db 0Dh,0ah
    db '$'

    ;--------------------------------------------------------
    end_of equ $
    ;--------------------------------------------------------

    [/code]
Sign In or Register to comment.