Subversion Repositories HelenOS

Rev

Rev 110 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 110 Rev 139
Line 25... Line 25...
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
 */
27
 */
28
 
28
 
29
 
29
 
30
#include <arch/boot/memmap.h>
30
#include <arch/boot/memmapasm.h>
31
 
31
 
32
E820_RECORD_SIZE = MEMMAP_E820_RECORD_SIZE
32
E820_RECORD_SIZE = MEMMAP_E820_RECORD_SIZE
33
E820_MAX_RECORDS = MEMMAP_E820_MAX_RECORDS
33
E820_MAX_RECORDS = MEMMAP_E820_MAX_RECORDS
34
E820_SMAP = 0x534d4150
34
E820_SMAP = 0x534d4150
35
 
35
 
36
.global memmap_arch_init
36
.global memmap_arch_init
-
 
37
.global e820counter
-
 
38
.global e820table
-
 
39
.global e801memorysize
37
 
40
 
38
.code16
41
.code16
39
.section K_TEXT_START_2
42
.section K_TEXT_START_2
40
 
43
 
41
memmap_arch_init:
44
memmap_arch_init:
42
	
45
 
43
e820begin:
46
e820begin:
44
	xorl	%ebx,%ebx	# during first call, ebx must be 0
47
	xorl	%ebx,%ebx	# during first call, ebx must be 0
-
 
48
	movw	%bx,%ds
45
	
49
	movw	%bx,%es
46
	movw	$e820table,%di
50
	movw	$e820table,%di
47
	movb	$E820_MAX_RECORDS,(e820counter)
51
	movb	$E820_MAX_RECORDS,(e820counter)
48
e820loop:	
52
e820loop:	
49
	movl	$E820_SMAP,%edx 	# constrol sequence "SMAP"
53
	movl	$E820_SMAP,%edx 	# control sequence "SMAP"
50
	pushw	%ds
-
 
51
	popw	%es		# e820 buffer address
-
 
52
 
54
 
53
	movl	$0xe820,%eax		# service
55
	movl	$0x0000e820,%eax	# service
54
	movl	$E820_RECORD_SIZE,%ecx
56
	movl	$E820_RECORD_SIZE,%ecx
55
	int 	$0x15
57
	int 	$0x15
56
	jc		e820end	
58
	jc	e820err
57
	
-
 
58
	
59
	
59
	cmpl	$E820_SMAP,%eax		# verifying BIOS
60
	cmpl	$E820_SMAP,%eax		# verifying BIOS
60
	jne		e820end
61
	jne	e820err
-
 
62
 
-
 
63
	cmpl	$E820_RECORD_SIZE,%ecx
-
 
64
	jne	e820err			# bad record size - bug in bios
61
	
65
	
62
	movw	%di,%ax		# next record
66
	movw	%di,%ax		# next record
63
	addw	$E820_RECORD_SIZE,%ax
67
	addw	$E820_RECORD_SIZE,%ax
64
	movw	%ax,%di
68
	movw	%ax,%di
65
		
69
		
Line 68... Line 72...
68
	
72
	
69
	cmpl	$0,%ebx	
73
	cmpl	$0,%ebx	
70
	jne	e820loop
74
	jne	e820loop
71
	
75
	
72
e820end:
76
e820end:
73
	
-
 
74
	movb	(e820counter),%al	
77
	movb	$E820_MAX_RECORDS,%al
75
	negb	%al
-
 
76
	addb	$32,%al
78
	subb	(e820counter),%al
77
	movb	%al,(e820counter) # store # of valid entries in e820counter
79
	movb	%al,(e820counter) # store # of valid entries in e820counter
-
 
80
 
-
 
81
	jmp	e801begin
-
 
82
 
-
 
83
e820err:
-
 
84
	movb	$0,(e820counter)
-
 
85
 
-
 
86
# method e801 - get size of memory
-
 
87
 
-
 
88
e801begin:
-
 
89
	xorw	%dx,%dx
-
 
90
	xorw	%cx,%cx
-
 
91
	xorw	%bx,%bx
-
 
92
	movw	$0xe801,%ax
-
 
93
	stc
-
 
94
	int	$0x15
-
 
95
	
-
 
96
	jc	e801end
78
	
97
	
-
 
98
			# fix problem with some BIOSes which use ax:bx rather than cx:dx
-
 
99
	testw	%cx,%cx
-
 
100
	jnz	e801cxdx
-
 
101
	testw	%dx,%dx
-
 
102
	jnz	e801cxdx
-
 
103
 
-
 
104
	movw	%ax,%cx
-
 
105
	movw	%bx,%dx
-
 
106
	
-
 
107
e801cxdx:
-
 
108
	andl	$0xffff,%edx
-
 
109
	shll	$6,%edx
-
 
110
	andl	$0xffff,%ecx
-
 
111
	addl	%ecx,%edx
-
 
112
	addl	$0x0400,%edx  # add lower 1 MB - its not count by e801 method
-
 
113
	movl	%edx,(e801memorysize)		
-
 
114
e801end:
79
	ret
115
	ret
80
 
116
 
-
 
117
	#memory size in 1 kb chunks
-
 
118
e801memorysize:
-
 
119
	.long	0
81
 
120
 
82
e820counter:
121
e820counter:
83
	.byte 0
122
	.byte 0xff
84
		 
123
 
85
e820table:
124
e820table:
86
	.space  (32*E820_RECORD_SIZE),0 # space for 32 records, each E820_RECORD_SIZE bytes long
125
	.space  (32*E820_RECORD_SIZE),0xff # space for 32 records, each E820_RECORD_SIZE bytes long