summaryrefslogtreecommitdiff
path: root/kernel/usrspace.s
blob: 1d20f716c9043602e42683b46126796d7023803d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
global userspace_init
extern _binary_usrbin_bin_size
extern _binary_usrbin_bin_start
extern tss

userspace_init:
  push ebp
  mov ebp, esp
  push esi
  push edi
  mov ecx, _binary_usrbin_bin_size
  mov esi, _binary_usrbin_bin_start
  mov edi, 0x100000
.loop:
  movsb
  dec ecx
  jz .end
  jmp .loop
.end:
  pop edi
  pop esi
  call usrcall
  pop ebp
  ret

usrcall:
  push ebp
  mov ebp, esp
  cli
  mov ax, 0x23
  mov ds, ax
  mov es, ax
  mov fs, ax
  mov gs, ax
  mov eax, esp
  ; save ESP in the TSS
  mov [tss+4], eax
  push dword 0x23
  push dword 0x00180000
  pushf
  push dword 0x1B
  push dword 0x00100000
  iret
  pop ebp
  ret