Subversion Repositories Kolibri OS

Rev

Rev 1172 | Rev 1232 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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