Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
2288 clevermous 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;
6122 hidnplayr 3
;; Copyright (C) KolibriOS team 2004-2016. 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
 
3383 hidnplayr 69
format binary as "mnt"
70
 
2288 clevermous 71
include 'macros.inc'
2381 hidnplayr 72
include 'struct.inc'
2288 clevermous 73
 
74
$Revision: 7129 $
75
 
76
 
77
USE_COM_IRQ     equ 1      ; make irq 3 and irq 4 available for PCI devices
3627 Serge 78
VESA_1_2_VIDEO  equ 0      ; enable vesa 1.2 bank switch functions
2288 clevermous 79
 
80
; Enabling the next line will enable serial output console
3556 hidnplayr 81
;debug_com_base  equ 0x3f8  ; 0x3f8 is com1, 0x2f8 is com2, 0x3e8 is com3, 0x2e8 is com4, no irq's are used
2288 clevermous 82
 
83
include "proc32.inc"
84
include "kglobals.inc"
85
include "lang.inc"
3539 clevermous 86
include "encoding.inc"
2288 clevermous 87
 
88
include "const.inc"
3777 yogev_ezra 89
 
90
iglobal
91
; The following variable, if equal to 1, duplicates debug output to the screen.
92
debug_direct_print db 0
93
; Start the first app (LAUNCHER) after kernel is loaded? (1=yes, 2 or 0=no)
94
launcher_start db 1
95
endg
96
 
2288 clevermous 97
max_processes    equ   255
98
tss_step         equ   (128+8192) ; tss & i/o - 65535 ports, * 256=557056*4
99
 
100
os_stack       equ  (os_data_l-gdts)    ; GDTs
101
os_code        equ  (os_code_l-gdts)
102
graph_data     equ  (3+graph_data_l-gdts)
103
tss0           equ  (tss0_l-gdts)
104
app_code       equ  (3+app_code_l-gdts)
105
app_data       equ  (3+app_data_l-gdts)
106
app_tls        equ  (3+tls_data_l-gdts)
107
pci_code_sel   equ  (pci_code_32-gdts)
108
pci_data_sel   equ  (pci_data_32-gdts)
109
 
110
 
111
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
112
;;
113
;;   Included files:
114
;;
115
;;   Kernel16.inc
116
;;    - Booteng.inc   English text for bootup
117
;;    - Bootcode.inc  Hardware setup
118
;;    - Pci16.inc     PCI functions
119
;;
120
;;   Kernel32.inc
121
;;    - Sys32.inc     Process management
122
;;    - Shutdown.inc  Shutdown and restart
123
;;    - Fat32.inc     Read / write hd
124
;;    - Vesa12.inc    Vesa 1.2 driver
125
;;    - Vesa20.inc    Vesa 2.0 driver
126
;;    - Vga.inc       VGA driver
127
;;    - Stack.inc     Network interface
128
;;    - Mouse.inc     Mouse pointer
129
;;    - Scincode.inc  Window skinning
130
;;    - Pci32.inc     PCI functions
131
;;
132
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
133
 
7129 dunkaist 134
; In bios boot mode the kernel code below is appended to bootbios.bin file.
135
; That is a loading and initialization code that also draws the blue screen
136
; menu with svn revision number near top right corner of the screen. This fasm
137
; preprocessor code searches for '****' signature inside bootbios.bin and
138
; places revision number there.
139
if ~ defined UEFI
140
  bootbios:
141
  file 'bootbios.bin'
142
  if __REV__ > 0
143
    cur_pos = 0
144
    cnt = 0
145
    repeat $ - bootbios
146
      load a byte from %
147
      if a = '*'
148
        cnt = cnt + 1
149
      else
150
        cnt = 0
151
      end if
152
      if cnt = 4
153
        cur_pos = % - 1
154
        break
155
      end if
156
    end repeat
157
    store byte ' ' at cur_pos + 1
158
    rev_var = __REV__
159
    while rev_var > 0
160
      store byte rev_var mod 10 + '0' at cur_pos
161
      cur_pos = cur_pos - 1
162
      rev_var = rev_var / 10
163
    end while
164
      store byte ' ' at cur_pos
165
      store dword ' SVN' at cur_pos - 4
166
  end if
3287 esevece 167
end if
2288 clevermous 168
 
169
use32
170
org $+0x10000
171
 
172
align 4
173
B32:
174
        mov     ax, os_stack       ; Selector for os
175
        mov     ds, ax
176
        mov     es, ax
177
        mov     fs, ax
178
        mov     gs, ax
179
        mov     ss, ax
6244 serge 180
        mov     esp, TMP_STACK_TOP       ; Set stack
2288 clevermous 181
 
182
; CLEAR 0x280000 - HEAP_BASE
183
 
184
        xor     eax, eax
185
        mov     edi, CLEAN_ZONE
186
        mov     ecx, (HEAP_BASE-OS_BASE-CLEAN_ZONE) / 4
187
        cld
188
        rep stosd
189
 
190
; CLEAR KERNEL UNDEFINED GLOBALS
191
        mov     edi, endofcode-OS_BASE
192
        mov     ecx, 0x90000
193
        sub     ecx, edi
194
        shr     ecx, 2
195
        rep stosd
196
 
197
; SAVE & CLEAR 0-0xffff
198
 
199
        mov     edi, 0x1000
3732 Serge 200
        mov     ecx, 0x8000 / 4
2288 clevermous 201
        rep stosd
3732 Serge 202
        mov     edi, 0xa000
203
        mov     ecx, 0x6000 / 4
204
        rep stosd
2288 clevermous 205
 
206
        call    test_cpu
207
        bts     [cpu_caps-OS_BASE], CAPS_TSC    ;force use rdtsc
208
 
209
        call    check_acpi
5787 serge 210
        call    init_hpet
2288 clevermous 211
        call    init_BIOS32
212
; MEMORY MODEL
213
        call    mem_test
214
        call    init_mem
215
        call    init_page_map
216
 
217
; ENABLE PAGING
218
 
5130 serge 219
        mov     eax, sys_proc-OS_BASE+PROC.pdt_0
2288 clevermous 220
        mov     cr3, eax
221
 
222
        mov     eax, cr0
223
        or      eax, CR0_PG+CR0_WP
224
        mov     cr0, eax
225
 
226
        lgdt    [gdts]
227
        jmp     pword os_code:high_code
228
 
229
align 4
230
bios32_entry    dd ?
231
tmp_page_tabs   dd ?
232
use16
5033 clevermous 233
ap_init16:
234
        cli
235
        lgdt    [cs:gdts_ap-ap_init16]
236
        mov     eax, [cs:cr3_ap-ap_init16]
237
        mov     cr3, eax
238
        mov     eax, [cs:cr4_ap-ap_init16]
239
        mov     cr4, eax
240
        mov     eax, CR0_PE+CR0_PG+CR0_WP
241
        mov     cr0, eax
242
        jmp     pword os_code:ap_init_high
243
align 16
244
gdts_ap:
245
        dw     gdte-gdts-1
246
        dd     gdts
247
        dw     0
248
cr3_ap  dd     ?
249
cr4_ap  dd     ?
250
ap_init16_size = $ - ap_init16
2288 clevermous