Page 2 of 2

Re: Issue with custom Linux Bootloader

Posted: Fri Nov 21, 2008 8:50 am
by Moffatt
I see my mistake with loading it from the Floppy.

Once I was able to load it from a Floppy, I was able to debug. The following is my changed code that can boot the Linux Kernel. All I can say is that with BOCHS I able to confirm that all the registers were set correctly. I tried this on my target and the kernel boots correctly.

Code: Select all


_TEXT32 SEGMENT PARA PUBLIC USE32 'CODE16'
ASSUME CS:_TEXT32, DS:NOTHING
org 0x0

	;Disable the Interrupts before beginning
	cli
	; Reload CS with 16-bit value
	; Try a jmp
	db	0xea
	dw    	0x30 ; Hardcoded JUMP to known offset
        dw      PSEUDO_RM_CSEG

_TEXT32 Ends

_TEXT16 SEGMENT PARA PUBLIC USE16 'CODE16'
ASSUME CS:_TEXT16, DS:NOTHING

org 0x20

	; Load the Segment Registers, with Segment Limit
        mov     ax, PSEUDO_RM_DSEG
        mov     ss, ax
       	mov     ds, ax
      	mov     es, ax
        mov     fs, ax
        mov     gs, ax

	; Clear the PE flag in the CR0 register
        mov     eax, cr0            ; Get the current CR0
        and     al, NOT 1           ; Clear the PE bit to enable real mode
        mov     cr0, eax            ; NOW WE'RE IN REALMODE!



	; Reload CS with Real Mode value
	; Try a jmp
	db	0xea
	dw    	0x60 ; Hardcoded JUMP to known offset
        dw      0x1000

org 0x50

	;Change Bx to linux kernel segment
	mov 	bx, LINUX_KERNEL_SEGMENT
	mov	ss, bx
	mov	sp, LINUX_SETUP_STACK

	mov	ds, bx
	mov	es, bx
	mov	fs, bx
	mov	gs, bx

	;/* jump to start */
	;/* ljmp */
	; Always jump to LINUX_KERNEL_ENTRY_POINT
	db	0xea
	dw	0
	dw 	LINUX_KERNEL_ENTRY_POINT

_TEXT16 ends

end
Thanks for all the assistance, I can have a nice relaxing weekend

-Moffatt