Subversion Repositories Kolibri OS

Rev

Rev 90 | Rev 97 | 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
82 halyavin 62
                  org   0x0
1 ha 63
                  jmp   start_of_code
64
 
65
; mike.dld {
90 mario79 66
        org $+0x10000
1 ha 67
db 0
68
dd servetable-0x10000
69
draw_line       dd __sys_draw_line
70
disable_mouse   dd __sys_disable_mouse
71
draw_pointer    dd __sys_draw_pointer
72
drawbar         dd __sys_drawbar
73
putpixel        dd __sys_putpixel
74
; } mike.dld
75
 
77 diamond 76
version           db    'Kolibri OS  version 0.5.3.1      ',13,10,13,10,0
1 ha 77
                  ;dd    endofcode-0x10000
78
 
79
                  ;db   'Boot02'
80
;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
81
include "boot/preboot.inc"
82
;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
83
 
84
preboot_lfb       db    0
85
preboot_bootlog   db    0
86
 
87
 
88
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
89
;;                                                                      ;;
90
;;                      16 BIT INCLUDED FILES                           ;;
91
;;                                                                      ;;
92
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
93
 
7 me_root 94
include "kernel16.inc"
1 ha 95
 
96
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
97
;;                                                                      ;;
98
;;                  SWITCH TO 32 BIT PROTECTED MODE                     ;;
99
;;                                                                      ;;
100
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
101
 
3 halyavin 102
os_data        =  os_data_l-gdts    ; GDTs
103
os_code        =  os_code_l-gdts
1 ha 104
int_code       equ  int_code_l-gdts
105
int_data       equ  int_data_l-gdts
106
tss0sys        equ  tss0sys_l-gdts
107
graph_data     equ  3+graph_data_l-gdts
108
tss0           equ  tss0_l-gdts
109
app_code       equ  3+app_code_l-gdts
110
app_data       equ  3+app_data_l-gdts
111
 
112
 
113
 
114
; CR0 Flags - Protected mode and Paging
115
 
116
        mov     ecx,0x00000001
117
        ;and     ebx,65535
118
        ;cmp     ebx,00100000000000000b ; lfb -> paging
119
        ;jb      no_paging
120
        ;mov     ax,0x0000
121
        ;mov     es,ax
122
        ;mov     al,[es:0x901E]
123
        ;cmp     al,1
124
        ;je      no_paging
125
        ;or      ecx, 0x80000000
126
       ;no_paging:
127
 
128
; Enabling 32 bit protected mode
129
 
130
        sidt    [cs:old_ints_h-0x10000]
131
 
132
        cli                             ; disable all irqs
133
        cld
134
        mov     al,255                  ; mask all irqs
135
        out     0xa1,al
136
        out     0x21,al
137
   l.5: in      al, 0x64                ; Enable A20
138
        test    al, 2
139
        jnz     l.5
140
        mov     al, 0xD1
141
        out     0x64, al
142
   l.6: in      al, 0x64
143
        test    al, 2
144
        jnz     l.6
145
        mov     al, 0xDF
146
        out     0x60, al
147
        lgdt    [cs:gdts-0x10000]       ; Load GDT
148
        mov     eax, cr0                ; Turn on paging // protected mode
149
        or      eax, ecx
150
        and     eax, 10011111b *65536*256 + 0xffffff ; caching enabled
151
        mov     cr0, eax
77 diamond 152
        jmp     $+2
82 halyavin 153
org $+0x10000
1 ha 154
        mov     ax,os_data              ; Selector for os
155
        mov     ds,ax
156
        mov     es,ax
157
        mov     fs,ax
158
        mov     gs,ax
159
        mov     ss,ax
12 halyavin 160
        mov     esp,0x3ec00             ; Set stack
1 ha 161
        jmp     pword os_code:B32       ; jmp to enable 32 bit mode
162
 
163
use32
164
 
165
iglobal
166
  boot_memdetect    db   'Determining amount of memory',0
167
  boot_fonts        db   'Fonts loaded',0
168
  boot_tss          db   'Setting TSSs',0
169
  boot_cpuid        db   'Reading CPUIDs',0
170
  boot_devices      db   'Detecting devices',0
171
  boot_timer        db   'Setting timer',0
172
  boot_irqs         db   'Reprogramming IRQs',0
173
  boot_setmouse     db   'Setting mouse',0
174
  boot_windefs      db   'Setting window defaults',0
175
  boot_bgr          db   'Calculating background',0
176
  boot_resirqports  db   'Reserving IRQs & ports',0
177
  boot_setrports    db   'Setting addresses for IRQs',0
178
  boot_setostask    db   'Setting OS task',0
179
  boot_allirqs      db   'Unmasking all IRQs',0
180
  boot_tsc          db   'Reading TSC',0
181
  boot_pal_ega      db   'Setting EGA/CGA 320x200 palette',0
182
  boot_pal_vga      db   'Setting VGA 640x480 palette',0
183
  boot_mtrr         db   'Setting MTRR',0
184
  boot_tasking      db   'All set - press ESC to start',0
185
endg
186
 
187
iglobal
188
  boot_y dd 10
189
endg
190
 
191
boot_log:
192
         pushad
193
 
194
         mov   edx,esi
195
.bll3:   inc   edx
196
         cmp   [edx],byte 0
197
         jne   .bll3
198
         sub   edx,esi
199
         mov   eax,10*65536
200
         mov   ax,word [boot_y]
201
         add   [boot_y],dword 10
202
         mov   ebx,0xffffff
203
         mov   ecx,esi
204
         mov   edi,1
205
         call  dtext
206
 
207
         mov   [novesachecksum],1000
208
         call  checkEgaCga
209
 
210
         cmp   [preboot_blogesc],byte 1
211
         je    .bll2
212
 
213
         cmp   esi,boot_tasking
214
         jne   .bll2
215
         ; begin ealex 04.08.05
216
;         in    al,0x61
217
;         and   al,01111111b
41 mikedld 218
;         out   0x61,al
1 ha 219
         ; end ealex 04.08.05
220
.bll1:   in    al,0x60    ; wait for ESC key press
221
         cmp   al,129
222
         jne   .bll1
223
 
224
.bll2:   popad
225
 
226
         ret
227
 
228
uglobal
229
  cpuid_0    dd  0,0,0,0
230
  cpuid_1    dd  0,0,0,0
231
  cpuid_2    dd  0,0,0,0
232
  cpuid_3    dd  0,0,0,0
233
endg
234
 
235
iglobal
236
  firstapp   db  'LAUNCHER   '
237
  char       db  'CHAR    MT '
238
  char2      db  'CHAR2   MT '
239
  bootpath   db  '/KOLIBRI    '
240
  bootpath2  db  0
241
  vmode      db  'VMODE   MDR'
242
  vrr_m      db  'VRR_M      '
243
endg
244
 
245
 
246
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
247
;;                                                                      ;;
248
;;                          32 BIT ENTRY                                ;;
249
;;                                                                      ;;
250
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
251
 
252
align 4
253
 
254
B32:
255
; CLEAR 0x280000-0xF00000