	.file	"mem_manage.c"
.globl info_base_info
	.data
	.align 32
	.type	info_base_info, @object
	.size	info_base_info, 48
info_base_info:
	.byte	0
	.zero	7
	.quad	info_base_bootstrap
	.quad	48
	.quad	0
	.zero	16
.globl info_base
	.align 8
	.type	info_base, @object
	.size	info_base, 8
info_base:
	.quad	info_base_bootstrap+48
.globl info_base_len
	.align 8
	.type	info_base_len, @object
	.size	info_base_len, 8
info_base_len:
	.quad	19
.globl free_mem_head
	.align 8
	.type	free_mem_head, @object
	.size	free_mem_head, 8
free_mem_head:
	.quad	info_base_bootstrap
.globl used_mem_head
	.bss
	.align 8
	.type	used_mem_head, @object
	.size	used_mem_head, 8
used_mem_head:
	.zero	8
	.text
.globl init_mm
	.type	init_mm, @function
init_mm:
.LFB2:
	movq	free_mem_head(%rip), %rdx
	movzbl	(%rdx), %eax
	orl	$1, %eax
	movb	%al, (%rdx)
	movq	free_mem_head(%rip), %rdx
	movl	end(%rip), %eax
	cltq
	movq	%rax, 8(%rdx)
	movq	free_mem_head(%rip), %rcx
	movl	end(%rip), %edx
	movl	$41943040, %eax
	subl	%edx, %eax
	cltq
	movq	%rax, 16(%rcx)
	movq	free_mem_head(%rip), %rax
	movq	$0, 24(%rax)
	movq	free_mem_head(%rip), %rax
	movq	$0, 32(%rax)
	movq	free_mem_head(%rip), %rax
	movq	$0, 40(%rax)
	ret
.LFE2:
	.size	init_mm, .-init_mm
.globl alloc
	.type	alloc, @function
alloc:
.LFB3:
	subq	$8, %rsp
.LCFI0:
	movq	%rdi, (%rsp)
	movq	$0, info_base_len(%rip)
	movq	info_base_len(%rip), %rax
	testq	%rax, %rax
	je	.L7
	movl	$0, %eax
	call	fill_info_base
.L7:
	addq	$8, %rsp
	ret
.LFE3:
	.size	alloc, .-alloc
.globl fill_info_base
	.type	fill_info_base, @function
fill_info_base:
.LFB4:
	subq	$24, %rsp
.LCFI1:
	movq	info_base_len(%rip), %rax
	testq	%rax, %rax
	jne	.L16
	movq	free_mem_head(%rip), %rax
	movq	%rax, 16(%rsp)
	jmp	.L11
.L12:
	movq	16(%rsp), %rax
	movq	40(%rax), %rax
	movq	%rax, 16(%rsp)
.L11:
	cmpq	$0, 16(%rsp)
	je	.L13
	movq	16(%rsp), %rax
	movq	16(%rax), %rax
	cmpq	$95, %rax
	jbe	.L12
.L13:
	cmpq	$0, 16(%rsp)
	jne	.L16
	movl	$1, %edi
	call	alloc_page
.L16:
	addq	$24, %rsp
	ret
.LFE4:
	.size	fill_info_base, .-fill_info_base
.globl pop_free_mem
	.type	pop_free_mem, @function
pop_free_mem:
.LFB5:
	ret
.LFE5:
	.size	pop_free_mem, .-pop_free_mem
	.section	.rodata
	.align 8
.LC0:
	.string	"kernel panic, memory page management not implemented"
	.text
.globl alloc_page
	.type	alloc_page, @function
alloc_page:
.LFB6:
	subq	$8, %rsp
.LCFI2:
	movq	%rdi, (%rsp)
	movl	$.LC0, %edi
	movl	$0, %eax
	call	panic
	addq	$8, %rsp
	ret
.LFE6:
	.size	alloc_page, .-alloc_page
.globl chk_page_addr_r
	.type	chk_page_addr_r, @function
chk_page_addr_r:
.LFB7:
	subq	$40, %rsp
.LCFI3:
	movq	%rdi, 16(%rsp)
	movq	%rsi, 8(%rsp)
	movl	%edx, 4(%rsp)
	cmpl	$1, 4(%rsp)
	jne	.L22
	movq	8(%rsp), %rax
	movzbl	(%rax), %eax
	andl	$-128, %eax
	testb	%al, %al
	jne	.L24
.L22:
	cmpl	$0, 4(%rsp)
	jne	.L25
.L24:
	movq	8(%rsp), %rax
	movzbl	(%rax), %eax
	andl	$1, %eax
	movzbl	%al, %eax
	movl	4(%rsp), %edx
	addl	%eax, %edx
	movl	%edx, (%rsp)
	jmp	.L26
.L25:
	movl	4(%rsp), %edx
	movl	%edx, %eax
	sall	$3, %eax
	addl	%edx, %eax
	leal	3(%rax), %ecx
	movl	$511, %eax
	sall	%cl, %eax
	cltq
	movq	%rax, %rsi
	andq	16(%rsp), %rsi
	movl	4(%rsp), %edx
	movl	%edx, %eax
	sall	$3, %eax
	addl	%edx, %eax
	leal	3(%rax), %ecx
	movq	%rsi, %rax
	shrq	%cl, %rax
	movl	%eax, 36(%rsp)
	movl	36(%rsp), %eax
	cltq
	salq	$3, %rax
	addq	8(%rsp), %rax
	movzbl	(%rax), %eax
	andl	$1, %eax
	testb	%al, %al
	je	.L27
	movl	4(%rsp), %ecx
	decl	%ecx
	movl	36(%rsp), %eax
	cltq
	salq	$3, %rax
	addq	8(%rsp), %rax
	movq	(%rax), %rax
	shrq	$12, %rax
	movabsq	$1099511627775, %rdx
	andq	%rdx, %rax
	salq	$12, %rax
	movq	%rax, %rsi
	movq	16(%rsp), %rdi
	movl	%ecx, %edx
	call	chk_page_addr_r
	movl	%eax, (%rsp)
	jmp	.L26
.L27:
	movl	4(%rsp), %eax
	movl	%eax, (%rsp)
.L26:
	movl	(%rsp), %eax
	addq	$40, %rsp
	ret
.LFE7:
	.size	chk_page_addr_r, .-chk_page_addr_r
	.section	.rodata
.LC1:
	.string	"page map size: "
.LC2:
	.string	"\n"
.LC3:
	.string	"checking "
.LC4:
	.string	" level indexes:\n"
	.text
.globl chk_page_addr
	.type	chk_page_addr, @function
chk_page_addr:
.LFB8:
	subq	$56, %rsp
.LCFI4:
	movq	%rdi, 16(%rsp)
	movq	16(%rsp), %rax
	shrq	$12, %rax
	andl	$511, %eax
	movl	%eax, 32(%rsp)
	movq	16(%rsp), %rax
	shrq	$21, %rax
	andl	$511, %eax
	movl	%eax, 36(%rsp)
	movq	16(%rsp), %rax
	shrq	$30, %rax
	andl	$511, %eax
	movl	%eax, 40(%rsp)
	movq	16(%rsp), %rax
	shrq	$39, %rax
	andl	$511, %eax
	movl	%eax, 44(%rsp)
	movq	kernel_page(%rip), %rax
	movq	%rax, 48(%rsp)
	movl	$.LC1, %edi
	call	cons_writes
	movl	$8, %edi
	call	write_numd
	movl	$.LC2, %edi
	call	cons_writes
	movl	$.LC3, %edi
	call	cons_writes
	movq	16(%rsp), %rdi
	call	write_numh
	movl	$.LC4, %edi
	call	cons_writes
	movl	44(%rsp), %eax
	movslq	%eax,%rdi
	call	write_numd
	movl	$.LC2, %edi
	call	cons_writes
	movl	40(%rsp), %eax
	movslq	%eax,%rdi
	call	write_numd
	movl	$.LC2, %edi
	call	cons_writes
	movl	36(%rsp), %eax
	movslq	%eax,%rdi
	call	write_numd
	movl	$.LC2, %edi
	call	cons_writes
	movl	32(%rsp), %eax
	movslq	%eax,%rdi
	call	write_numd
	movl	$.LC2, %edi
	call	cons_writes
	movl	44(%rsp), %eax
	cltq
	salq	$3, %rax
	addq	48(%rsp), %rax
	movq	(%rax), %rdx
	movabsq	$4503599627366400, %rax
	andq	%rdx, %rax
	movq	%rax, 48(%rsp)
	movl	40(%rsp), %eax
	cltq
	salq	$3, %rax
	addq	48(%rsp), %rax
	movq	(%rax), %rdx
	movabsq	$4503599627366400, %rax
	andq	%rdx, %rax
	movq	%rax, 48(%rsp)
	movl	36(%rsp), %eax
	cltq
	salq	$3, %rax
	addq	48(%rsp), %rax
	movq	(%rax), %rax
	andl	$128, %eax
	testq	%rax, %rax
	je	.L31
	movl	$2, 12(%rsp)
	jmp	.L33
.L31:
	movl	36(%rsp), %eax
	cltq
	salq	$3, %rax
	addq	48(%rsp), %rax
	movq	(%rax), %rdx
	movabsq	$4503599627366400, %rax
	andq	%rdx, %rax
	movq	%rax, 48(%rsp)
	movl	32(%rsp), %eax
	cltq
	salq	$3, %rax
	addq	48(%rsp), %rax
	movq	(%rax), %rax
	movl	%eax, %edx
	andl	$1, %edx
	movl	%edx, 12(%rsp)
.L33:
	movl	12(%rsp), %eax
	addq	$56, %rsp
	ret
.LFE8:
	.size	chk_page_addr, .-chk_page_addr
	.section	.rodata
.LC5:
	.string	"\nmemory maps: "
.LC6:
	.string	"\nbase address: "
.LC7:
	.string	"\nlength: "
.LC8:
	.string	"\ntype: "
.LC9:
	.string	"\ndone\n"
.LC10:
	.string	"\nmemory map has zero length\n"
.LC11:
	.string	"No memory map info"
	.text
.globl print_mmap_info
	.type	print_mmap_info, @function
print_mmap_info:
.LFB9:
	subq	$24, %rsp
.LCFI5:
	movq	bootloader_info(%rip), %rax
	movl	(%rax), %eax
	andl	$64, %eax
	testl	%eax, %eax
	je	.L36
	movq	bootloader_info(%rip), %rax
	movl	40(%rax), %eax
	testl	%eax, %eax
	je	.L38
	movl	$.LC5, %edi
	call	cons_writes
	movq	bootloader_info(%rip), %rax
	movl	40(%rax), %eax
	mov	%eax, %edi
	call	write_numd
	movq	bootloader_info(%rip), %rax
	movl	44(%rax), %eax
	mov	%eax, %eax
	movq	%rax, 16(%rsp)
	movl	$0, 12(%rsp)
	jmp	.L40
.L41:
	movl	$.LC6, %edi
	call	cons_writes
	movq	16(%rsp), %rax
	movq	(%rax), %rdi
	call	write_numh
	movl	$.LC7, %edi
	call	cons_writes
	movq	16(%rsp), %rax
	movq	8(%rax), %rdi
	call	write_numd
	movl	$.LC8, %edi
	call	cons_writes
	movq	16(%rsp), %rax
	movl	16(%rax), %eax
	mov	%eax, %edi
	call	write_numd
	movq	16(%rsp), %rax
	subq	$4, %rax
	movl	(%rax), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	0(,%rdx,4), %rax
	leaq	(%rdx,%rax), %rax
	addq	%rax, 16(%rsp)
.L40:
	movl	12(%rsp), %eax
	movq	bootloader_info(%rip), %rdx
	movl	40(%rdx), %edx
	cmpl	%edx, %eax
	jb	.L41
	movl	$.LC9, %edi
	call	cons_writes
	jmp	.L45
.L38:
	movl	$.LC10, %edi
	call	cons_writes
	jmp	.L45
.L36:
	movl	$.LC11, %edi
	call	cons_writes
.L45:
	addq	$24, %rsp
	ret
.LFE9:
	.size	print_mmap_info, .-print_mmap_info
	.comm	info_base_bootstrap,960,32
	.section	.eh_frame,"a",@progbits
.Lframe1:
	.long	.LECIE1-.LSCIE1
.LSCIE1:
	.long	0x0
	.byte	0x1
	.string	"zR"
	.uleb128 0x1
	.sleb128 -8
	.byte	0x10
	.uleb128 0x1
	.byte	0x3
	.byte	0xc
	.uleb128 0x7
	.uleb128 0x8
	.byte	0x90
	.uleb128 0x1
	.align 8
.LECIE1:
.LSFDE1:
	.long	.LEFDE1-.LASFDE1
.LASFDE1:
	.long	.LASFDE1-.Lframe1
	.long	.LFB2
	.long	.LFE2-.LFB2
	.uleb128 0x0
	.align 8
.LEFDE1:
.LSFDE3:
	.long	.LEFDE3-.LASFDE3
.LASFDE3:
	.long	.LASFDE3-.Lframe1
	.long	.LFB3
	.long	.LFE3-.LFB3
	.uleb128 0x0
	.byte	0x4
	.long	.LCFI0-.LFB3
	.byte	0xe
	.uleb128 0x10
	.align 8
.LEFDE3:
.LSFDE5:
	.long	.LEFDE5-.LASFDE5
.LASFDE5:
	.long	.LASFDE5-.Lframe1
	.long	.LFB4
	.long	.LFE4-.LFB4
	.uleb128 0x0
	.byte	0x4
	.long	.LCFI1-.LFB4
	.byte	0xe
	.uleb128 0x20
	.align 8
.LEFDE5:
.LSFDE7:
	.long	.LEFDE7-.LASFDE7
.LASFDE7:
	.long	.LASFDE7-.Lframe1
	.long	.LFB5
	.long	.LFE5-.LFB5
	.uleb128 0x0
	.align 8
.LEFDE7:
.LSFDE9:
	.long	.LEFDE9-.LASFDE9
.LASFDE9:
	.long	.LASFDE9-.Lframe1
	.long	.LFB6
	.long	.LFE6-.LFB6
	.uleb128 0x0
	.byte	0x4
	.long	.LCFI2-.LFB6
	.byte	0xe
	.uleb128 0x10
	.align 8
.LEFDE9:
.LSFDE11:
	.long	.LEFDE11-.LASFDE11
.LASFDE11:
	.long	.LASFDE11-.Lframe1
	.long	.LFB7
	.long	.LFE7-.LFB7
	.uleb128 0x0
	.byte	0x4
	.long	.LCFI3-.LFB7
	.byte	0xe
	.uleb128 0x30
	.align 8
.LEFDE11:
.LSFDE13:
	.long	.LEFDE13-.LASFDE13
.LASFDE13:
	.long	.LASFDE13-.Lframe1
	.long	.LFB8
	.long	.LFE8-.LFB8
	.uleb128 0x0
	.byte	0x4
	.long	.LCFI4-.LFB8
	.byte	0xe
	.uleb128 0x40
	.align 8
.LEFDE13:
.LSFDE15:
	.long	.LEFDE15-.LASFDE15
.LASFDE15:
	.long	.LASFDE15-.Lframe1
	.long	.LFB9
	.long	.LFE9-.LFB9
	.uleb128 0x0
	.byte	0x4
	.long	.LCFI5-.LFB9
	.byte	0xe
	.uleb128 0x20
	.align 8
.LEFDE15:
	.ident	"GCC: (GNU) 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)"
	.section	.note.GNU-stack,"",@progbits
