Subversion Repositories Kolibri OS

Rev

Rev 3163 | Rev 3176 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
431 serge 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
2047 art_zh 3
;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;;
431 serge 4
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa      ;;
5
;; Distributed under terms of the GNU General Public License    ;;
6
;;                                                              ;;
7
;;  BOOTCODE.INC                                                ;;
8
;;                                                              ;;
2047 art_zh 9
;;  Kolibri-A auxiliary 16-bit code,                            ;;
10
;;                        based on bootcode for KolibriOS       ;;
431 serge 11
;;                                                              ;;
12
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1 ha 13
 
593 mikedld 14
$Revision: 3169 $
1 ha 15
 
3169 art_zh 16
boot_dev  db	  0  ; 0=floppy, 1=hd
1 ha 17
 
18
;==========================================================================
19
;
20
;                           16 BIT FUNCTIONS
21
;
22
;==========================================================================
23
 
24
 
134 diamond 25
boot_read_floppy:
1683 art_zh 26
	push	si
27
	xor	si, si
28
	mov	ah, 2	; read
134 diamond 29
@@:
1683 art_zh 30
	push	ax
31
	int	0x13
32
	pop	ax
33
	jnc	@f
34
	inc	si
35
	cmp	si, 10
1703 art_zh 36
	jnb	$
134 diamond 37
@@:
1683 art_zh 38
	pop	si
39
	ret
134 diamond 40
 
1703 art_zh 41
sayerr_plain:
42
sayerr:
43
	jmp	$
44
 
45
 
795 shurf 46
; convert abs. sector number (AX) to BIOS T:H:S
47
; sector number = (abs.sector%BPB_SecPerTrk)+1
48
; pre.track number = (abs.sector/BPB_SecPerTrk)
49
; head number = pre.track number%BPB_NumHeads
50
; track number = pre.track number/BPB_NumHeads
51
; Return: cl - sector number
52
;         ch - track number
53
;         dl - drive number (0 = a:)
54
;         dh - head number
55
conv_abs_to_THS:
1683 art_zh 56
	push	bx
57
	mov	bx,word [BPB_SecPerTrk]
58
	xor	dx,dx
59
	div	bx
60
	inc	dx
61
	mov	cl, dl				; cl = sector number
62
	mov	bx,word [BPB_NumHeads]
63
	xor	dx,dx
64
	div	bx
65
	; !!!!!!! ax = track number, dx = head number
66
	mov	ch,al				; ch=track number
67
	xchg	dh,dl				; dh=head number
68
	mov	dl,0				; dl=0 (drive 0 (a:))
69
	pop	bx
70
	retn
795 shurf 71
; needed variables
1683 art_zh 72
BPB_SecPerTrk	dw	0			; sectors per track
73
BPB_NumHeads	dw	0			; number of heads
74
BPB_FATSz16	dw	0			; size of FAT
75
BPB_RootEntCnt	dw	0			; count of root dir. entries
76
BPB_BytsPerSec	dw	0			; bytes per sector
77
BPB_RsvdSecCnt	dw	0			; number of reserved sectors
78
BPB_TotSec16	dw	0			; count of the sectors on the volume
79
BPB_SecPerClus	db	0			; number of sectors per cluster
80
BPB_NumFATs	db	0			; number of FAT tables
81
abs_sector_adj	dw	0			; adjustment to make abs. sector number
82
end_of_FAT	dw	0			; end of FAT table
83
FirstDataSector dw	0			; begin of data
795 shurf 84
 
1 ha 85
;=========================================================================
86
;
87
;                           16 BIT CODE
88
;
89
;=========================================================================
90
 
3169 art_zh 91
diff16 "start_of_code: ",0,$
1 ha 92
 
93
start_of_code:
1683 art_zh 94
	cld
29 halyavin 95
; \begin{diamond}[02.12.2005]
514 diamond 96
; if bootloader sets ax = 'KL', then ds:si points to loader block
1683 art_zh 97
	cmp	ax, 'KL'
98
	jnz	@f
99
	mov	word [cs:cfgmanager.loader_block], si
100
	mov	word [cs:cfgmanager.loader_block+2], ds
29 halyavin 101
@@:
102
; \end{diamond}[02.12.2005]
1 ha 103
 
514 diamond 104
; if bootloader sets cx = 'HA' and dx = 'RD', then bx contains identifier of source hard disk
105
; (see comment to bx_from_load)
1683 art_zh 106
	cmp	cx, 'HA'
107
	jnz	no_hd_load
108
	cmp	dx,'RD'
109
	jnz	no_hd_load
110
	mov	word [cs:bx_from_load], bx		; {SPraid}[13.03.2007]
488 spraid 111
no_hd_load:
112
 
29 halyavin 113
; set up stack
1683 art_zh 114
	mov	ax, 3000h
115
	mov	ss, ax
116
	mov	sp, 0EC00h
29 halyavin 117
; set up segment registers
1683 art_zh 118
	push	cs
119
	pop	ds
120
	push	cs
121
	pop	es
1 ha 122
 
123
 
1703 art_zh 124
cpugood:
1 ha 125
 
1683 art_zh 126
	push	0
127
	popf
128
	sti
465 serge 129
 
29 halyavin 130
; set up esp
1683 art_zh 131
	movzx	esp, sp
1 ha 132
 
1683 art_zh 133
	push	0
134
	pop	es
135
	and	word [es:0x9031], 0
164 serge 136
; \begin{Mario79}
137
; find HDD IDE DMA PCI device
160 diamond 138
; check for PCI BIOS
1683 art_zh 139
	mov	ax, 0xB101
140
	int	0x1A
141
	jc	.nopci
142
	cmp	edx, 'PCI '
143
	jnz	.nopci
160 diamond 144
; find PCI class code
145
; class 1 = mass storage
146
; subclass 1 = IDE controller
147
; a) class 1, subclass 1, programming interface 0x80
1683 art_zh 148
	mov	ax, 0xB103
149
	mov	ecx, 1*10000h + 1*100h + 0x80
150
	xor	si, si	; device index = 0
151
	int	0x1A
152
	jnc	.found
187 diamond 153
; b) class 1, subclass 1, programming interface 0x8A
1683 art_zh 154
	mov	ax, 0xB103
155
	mov	ecx, 1*10000h + 1*100h + 0x8A
156
	xor	si, si	; device index = 0
157
	int	0x1A
158
	jnc	.found
187 diamond 159
; c) class 1, subclass 1, programming interface 0x85
1683 art_zh 160
	mov	ax, 0xB103
161
	mov	ecx, 1*10000h + 1*100h + 0x85
162
	xor	si, si
163
	int	0x1A
164
	jc	.nopci
160 diamond 165
.found:
166
; get memory base
1683 art_zh 167
	mov	ax, 0xB10A
168
	mov	di, 0x20	; memory base is config register at 0x20
169
	int	0x1A
170
	jc	.nopci
171
	and	cx, 0xFFF0	; clear address decode type
172
	mov	[es:0x9031], cx
160 diamond 173
.nopci:
164 serge 174
; \end{Mario79}
160 diamond 175
 
3169 art_zh 176
; --------------- APM - removed--------------------
1683 art_zh 177
	and	word [es:0x9044], 0	; ver = 0.0 (APM not found)
3163 art_zh 178
 if 0
1683 art_zh 179
	mov	ax, 0x5300
180
	xor	bx, bx
181
	int	0x15
182
	jc	apm_end 		; APM not found
183
	test	cx, 2
184
	jz	apm_end 		; APM 32-bit protected-mode interface not supported
185
	mov	[es:0x9044], ax 	; Save APM Version
186
	mov	[es:0x9046], cx 	; Save APM flags
164 serge 187
 
1683 art_zh 188
	mov	ax, 0x5304		; Disconnect interface
189
	xor	bx, bx
190
	int	0x15
191
	mov	ax, 0x5303		; Connect 32 bit mode interface
192
	xor	bx, bx
193
	int	0x15
465 serge 194
 
1683 art_zh 195
	mov	[es:0x9040], ebx
196
	mov	[es:0x9050], ax
197
	mov	[es:0x9052], cx
198
	mov	[es:0x9054], dx
465 serge 199
 
76 mario79 200
apm_end:
3163 art_zh 201
end if
76 mario79 202
 
713 Lrz 203
;CHECK current of code
1683 art_zh 204
	cmp	[cfgmanager.loader_block], -1
205
	jz	noloaderblock
206
	les	bx, [cfgmanager.loader_block]
207
	cmp	byte [es:bx], 1
208
	jnz	sayerr
209
	push	0
210
	pop	es
713 Lrz 211
 
212
noloaderblock:
1 ha 213
; DISPLAY VESA INFORMATION
3163 art_zh 214
;         call    print_vesa_info
215
;         call    calc_vmodes_table
216
;         call    check_first_parm  ;check and enable cursor_pos
1 ha 217
 
29 halyavin 218
; \begin{diamond}[30.11.2005]
219
cfgmanager:
220
; settings:
221
; a) preboot_graph = graphical mode
222
;    preboot_gprobe = probe this mode?
713 Lrz 223
; b) preboot_dma  = use DMA access?
29 halyavin 224
; c) preboot_vrrm = use VRR?
225
; d) preboot_device = from what boot?
713 Lrz 226
 
29 halyavin 227
; determine default settings
1703 art_zh 228
;        mov     [.bSettingsChanged], 0
713 Lrz 229
 
230
;.preboot_gr_end:
1683 art_zh 231
	mov	di, preboot_device
726 diamond 232
; if image in memory is present and [preboot_device] is uninitialized,
233
; set it to use this preloaded image
1683 art_zh 234
	cmp	byte [di], 0
235
	jnz	.preboot_device_inited
236
	cmp	[.loader_block], -1
237
	jz	@f
238
	les	bx, [.loader_block]
239
	test	byte [es:bx+1], 1
240
	jz	@f
241
	mov	byte [di], 3
242
	jmp	.preboot_device_inited
726 diamond 243
@@:
244
; otherwise, set [preboot_device] to 1 (default value - boot from floppy)
1683 art_zh 245
	mov	byte [di], 1
726 diamond 246
.preboot_device_inited:
1018 diamond 247
; following 4 lines set variables to 1 if its current value is 0
1683 art_zh 248
	cmp	byte [di+preboot_dma-preboot_device], 1
249
	adc	byte [di+preboot_dma-preboot_device], 0
250
	cmp	byte [di+preboot_biosdisk-preboot_device], 1
251
	adc	byte [di+preboot_biosdisk-preboot_device], 0
713 Lrz 252
 
1703 art_zh 253
;        pop     ax              ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ??
254
	jmp	.continue
2014 art_zh 255
 
143 diamond 256
.loader_block dd -1
29 halyavin 257
.continue:
1683 art_zh 258
	sti
1703 art_zh 259
	jmp	 .load
946 lrz 260
 
29 halyavin 261
.loadc:
1683 art_zh 262
	pop	eax
29 halyavin 263
.cont:
1683 art_zh 264
	push	cs
265
	pop	ds
29 halyavin 266
.load:
1 ha 267
 
268
; ASK GRAPHICS MODE
269
 
3163 art_zh 270
;       call    set_vmode
1 ha 271
 
272
; GRAPHICS ACCELERATION
346 diamond 273
; force yes
1683 art_zh 274
	mov	[es:0x901C], byte 1
1 ha 275
 
514 diamond 276
; DMA ACCESS TO HD
1 ha 277
 
1683 art_zh 278
	mov	al, [preboot_dma]
279
	mov	[es:0x901F], al
346 diamond 280
 
1 ha 281
; VRR_M USE
282
 
1683 art_zh 283
	mov	al,[preboot_vrrm]
284
	mov	[es:0x9030], al
285
	mov	[es:0x901E], byte 1
1 ha 286
 
287
; BOOT DEVICE
288
 
1683 art_zh 289
	mov	al, [preboot_device]
290
	dec	al
291
	mov	[boot_dev], al
1 ha 292
 
1103 diamond 293
 
1 ha 294
; SET GRAPHICS
295
 
1683 art_zh 296
	xor	ax, ax
297
	mov	es, ax
164 serge 298
 
3163 art_zh 299
;        mov     bx, [es:0x9008]         ; vga & 320x200
300
	mov	ax, 0xA000		; AtomBIOS Fn00
301
	mov	cx, 0x550A		; 1024x768, 32bpp, ARGB8888
412 serge 302
setgr:
1683 art_zh 303
	int	0x10
304
	test	ah, ah
1703 art_zh 305
	jnz	$
3163 art_zh 306
	mov	ax, 0xA006		; AtomBIOS Fn06
307
	int	0x10
308
	mov	[es:0x9018], ebx	; LFB
309
 
412 serge 310
gmok2:
1683 art_zh 311
	push	ds
312
	pop	es