summaryrefslogtreecommitdiff
path: root/bootblocks/zimage.s
blob: a58df57e910e6257308a55f3476fbda3cfe27c1f (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
!
! This is a short helper to copy a zImage from high memory to low memory
! then call it.
!

  org	$1000
Start:
  xor	ax,ax
  mov	ds,ax
  mov	es,ax
  mov	ss,ax
  mov	sp,#Start

  mov	di,#8
nextpg:
  mov	cx,#$8000
  mov	ah,#$87
  mov	si,#GDT
  int	$15
  jnc	no_err

  ! If there's an error reset.
  jmpi	$0000,$FFFF

no_err:
  inc	srcaddr
  inc	destaddr
  dec	di
  jnz	nextpg

  ! Call the Image (same as bzImage)
go:

  ! Kill the floppy motor, needed in case the kernel has no floppy driver.
  mov	dx,#0x3f2
  xor	al, al
  outb

  ! Setup required registers and go ...
  mov	ax,#$9000
  mov	bx,#$4000-12	! Fix this to use boot_mem_top
  mov	es,ax
  mov	fs,ax
  mov	gs,ax
  mov	ds,ax
  mov	ss,ax
  mov	sp,bx

  jmpi	0,$9020		! Note SETUPSEG NOT INITSEG

! The global descriptor table.

GDT:
.word	$0000,$0000
.word	$0000,$0000

.word	$0000,$0000
.word	$0000,$0000

.word	$FFFF,$0000
srcaddr:
.word	$9310,$0000

.word	$FFFF,$0000
destaddr:
.word	$9301,$0000

.word	$0000,$0000
.word	$0000,$0000

.word	$0000,$0000
.word	$0000,$0000