; rmmod.asm ; real mode module for HOS ; Author: Josh Holtrop ; Date: 09/20/04 ; the bootstrap process will jump us to 0x0:0x5010 so we'd better be ready for it [org 0x5000] [bits 16] ;HOS module header, better be 16 bytes! dd 0x4D534F48 ; magic identifier "HOSM" dd 1 ; real mode module dd start ; start address dd 0 ; reserved ; ebx = return address ; ecx = where to store real mode parameter table ; edx = initrd, where to put ram disk start: mov ax, cs ; 0 mov ds, ax mov es, ax mov ss, ax mov esp, 0x7000 mov [dat_rmadd], ecx mov [dat_initrd], edx mov [dat_retn], ebx mov ah, 0 ;reset floppy controller mov dl, 0 int 0x13 push txt_loading_initrd ;print loading initrd string push 23*80 call putString add sp, 4 push es ; draw a red bar to fill in mov ax, 0xb800 mov es, ax mov di, 24*160 mov cx, 80 mov ax, 0x04B0 rep stosw pop es mov cx, 80 ;80 cylinders to read xor si, si ;start at cylinder 0 mov edi, [dat_initrd] ;ram disk address read_cylinder: push cx mov bx, 0x1000 ;read sectors from head 0 mov es, bx xor bx, bx ;es:bx = data buffer for read mov ax, 0x0212 ;ah = int 0x13 function 2, al = number of sectors to read mov cx, si ;what cyl. we are on is now in cx mov ch, cl ;ch = cyl. number mov cl, 1 ;cl = sector number 1-63 xor dx, dx ;dh = head number ; mov dl, 0 ;dl = drive number int 0x13 mov bx, 0x1000 ;now read sectors from head 1 mov es, bx mov bx, 9216 ;es:bx = data buffer for read mov ax, 0x0212 ;ah = int 0x13 function 2, al = number of sectors to read mov cx, si ;what cyl. we are on is now in cx mov ch, cl ;ch = cyl. number mov cl, 1 ;cl = sector number 1-63 ; mov dh, 1 ;dh = head number ; mov dl, 0 ;dl = drive number mov dx, 0x0100 int 0x13 mov ebx, 0xb8000 ;draw a green block add bx, si shl bl, 1 mov word [ds:ebx+160*24], 0x0200+219 push si mov esi, 0x10000 ;now copy the disk up to where we will keep it mov cx, 0x2400 rep o32 movsb pop si ;what cylinder# we are on... inc si pop cx loop read_cylinder aloop: jmp aloop ; putString(int position, char *str) putString: push bp mov bp, sp push ds push es push edi push esi push eax mov ax, 0xb800 mov es, ax xor ax, ax mov ds, ax mov ax, [bp + 4] mov di, ax shl di, 1 mov ax, [bp + 6] mov si, ax putString_loop: lodsb stosb cmp al, 0 jz putString_loop_done mov al, 0x07 stosb jmp putString_loop putString_loop_done: pop eax pop esi pop edi pop es pop ds pop bp ret txt_loading_initrd: db "Loading initrd... ", 0 dat_rmadd dd 0 dat_initrd dd 0 dat_retn dd 0