Page 1 of 1

Emulate floppy (fat12) in cd (bootloader + kernel)

Posted: Tue Jan 25, 2011 1:48 am
by dan0tom
Hi! I have so more problems.

I created a bootloader that works when I add a boot record with no emulation in application isomaster (sudo apt-get install isomaster), but I loaded the kernel. I know that I need to emulate a floppy disk with a FAT12 file system. I have used everything and i see only blank screen ...

I use ubuntu, and nasm.

This is my bootloader:

Code: Select all

	;	Autor: dan-tom, 2011r.

[BITS 16]
[ORG 000h]

JMP POCZATEK

NAZWA_SYSTEMU		DB	'VAECE'
WIELKOSC_SEKTORA	DW	200H
WIELKOSC_CLUSTRA	DB	1H
ILE_ZAREZERWOWANYCH_SEKTOROW	DW	1H
ILE_TABLIC_ALOKACJI	DB	2H
ILE_ELEMENTOW_KATALOGU_GLOWNEGO	DW	0E0H
CALKOWITA_LICZBA_SEKTOROW	DW	0B40H
MEDIA_DESCRIPTOR_BYTE	DB	0F0H
ILE_SEKTOROW_NA_FAT	DW	9H
ILE_SEKTOROW_NA_SCIEZKE	DW	12H
ILE_GLOWIC	DW	2H
ILE_UKRYTYCH_SEKTOROW	DD	0H
TOTAL_SECTORS_LARGE	DD	0H
NUMER_DYSKIETKI	DB	0H
FLAGS2	DB	0H
SIGNATURE	DB	029H
VOLUME_ID	DD	0FFFFFFFFH
NAZWA_VOLUMENU	DB	'VAECEDT'
NAZWA_SYSTEMU_PLIKOW	DB	'FAT12	'

POCZATEK:
CLI
MOV AX,	07C0H
MOV DS,	AX
MOV	AX,	0H
MOV	SS,	AX
MOV	SP,	0FFFFH
STI
MOV DX,	BOOT_ZALADOWANY
CALL	WYPISZ_TEKST
MOV	AX,	DS
ADD	AX,	200H
MOV	ES,	AX
XOR	BX,	BX
MOV	DX,	[SEKTOR_ROOT_DIRECTORY]
MOV	CL,	[WIELKOSC_ROOT_DIRECTORY]
MOV	CH, 0
CALL ODCZYT_Z_DYSKU
XOR	DI,	DI
MOV	DX,	JADRO
CALL	SZUKAJ_JADRA
PUSH	AX
XOR	BX,	BX
MOV	DX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LAD_0	DB	'0', 0
BLAD_1	DB	'1', 0

TIMES	510-($-$$)	DB	0
DW	0AA55H
jadro111:

Code: Select all

[BITS 16]
[ORG 000h]

START:
JMP	POCZATEK
GOTOWOSC_SYSTEMU	DB	13,10, 13, 10, 13, 13, 10, 'SYSTEM OPERACYJNY ZOSTAL ZALADOWANY POMYSLNIE', 13, 10
DB	'WERTYFIKACJA POPRAWNOSCI DZIALANIA BOOT LOADERA WYPADLA POMYSLNIE', 0

POCZATEK:
CLI
MOV	AX,	CS
MOV	DS,	AX
MOV	AX,	0H
MOV	SS,	AX
MOV	SP,	0FFFFH
STI
MOV	DX,	GOTOWOSC_SYSTEMU
CALL	WYPISZ_TEKST
CALL	PROCEDURA_BEZ_KONCA
WYPISZ_TEKST:
PUSH	BX
XOR	BH,	BH
MOV	BL,	03H
MOV	SI,	DX
MOV	AH,	0EH
PETLA1_1:
MOV	AL,	[SI]
CMP	AL,	0
JE	END_PETLA1_1
INT	10H
INC	SI
JMP	PETLA1_1
END_PETLA1_1:
POP	BX
RET

PROCEDURA_BEZ_KONCA:
PETLA_GLOWNA_P_B_K:
NOP
JMP	PETLA_GLOWNA_P_B_K
RET
Pleas, help me when you know how can i do..

Re: Emulate floppy (fat12) in cd (bootloader + kernel)

Posted: Tue Jan 25, 2011 1:52 am
by Combuster
No-emulation and floppy emulation are mutually exclusive. If you want to stick with no-emulation, write code for the ISO 9660 filesystem instead. If you want floppy emulation, install your bootloader and kernel on a floppy (image) then supply that to your ISO tool (most people use mkisofs/genisoimage).

Both methods have corresponding tutorials in the wiki.

Re: Emulate floppy (fat12) in cd (bootloader + kernel)

Posted: Tue Jan 25, 2011 1:57 am
by dan0tom
Combuster wrote:No-emulation and floppy emulation are mutually exclusive. If you want to stick with no-emulation, write code for the ISO 9660 filesystem instead. If you want floppy emulation, install your bootloader and kernel on a floppy (image) then supply that to your ISO tool (most people use mkisofs/genisoimage).

Both methods have corresponding tutorials in the wiki.
It may be a guide how to make the bootloader include the jadro111.cor?

What I must edit in my code?

My code found jadro111.cor in the root directory