Subversion Repositories Kolibri OS

Rev

Rev 3169 | Rev 3194 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3169 Rev 3176
Line 9... Line 9...
9
;;  Kolibri-A auxiliary 16-bit code,                            ;;
9
;;  Kolibri-A auxiliary 16-bit code,                            ;;
10
;;                        based on bootcode for KolibriOS       ;;
10
;;                        based on bootcode for KolibriOS       ;;
11
;;                                                              ;;
11
;;                                                              ;;
12
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
12
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 13... Line 13...
13
 
13
 
Line 14... Line 14...
14
$Revision: 3169 $
14
$Revision: 3176 $
Line 15... Line -...
15
 
-
 
16
boot_dev  db	  0  ; 0=floppy, 1=hd
-
 
17
 
-
 
18
;==========================================================================
-
 
19
;
-
 
20
;                           16 BIT FUNCTIONS
-
 
21
;
-
 
22
;==========================================================================
-
 
23
 
-
 
24
 
-
 
25
boot_read_floppy:
-
 
26
	push	si
-
 
27
	xor	si, si
-
 
28
	mov	ah, 2	; read
-
 
29
@@:
-
 
30
	push	ax
-
 
31
	int	0x13
-
 
32
	pop	ax
-
 
33
	jnc	@f
-
 
34
	inc	si
-
 
35
	cmp	si, 10
-
 
36
	jnb	$
-
 
37
@@:
-
 
38
	pop	si
-
 
39
	ret
-
 
40
 
-
 
41
sayerr_plain:
-
 
42
sayerr:
-
 
43
	jmp	$
-
 
44
 
-
 
45
 
-
 
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:
-
 
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
-
 
71
; needed variables
-
 
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
-
 
Line 81... Line 15...
81
abs_sector_adj	dw	0			; adjustment to make abs. sector number
15
 
82
end_of_FAT	dw	0			; end of FAT table
16
boot_dev  db	  0  ; 0=floppy, 1=hd
83
FirstDataSector dw	0			; begin of data
17
 
84
 
18
 
Line 90... Line 24...
90
 
24
 
Line 91... Line 25...
91
diff16 "start_of_code: ",0,$
25
diff16 "start_of_code: ",0,$
92
 
26
 
93
start_of_code:
-
 
94
	cld
-
 
95
; \begin{diamond}[02.12.2005]
-
 
96
; if bootloader sets ax = 'KL', then ds:si points to loader block
-
 
97
	cmp	ax, 'KL'
-
 
98
	jnz	@f
-
 
99
	mov	word [cs:cfgmanager.loader_block], si
-
 
100
	mov	word [cs:cfgmanager.loader_block+2], ds
-
 
101
@@:
-
 
102
; \end{diamond}[02.12.2005]
-
 
103
 
-
 
104
; if bootloader sets cx = 'HA' and dx = 'RD', then bx contains identifier of source hard disk
-
 
105
; (see comment to bx_from_load)
-
 
106
	cmp	cx, 'HA'
-
 
107
	jnz	no_hd_load
-
 
108
	cmp	dx,'RD'
-
 
109
	jnz	no_hd_load
-
 
Line 110... Line 27...
110
	mov	word [cs:bx_from_load], bx		; {SPraid}[13.03.2007]
27
start_of_code:
111
no_hd_load:
28
	cld
112
 
29
 
113
; set up stack
30
; set up stack
Line 120... Line 37...
120
	push	cs
37
	push	cs
121
	pop	es
38
	pop	es
Line 122... Line 39...
122
 
39
 
123
 
-
 
-
 
40
 
124
cpugood:
41
cpugood:
125
 
42
        xor     ax, ax
126
	push	0
43
	push	ax
Line 127... Line 44...
127
	popf
44
	popf
128
	sti
45
	sti
Line 129... Line 46...
129
 
46
 
130
; set up esp
47
; set up esp
131
	movzx	esp, sp
-
 
132
 
-
 
133
	push	0
-
 
134
	pop	es
-
 
135
	and	word [es:0x9031], 0
-
 
136
; \begin{Mario79}
-
 
137
; find HDD IDE DMA PCI device
-
 
138
; check for PCI BIOS
-
 
139
	mov	ax, 0xB101
-
 
140
	int	0x1A
-
 
141
	jc	.nopci
-
 
142
	cmp	edx, 'PCI '
-
 
143
	jnz	.nopci
-
 
144
; find PCI class code
-
 
145
; class 1 = mass storage
-
 
146
; subclass 1 = IDE controller
-
 
147
; a) class 1, subclass 1, programming interface 0x80
-
 
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
-
 
153
; b) class 1, subclass 1, programming interface 0x8A
-
 
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
-
 
159
; c) class 1, subclass 1, programming interface 0x85
-
 
160
	mov	ax, 0xB103
-
 
161
	mov	ecx, 1*10000h + 1*100h + 0x85
-
 
162
	xor	si, si
-
 
163
	int	0x1A
-
 
164
	jc	.nopci
-
 
165
.found:
-
 
166
; get memory base
-
 
167
	mov	ax, 0xB10A
-
 
168
	mov	di, 0x20	; memory base is config register at 0x20
48
	movzx	esp, sp
169
	int	0x1A
-
 
170
	jc	.nopci
-
 
Line 171... Line 49...
171
	and	cx, 0xFFF0	; clear address decode type
49
 
172
	mov	[es:0x9031], cx
50
	push	ax
173
.nopci:
-
 
174
; \end{Mario79}
-
 
175
 
-
 
176
; --------------- APM - removed--------------------
-
 
177
	and	word [es:0x9044], 0	; ver = 0.0 (APM not found)
-
 
178
 if 0
-
 
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
-
 
187
 
-
 
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
-
 
194
 
-
 
195
	mov	[es:0x9040], ebx
-
 
196
	mov	[es:0x9050], ax
-
 
197
	mov	[es:0x9052], cx
-
 
198
	mov	[es:0x9054], dx
-
 
199
 
-
 
200
apm_end:
-
 
201
end if
-
 
202
 
-
 
203
;CHECK current of code
-
 
204
	cmp	[cfgmanager.loader_block], -1
-
 
205
	jz	noloaderblock
-
 
Line 206... Line -...
206
	les	bx, [cfgmanager.loader_block]
-
 
207
	cmp	byte [es:bx], 1
-
 
208
	jnz	sayerr
-
 
209
	push	0
-
 
210
	pop	es
-
 
211
 
-
 
212
noloaderblock:
-
 
213
; DISPLAY VESA INFORMATION
51
	pop	es
214
;         call    print_vesa_info
-
 
215
;         call    calc_vmodes_table
-
 
216
;         call    check_first_parm  ;check and enable cursor_pos
-
 
217
 
-
 
218
; \begin{diamond}[30.11.2005]
-
 
219
cfgmanager:
-
 
220
; settings:
-
 
221
; a) preboot_graph = graphical mode
-
 
222
;    preboot_gprobe = probe this mode?
-
 
223
; b) preboot_dma  = use DMA access?
-
 
224
; c) preboot_vrrm = use VRR?
-
 
225
; d) preboot_device = from what boot?
-
 
226
 
-
 
227
; determine default settings
-
 
228
;        mov     [.bSettingsChanged], 0
-
 
229
 
-
 
230
;.preboot_gr_end:
-
 
231
	mov	di, preboot_device
-
 
232
; if image in memory is present and [preboot_device] is uninitialized,
-
 
233
; set it to use this preloaded image
-
 
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
-
 
243
@@:
-
 
244
; otherwise, set [preboot_device] to 1 (default value - boot from floppy)
-
 
245
	mov	byte [di], 1
-
 
246
.preboot_device_inited:
-
 
247
; following 4 lines set variables to 1 if its current value is 0
-
 
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
-
 
252
 
-
 
253
;        pop     ax              ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ??
-
 
Line 254... Line -...
254
	jmp	.continue
-
 
255
 
-
 
256
.loader_block dd -1
-
 
257
.continue:
-
 
258
	sti
-
 
259
	jmp	 .load
-
 
Line 260... Line 52...
260
 
52
	mov	[es:0x9031], ax
Line -... Line 53...
-
 
53
 
261
.loadc:
54
; --------------- APM - removed--------------------
Line 262... Line 55...
262
	pop	eax
55
	and	word [es:0x9044], 0	; ver = 0.0 (APM not found)
263
.cont:
56
 
264
	push	cs
57
cfgmanager:
Line 265... Line -...
265
	pop	ds
-
 
266
.load:
-
 
267
 
-
 
268
; ASK GRAPHICS MODE
-
 
Line 269... Line 58...
269
 
58
 
Line 270... Line -...
270
;       call    set_vmode
-
 
271
 
59
 
272
; GRAPHICS ACCELERATION
60
; DMA ACCESS TO HD
Line 273... Line 61...
273
; force yes
61
 
Line 274... Line -...
274
	mov	[es:0x901C], byte 1
-
 
275
 
62
	mov	al, 1
276
; DMA ACCESS TO HD
63
	mov	[es:0x901F], al
-
 
64
 
Line 277... Line 65...
277
 
65
; GRAPHICS ACCELERATION
Line 278... Line -...
278
	mov	al, [preboot_dma]
-
 
279
	mov	[es:0x901F], al
-
 
280
 
-
 
281
; VRR_M USE
-
 
282
 
66
; force yes
283
	mov	al,[preboot_vrrm]
67
	mov	[es:0x901C], al
284
	mov	[es:0x9030], al
68
 
285
	mov	[es:0x901E], byte 1
69
 
286
 
70
; VRR_M USE