Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
1 ha 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;
3
;; Kolibri OS - based on source code Menuet OS, but not 100% compatible.
4
;;
5
;; See file COPYING or GNU.TXT for details with these additional details:
6
;;     - All code written in 32 bit x86 assembly language
7
;;     - No external code (eg. bios) at process execution time
8
;;
9
;;
10
;;   Compile with last version FASM
11
;;
12
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7 me_root 13
include "kglobals.inc"
1 ha 14
include "lang.inc"
15
 
16
WinMapAddress           equ     0x460000
17
display_data       = 0x460000
18
 
19
max_processes      equ   255
20
 
21
window_data        equ   0x0000
22
tss_data           equ   0xD20000
23
;tss_step           equ   (128+2048) ; tss & i/o - 16384 ports, * 256=557056
24
tss_step           equ   (128+8192) ; tss & i/o - 65535 ports, * 256=557056*4
25
draw_data          equ   0xC00000
26
sysint_stack_data  equ   0xC03000
27
 
28
 
29
twdw               equ   (0x3000-window_data)
30
 
31
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
32
;;
33
;;   Included files:
34
;;
35
;;   Kernel16.inc
36
;;    - Booteng.inc   English text for bootup
37
;;    - Bootcode.inc  Hardware setup
38
;;    - Pci16.inc     PCI functions
39
;;
40
;;   Kernel32.inc
41
;;    - Sys32.inc     Process management
42
;;    - Shutdown.inc  Shutdown and restart
43
;;    - Fat32.inc     Read / write hd
44
;;    - Vesa12.inc    Vesa 1.2 driver
45
;;    - Vesa20.inc    Vesa 2.0 driver
46
;;    - Vga.inc       VGA driver
47
;;    - Stack.inc     Network interface
48
;;    - Mouse.inc     Mouse pointer
49
;;    - Scincode.inc  Window skinning
50
;;    - Pci32.inc     PCI functions
51
;;
52
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
53
 
54
 
55
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
56
;;                                                                      ;;
57
;;                  16 BIT ENTRY FROM BOOTSECTOR                        ;;
58
;;                                                                      ;;
59
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
60
 
61
use16
62
                  org   0x10000
63
                  jmp   start_of_code
64
 
65
; mike.dld {
66
db 0
67
dd servetable-0x10000
68
draw_line       dd __sys_draw_line
69
disable_mouse   dd __sys_disable_mouse
70
draw_pointer    dd __sys_draw_pointer
71
drawbar         dd __sys_drawbar
72
putpixel        dd __sys_putpixel
73
; } mike.dld
74
 
61 halyavin 75
version           db    'Kolibri OS  version 0.5.3.0      ',13,10,13,10,0
1 ha 76
                  ;dd    endofcode-0x10000
77
 
78
                  ;db   'Boot02'
79
;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
80
include "boot/preboot.inc"
81
;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
82
 
83
preboot_lfb       db    0
84
preboot_bootlog   db    0
85
 
86
 
87
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
88
;;                                                                      ;;
89
;;                      16 BIT INCLUDED FILES                           ;;
90
;;                                                                      ;;
91
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
92
 
7 me_root 93
include "kernel16.inc"
1 ha 94
 
95
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
96
;;                                                                      ;;
97
;;                  SWITCH TO 32 BIT PROTECTED MODE                     ;;
98
;;                                                                      ;;
99
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
100
 
3 halyavin 101
os_data        =  os_data_l-gdts    ; GDTs
102
os_code        =  os_code_l-gdts
1 ha 103
int_code       equ  int_code_l-gdts
104
int_data       equ  int_data_l-gdts
105
tss0sys        equ  tss0sys_l-gdts
106
graph_data     equ  3+graph_data_l-gdts
107
tss0           equ  tss0_l-gdts
108
app_code       equ  3+app_code_l-gdts
109
app_data       equ  3+app_data_l-gdts
110
 
111
 
112
 
113
; CR0 Flags - Protected mode and Paging
114
 
115
        mov     ecx,0x00000001
116
        ;and     ebx,65535
117
        ;cmp     ebx,00100000000000000b ; lfb -> paging
118
        ;jb      no_paging
119
        ;mov     ax,0x0000
120
        ;mov     es,ax
121
        ;mov     al,[es:0x901E]
122
        ;cmp     al,1
123
        ;je      no_paging
124
        ;or      ecx, 0x80000000
125
       ;no_paging:
126
 
127
; Enabling 32 bit protected mode
128
 
129
        sidt    [cs:old_ints_h-0x10000]
130
 
131
        cli                             ; disable all irqs
132
        cld
133
        mov     al,255                  ; mask all irqs
134
        out     0xa1,al
135
        out     0x21,al
136
   l.5: in      al, 0x64                ; Enable A20
137
        test    al, 2
138
        jnz     l.5
139
        mov     al, 0xD1
140
        out     0x64, al
141
   l.6: in      al, 0x64
142
        test    al, 2
143
        jnz     l.6
144
        mov     al, 0xDF
145
        out     0x60, al
146
        lgdt    [cs:gdts-0x10000]       ; Load GDT
147
        mov     eax, cr0                ; Turn on paging // protected mode
148
        or      eax, ecx
149
        and     eax, 10011111b *65536*256 + 0xffffff ; caching enabled
150
        mov     cr0, eax
151
        jmp     byte $+2
152
        mov     ax,os_data              ; Selector for os
153
        mov     ds,ax
154
        mov     es,ax
155
        mov     fs,ax
156
        mov     gs,ax
157
        mov     ss,ax
12 halyavin 158
        mov     esp,0x3ec00             ; Set stack
1 ha 159
        jmp     pword os_code:B32       ; jmp to enable 32 bit mode
160
 
161
use32
162
 
163
iglobal
164
  boot_memdetect    db   'Determining amount of memory',0
165
  boot_fonts        db   'Fonts loaded',0
166
  boot_tss          db   'Setting TSSs',0
167
  boot_cpuid        db   'Reading CPUIDs',0
168
  boot_devices      db   'Detecting devices',0
169
  boot_timer        db   'Setting timer',0
170
  boot_irqs         db   'Reprogramming IRQs',0
171
  boot_setmouse     db   'Setting mouse',0
172
  boot_windefs      db   'Setting window defaults',0
173
  boot_bgr          db   'Calculating background',0
174
  boot_resirqports  db   'Reserving IRQs & ports',0
175
  boot_setrports    db   'Setting addresses for IRQs',0
176
  boot_setostask    db   'Setting OS task',0
177
  boot_allirqs      db   'Unmasking all IRQs',0
178
  boot_tsc          db   'Reading TSC',0
179
  boot_pal_ega      db   'Setting EGA/CGA 320x200 palette',0
180
  boot_pal_vga      db   'Setting VGA 640x480 palette',0
181
  boot_mtrr         db   'Setting MTRR',0
182
  boot_tasking      db   'All set - press ESC to start',0
183
endg
184
 
185
iglobal
186
  boot_y dd 10
187
endg
188
 
189
boot_log:
190
         pushad
191
 
192
         mov   edx,esi
193
.bll3:   inc   edx
194
         cmp   [edx],byte 0
195
         jne   .bll3
196
         sub   edx,esi
197
         mov   eax,10*65536
198
         mov   ax,word [boot_y]
199
         add   [boot_y],dword 10
200
         mov   ebx,0xffffff
201
         mov   ecx,esi
202
         mov   edi,1
203
         call  dtext
204
 
205
         mov   [novesachecksum],1000
206
         call  checkEgaCga
207
 
208
         cmp   [preboot_blogesc],byte 1
209
         je    .bll2
210
 
211
         cmp   esi,boot_tasking
212
         jne   .bll2
213
         ; begin ealex 04.08.05
214
;         in    al,0x61
215
;         and   al,01111111b
41 mikedld 216
;         out   0x61,al
1 ha 217
         ; end ealex 04.08.05
218
.bll1:   in    al,0x60    ; wait for ESC key press
219
         cmp   al,129
220
         jne   .bll1
221
 
222
.bll2:   popad
223
 
224
         ret
225
 
226
uglobal
227
  cpuid_0    dd  0,0,0,0
228
  cpuid_1    dd  0,0,0,0
229
  cpuid_2    dd  0,0,0,0
230
  cpuid_3    dd  0,0,0,0
231
endg
232
 
233
iglobal
234
  firstapp   db  'LAUNCHER   '
235
  char       db  'CHAR    MT '
236
  char2      db  'CHAR2   MT '
237
  bootpath   db  '/KOLIBRI    '
238
  bootpath2  db  0
239
  vmode      db  'VMODE   MDR'
240
  vrr_m      db  'VRR_M      '
241
endg
242
 
243
 
244
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
245
;;                                                                      ;;
246
;;                          32 BIT ENTRY                                ;;
247
;;                                                                      ;;
248
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
249
 
250
align 4
251
 
252
B32:
253
; CLEAR 0x280000-0xF00000
254
 
255
        xor   eax,eax
256
        mov   edi,0x280000
257
        mov   ecx,(0x100000*0xF-0x280000) / 4
258
        cld
259
        rep   stosd
260
; CLEAR 0x80000-0x90000