Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
2288 clevermous 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;
2455 mario79 3
;; Copyright (C) KolibriOS team 2004-2012. All rights reserved.
2288 clevermous 4
;; PROGRAMMING:
5
;; Ivan Poddubny
6
;; Marat Zakiyanov (Mario79)
7
;; VaStaNi
8
;; Trans
9
;; Mihail Semenyako (mike.dld)
10
;; Sergey Kuzmin (Wildwest)
11
;; Andrey Halyavin (halyavin)
12
;; Mihail Lisovin (Mihasik)
13
;; Andrey Ignatiev (andrew_programmer)
14
;; NoName
15
;; Evgeny Grechnikov (Diamond)
16
;; Iliya Mihailov (Ghost)
17
;; Sergey Semyonov (Serge)
18
;; Johnny_B
19
;; SPraid (simba)
20
;; Hidnplayr
21
;; Alexey Teplov ()
22
;; Rus
23
;; Nable
24
;; shurf
25
;; Alver
26
;; Maxis
27
;; Galkov
28
;; CleverMouse
29
;; tsdima
30
;; turbanoff
31
;; Asper
32
;; art_zh
33
;;
34
;; Data in this file was originally part of MenuetOS project which is
35
;; distributed under the terms of GNU GPL. It is modified and redistributed as
36
;; part of KolibriOS project under the terms of GNU GPL.
37
;;
38
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa
39
;; PROGRAMMING:
40
;;
41
;; Ville Mikael Turjanmaa, villemt@itu.jyu.fi
42
;; - main os coding/design
43
;; Jan-Michael Brummer, BUZZ2@gmx.de
44
;; Felix Kaiser, info@felix-kaiser.de
45
;; Paolo Minazzi, paolo.minazzi@inwind.it
46
;; quickcode@mail.ru
47
;; Alexey, kgaz@crosswinds.net
48
;; Juan M. Caravaca, bitrider@wanadoo.es
49
;; kristol@nic.fi
50
;; Mike Hibbett, mikeh@oceanfree.net
51
;; Lasse Kuusijarvi, kuusijar@lut.fi
52
;; Jarek Pelczar, jarekp3@wp.pl
53
;;
54
;; KolibriOS is distributed in the hope that it will be useful, but WITHOUT ANY
55
;; WARRANTY. No author or distributor accepts responsibility to anyone for the
56
;; consequences of using it or for whether it serves any particular purpose or
57
;; works at all, unless he says so in writing. Refer to the GNU General Public
58
;; License (the "GPL") for full details.
59
;
60
;; Everyone is granted permission to copy, modify and redistribute KolibriOS,
61
;; but only under the conditions described in the GPL. A copy of this license
62
;; is supposed to have been given to you along with KolibriOS so you can know
63
;; your rights and responsibilities. It should be in a file named COPYING.
64
;; Among other things, the copyright notice and this notice must be preserved
65
;; on all copies.
66
;;
67
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
68
 
69
include 'macros.inc'
2381 hidnplayr 70
include 'struct.inc'
2288 clevermous 71
 
72
$Revision: 3341 $
73
 
74
 
75
USE_COM_IRQ     equ 1      ; make irq 3 and irq 4 available for PCI devices
76
 
77
; Enabling the next line will enable serial output console
78
;debug_com_base  equ 0x3f8  ; 0x3f8 is com1, 0x2f8 is com2, 0x3e8 is com3, 0x2e8 is com4, no irq's are used
79
 
80
include "proc32.inc"
81
include "kglobals.inc"
82
include "lang.inc"
83
 
84
include "const.inc"
85
max_processes    equ   255
86
tss_step         equ   (128+8192) ; tss & i/o - 65535 ports, * 256=557056*4
87
 
88
 
89
os_stack       equ  (os_data_l-gdts)    ; GDTs
90
os_code        equ  (os_code_l-gdts)
91
graph_data     equ  (3+graph_data_l-gdts)
92
tss0           equ  (tss0_l-gdts)
93
app_code       equ  (3+app_code_l-gdts)
94
app_data       equ  (3+app_data_l-gdts)
95
app_tls        equ  (3+tls_data_l-gdts)
96
pci_code_sel   equ  (pci_code_32-gdts)
97
pci_data_sel   equ  (pci_data_32-gdts)
98
 
99
 
100
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
101
;;
102
;;   Included files:
103
;;
104
;;   Kernel16.inc
105
;;    - Booteng.inc   English text for bootup
106
;;    - Bootcode.inc  Hardware setup
107
;;    - Pci16.inc     PCI functions
108
;;
109
;;   Kernel32.inc
110
;;    - Sys32.inc     Process management
111
;;    - Shutdown.inc  Shutdown and restart
112
;;    - Fat32.inc     Read / write hd
113
;;    - Vesa12.inc    Vesa 1.2 driver
114
;;    - Vesa20.inc    Vesa 2.0 driver
115
;;    - Vga.inc       VGA driver
116
;;    - Stack.inc     Network interface
117
;;    - Mouse.inc     Mouse pointer
118
;;    - Scincode.inc  Window skinning
119
;;    - Pci32.inc     PCI functions
120
;;
121
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
122
 
123
 
124
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
125
;;                                                                      ;;
126
;;                  16 BIT ENTRY FROM BOOTSECTOR                        ;;
127
;;                                                                      ;;
128
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
129
 
130
use16
131
                  org   0x0
132
        jmp     start_of_code
133
 
3287 esevece 134
if lang eq sp
135
include "kernelsp.inc"  ; spanish kernel messages
136
else
2288 clevermous 137
version db    'Kolibri OS  version 0.7.7.0+     ',13,10,13,10,0
3287 esevece 138
end if
2288 clevermous 139
 
140
include "boot/bootstr.inc"     ; language-independent boot messages
141
include "boot/preboot.inc"
142
 
3274 esevece 143
if lang eq ge
144
include "boot/bootge.inc"     ; german system boot messages
145
else if lang eq sp
146
include "boot/bootsp.inc"     ; spanish system boot messages
2288 clevermous 147
else if lang eq ru
148
include "boot/bootru.inc"      ; russian system boot messages
149
include "boot/ru.inc"          ; Russian font
150
else if lang eq et
151
include "boot/bootet.inc"      ; estonian system boot messages
152
include "boot/et.inc"          ; Estonian font
153
else
3274 esevece 154
include "boot/booten.inc"      ; english system boot messages
2288 clevermous 155
end if
156
 
157
include "boot/bootcode.inc"    ; 16 bit system boot code
158
include "bus/pci/pci16.inc"
159
include "detect/biosdisk.inc"
160
 
161
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
162
;;                                                                      ;;
163
;;                  SWITCH TO 32 BIT PROTECTED MODE                     ;;
164
;;                                                                      ;;
165
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
166
 
167
 
168
; CR0 Flags - Protected mode and Paging
169
 
170
        mov     ecx, CR0_PE
171
 
172
; Enabling 32 bit protected mode
173
 
174
        sidt    [cs:old_ints_h]
175
 
176
        cli                             ; disable all irqs
177
        cld
178
        mov     al, 255                 ; mask all irqs
179
        out     0xa1, al
180
        out     0x21, al
181
   l.5:
182
        in      al, 0x64                ; Enable A20
183
        test    al, 2
184
        jnz     l.5
185
        mov     al, 0xD1
186
        out     0x64, al
187
   l.6:
188
        in      al, 0x64
189
        test    al, 2
190
        jnz     l.6
191
        mov     al, 0xDF
192
        out     0x60, al
193
   l.7:
194
        in      al, 0x64
195
        test    al, 2
196
        jnz     l.7
197
        mov     al, 0xFF
198
        out     0x64, al
199
 
200
        lgdt    [cs:tmp_gdt]            ; Load GDT
201
        mov     eax, cr0                ; protected mode
202
        or      eax, ecx
203
        and     eax, 10011111b *65536*256 + 0xffffff ; caching enabled
204
        mov     cr0, eax
205
        jmp     pword os_code:B32       ; jmp to enable 32 bit mode
206
 
207
align 8
208
tmp_gdt:
209
 
210
        dw     23
211
        dd     tmp_gdt+0x10000
212
        dw     0
213
 
214
        dw     0xffff
215
        dw     0x0000
216
        db     0x00
217
        dw     11011111b *256 +10011010b
218
        db     0x00
219
 
220
        dw     0xffff
221
        dw     0x0000
222
        db     0x00
223
        dw     11011111b *256 +10010010b
224
        db     0x00
225
 
226
include "data16.inc"
227
 
228
use32
229
org $+0x10000
230
 
231
align 4
232
B32:
233
        mov     ax, os_stack       ; Selector for os
234
        mov     ds, ax
235
        mov     es, ax
236
        mov     fs, ax
237
        mov     gs, ax
238
        mov     ss, ax
239
        mov     esp, 0x006CC00       ; Set stack
240
 
241
; CLEAR 0x280000 - HEAP_BASE
242
 
243
        xor     eax, eax
244
        mov     edi, CLEAN_ZONE
245
        mov     ecx, (HEAP_BASE-OS_BASE-CLEAN_ZONE) / 4
246
        cld
247
        rep stosd
248
 
249
; CLEAR KERNEL UNDEFINED GLOBALS
250
        mov     edi, endofcode-OS_BASE
251
        mov     ecx, 0x90000
252
        sub     ecx, edi
253
        shr     ecx, 2
254
        rep stosd
255
 
256
; SAVE & CLEAR 0-0xffff
257
 
258
        xor     esi, esi
259
        mov     edi, (BOOT_VAR-OS_BASE)
260
        mov     ecx, 0x10000 / 4
261
        rep movsd
262