3
					
						
						« am: 17. September 2005, 16:48 »
					 
					
					kein problem.
danke das du es auf dich nimmst den ganz durch zu guckn
boot.asm:
[BITS 16]
org 0x7C00
start:
	mov [bootdrv], dl
	mov ax, cs
	mov	ds, ax		
	mov	es, ax		
	mov	fs, ax	
	mov	gs, ax		
; -----------------------------------
; Setup Stack
; -----------------------------------
	cli             ; Keine Interrupts!
	mov ax, 0x9000  ; Stackadresse
	mov ss, ax      ; SS = 9000 (unser Stack)
	mov sp, 0       ; SP = 0000  (der Stackpointer)
	sti             ; Interrupts zulassen
; -----------------------------------
; Enable A20 
; -----------------------------------
	call enableA20
	
; -----------------------------------
; Load Kernel
; -----------------------------------
%include "load_floppy.inc"
; -----------------------------------
; Print a message
; -----------------------------------
%include "message.inc"   <-----------------------HIER DIESE MESSAGE WIRD NICH ANGEZEIGT (ES SEI DENN ICH MACHE SIE VOR DEN FLOPPY LOAD)
	
; -----------------------------------
; Setup GDT
; -----------------------------------
	lgdt	[gdt]
	
; -----------------------------------
; Enter Protected Mode
; -----------------------------------
	cli
	mov	ecx, CR0		
	or ecx, 1
	mov	CR0, ecx		
	db	0xea	;Bitmuster für einen FAR JUMP	
	dw	PMode	;Angabe des Offsets zu dem gesprungen werden soll	
	dw	0x8		;Angabe des Selektors für das Segment zu dem gesprungen werden soll.
	
; -----------------------------------
; Refresh Registers
; -----------------------------------
[BITS 32]
PMode:
	mov	eax, 2		;Index 2 der GDT auswählen	
	shl eax, 3
	mov	ds, ax		
	mov	es, ax		
	mov	ss, ax		
	mov	eax, 0		
	mov	fs, ax		;FS und GS auf NULL Deskriptor zeigen lassen	
	mov	gs, ax		
	mov	esp, 0x1FFFF	;ESP setzen
	
; -----------------------------------
; Jump to the Kernel
; -----------------------------------
	jmp dword 8:0x10000
%include "gdt.inc"
%include "a20gate.inc"
bootdrv db 0
loadmsg db "Loading ClusterOS...",13,10,0
TIMES 510-($-$$) DB 0
SIGNATURE DW 0xAA55
load_floppy.inc:
_disk_reset:
; Diskdrive reset (Interrupt 13h, 0)
	push ds            ; Sichere DS
	mov ax, 0          ; Die gewünschte Funktion (reset)
	mov dl, [bootdrv]
	int 13h            ; Den Interrupt ausführen
	pop ds             ; DS wiederherstellen
	jc _disk_reset            ; Geht nicht? -> Noch mal!
; ------------------------------------------------
;	kernel
; ------------------------------------------------
_loadkernel:
	mov ax,0x1000      ; ES:BX = 10000
	mov es,ax
	mov bx, 0
	mov al, 18	; num of sectors
	mov cx, 2	; cylinder + start sector
	mov dh, 0	; head
; Read Sectors( Int 0x13, 2 )
	mov dl, [bootdrv]
	mov ah, 2 
	int 0x13   
	jc _loadkernel
_loadprogramfiles:
; ------------------------------------------------
;	command
; ------------------------------------------------
_loadprogramfiles_1:
	mov ax,0x5200      ; ES:BX = 52000
	mov es,ax
	mov bx, 0
	mov al, 18	; num of sectors
	mov cx, 2	; cylinder + start sector
	mov dh, 1	; head
; Read Sectors( Int 0x13, 2 )
	mov dl, [bootdrv]
	mov ah, 2 
	int 0x13   
	jc _loadprogramfiles_1        ; Fehler? Noch mal!
; ------------------------------------------------
;	info
; ------------------------------------------------
_loadprogramfiles_2:
	mov ax,0x5300      ; ES:BX = 53000
	mov es,ax
	mov bx, 0
	mov al, 18	; num of sectors
	mov cx, 5	; cylinder + start sector
	mov dh, 1	; head
; Read Sectors( Int 0x13, 2 )
	mov dl, [bootdrv]
	mov ah, 2 
	int 0x13   
	jc _loadprogramfiles_2        ; Fehler? Noch mal!
_load_end:
; deactivate floppy-motor
	mov dx,0x3F2 
	mov al,0x0C 
	out dx,al
message.inc
	mov si,loadmsg
putstr:
	lodsb             ; Byte laden
	or al,al
	jz short putstrd  ; 0-Byte? -> Ende!
	mov ah,0x0E       ; Funktion 0x0E
	mov bx,0x0007     ; Attribut-Byte (wird nicht benötigt)
	int 0x10          ; schreiben
	jmp putstr        ; Nächstes Byte
putstrd:
gdt.inc
gdt_start:	
	dd	0	;Ein DWORD mit dem Wert 0	
	dd	0	;Ein DWORD mit dem Wert 0
FLAT_CODE:			; 1
	dw 0xFFFFF
	dw 0x0
	db 0x0
	db 9Ah		
	db 0CFh		
	db 0
FLAT_DATA:			; 2
	dw 0xFFFFF
	dw 0x0
	db 0x0
	db 92h		
	db 0CFh		
	db 0
gdt:
	dw gdt - gdt_start - 1
	dd gdt_start
a20gate.inc habe ich von einen andren projekt rauskopiert.
steht nur code drinne der den a20 aktiviert.
sollte also nix falsche drinnen sein.
;;
;; enableA20.s (adapted from Visopsys OS-loader)
;;
;; Copyright (c) 2000, J. Andrew McLaughlin
;; You're free to use this code in any manner you like, as long as this
;; notice is included (and you give credit where it is due), and as long
;; as you understand and accept that it comes with NO WARRANTY OF ANY KIND.
;; Contact me at jamesamc@yahoo.com about any bugs or problems.
;;
enableA20:
;; This subroutine will enable the A20 address line in the keyboard
;; controller.  Takes no arguments.  Returns 0 in EAX on success, 
;; -1 on failure.  Written for use in 16-bit code, see lines marked
;; with 32-BIT for use in 32-bit code.
pusha
;; Make sure interrupts are disabled
cli
;; Keep a counter so that we can make up to 5 attempts to turn
;; on A20 if necessary
mov CX, 5
.startAttempt1:
;; Wait for the controller to be ready for a command
.commandWait1:
xor AX, AX
in AL, 64h
bt AX, 1
jc .commandWait1
;; Tell the controller we want to read the current status.
;; Send the command D0h: read output port.
mov AL, 0D0h
out 64h, AL
;; Wait for the controller to be ready with a byte of data
.dataWait1:
xor AX, AX
in AL, 64h
bt AX, 0
jnc .dataWait1
;; Read the current port status from port 60h
xor AX, AX
in AL, 60h
;; Save the current value of (E)AX
push AX; 16-BIT
;; push EAX; 32-BIT
;; Wait for the controller to be ready for a command
.commandWait2:
in AL, 64h
bt AX, 1
jc .commandWait2
;; Tell the controller we want to write the status byte again
mov AL, 0D1h
out 64h, AL
;; Wait for the controller to be ready for the data
.commandWait3:
xor AX, AX
in AL, 64h
bt AX, 1
jc .commandWait3
;; Write the new value to port 60h.  Remember we saved the old
;; value on the stack
pop AX; 16-BIT
;; pop EAX; 32-BIT
;; Turn on the A20 enable bit
or AL, 00000010b
out 60h, AL
;; Finally, we will attempt to read back the A20 status
;; to ensure it was enabled.
;; Wait for the controller to be ready for a command
.commandWait4:
xor AX, AX
in AL, 64h
bt AX, 1
jc .commandWait4
;; Send the command D0h: read output port.
mov AL, 0D0h
out 64h, AL
;; Wait for the controller to be ready with a byte of data
.dataWait2:
xor AX, AX
in AL, 64h
bt AX, 0
jnc .dataWait2
;; Read the current port status from port 60h
xor AX, AX
in AL, 60h
;; Is A20 enabled?
bt AX, 1
;; Check the result.  If carry is on, A20 is on.
jc .success
;; Should we retry the operation?  If the counter value in ECX
;; has not reached zero, we will retry
loop .startAttempt1
;; Well, our initial attempt to set A20 has failed.  Now we will
;; try a backup method (which is supposedly not supported on many
;; chipsets, but which seems to be the only method that works on
;; other chipsets).
;; Keep a counter so that we can make up to 5 attempts to turn
;; on A20 if necessary
mov CX, 5
.startAttempt2:
;; Wait for the keyboard to be ready for another command
.commandWait6:
xor AX, AX
in AL, 64h
bt AX, 1
jc .commandWait6
;; Tell the controller we want to turn on A20
mov AL, 0DFh
out 64h, AL
;; Again, we will attempt to read back the A20 status
;; to ensure it was enabled.
;; Wait for the controller to be ready for a command
.commandWait7:
xor AX, AX
in AL, 64h
bt AX, 1
jc .commandWait7
;; Send the command D0h: read output port.
mov AL, 0D0h
out 64h, AL
;; Wait for the controller to be ready with a byte of data
.dataWait3:
xor AX, AX
in AL, 64h
bt AX, 0
jnc .dataWait3
;; Read the current port status from port 60h
xor AX, AX
in AL, 60h
;; Is A20 enabled?
bt AX, 1
;; Check the result.  If carry is on, A20 is on, but we might warn
;; that we had to use this alternate method
jc .warn
;; Should we retry the operation?  If the counter value in ECX
;; has not reached zero, we will retry
loop .startAttempt2
;; OK, we weren't able to set the A20 address line.  Do you want
;; to put an error message here?
jmp .fail
.warn:
;; Here you may or may not want to print a warning message about
;; the fact that we had to use the nonstandard alternate enabling
;; method
.success:
sti
popa
xor EAX, EAX
ret
.fail:
sti
popa
mov EAX, -1
ret