summaryrefslogtreecommitdiffstats
path: root/arch/x86/bios/memory16.S
blob: e4aef2f256eae8794b3831aac83553dc7ade3d33 (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
/* SPDX-License-Identifier: GPL-2.0-or-later */
/* SPDX-FileCopyrightText: 2009 Juergen Beisert, Pengutronix */

/* This code was inspired by the GRUB2 project. */

/**
 * @file
 * @brief Query the memory layout information from the BIOS
 *
 * Note: This function is running in flat and real mode. Due to some
 * other restrictions it must running from an address space below 0x10000
 */

/**
 * @fn unsigned short bios_get_memsize(void)
 * @brief Does a BIOS call "INT 15H, AH=88H" to get extended memory size
 * @return Extended memory size in KB
 *
 * @note This call is limited to 64 MiB. So, if the system provides more than
 * 64 MiB of memory, still 64 MiB are reported.
 *
 */


	.section .boot.text.bios_get_memsize, "ax"
	.code32
	.globl bios_get_memsize
	.type bios_get_memsize, @function

	.extern prot_to_real

bios_get_memsize:

	pushl %ebp

	call prot_to_real	/* enter real mode */
	.code16

	movb $0x88, %ah
	int $0x15

	movw %ax, %dx

	DATA32	call real_to_prot

	.code32

	movw %dx, %ax

	popl %ebp
	ret

	.size bios_get_memsize, .-bios_get_memsize