Int 15/AX=E820h 是用来获取系统中的内存映地址描述符的,操作系统常用来获取内存大小.

PS:内存(Memory)可以是我们平时所说的在主板上的内存条,我们称作Base Memory,也可以是毗边
Base Memory 的并作为普通内存扩展的内存.

首先来了解一下相关的数据结构:

Format of Phoenix BIOS system memory map address range descriptor
(BIOS系统内存映射地址描述符格式,通常在英文中被称作Entry,一个Entry描述一种系统内存信息):

Offset  Size    Description    
00h    QWORD   base address    #系统内存块基地址
08h    QWORD   length in bytes #系统内存大小
10h    DWORD   type of address range #内存类型,看下面的(Values for System Memory Map address type )

这个结构块的大小为20

格式:

AX = E820h
EAX = 0000E820h
EDX = 534D4150h ('SMAP')
EBX = continuation value or 00000000h to start at beginning of map
持续值 或者 等于00000000h,以便重map的开头开始scan
ECX = size of buffer for result, in bytes (should be >= 20 bytes)
ES:DI -> buffer for result
Return:

CF clear if successful

EAX = 534D4150h ('SMAP')
ES:DI buffer filled
EBX = next offset from which to copy or 00000000h if all done
ECX = 传送到缓冲区buf的Entry的大小,一般为20个字节,ECX=20
CF set on error
AH = error code (86h) 
Reference:
http://www.ctyme.com/intr/rb-1741.htm
除了Base Memory外,他还返回芯片集定义的系统内存地址空洞,而这些空洞是没有被使用的,是
主板内存映射设备和BIOS所保留的.
Values for System Memory Map address type:
01h    memory, available to OS
02h    reserved, not available (e.g. system ROM, memory-mapped device)
03h    ACPI Reclaim Memory (usable by OS after reading ACPI tables)
04h    ACPI NVS Memory (OS is required to save this memory between NVS
sessions)
other  not defined yet -- treat as Reserved
原理描述:
调用此功能可以从系统某一个地方(这里存放有一个List(列表),这个列表里存放的都是一个个的
Entry)通过设置EBX(20的倍数)的值,然后调用int 0x15就可以讲EBX所指向的Entry拷贝
到ES:DI所指向的内存区)
 


Linux2.4.10-setup.S中关于内存检测(E820h)注释及流程:
首先了解一下empty_zero_page 都存放些什么东西:
Offset Type  Description
------  ----  -----------
0 32 bytes struct screen_info, SCREEN_INFO
ATTENTION, overlaps the following !!!
2 unsigned short EXT_MEM_K, extended memory size in Kb (from int 0x15)
0x20 unsigned short CL_MAGIC, commandline magic number (=0xA33F)
0x22 unsigned short CL_OFFSET, commandline offset
Address of commandline is calculated:
0x90000 + contents of CL_OFFSET
(only taken, when CL_MAGIC = 0xA33F)
0x40 20 bytes struct apm_bios_info, APM_BIOS_INFO
0x80 16 bytes hd0-disk-parameter from intvector 0x41
0x90 16 bytes hd1-disk-parameter from intvector 0x46
 0xa0 16 bytes System description table truncated to 16 bytes.
( struct sys_desc_table_struct )
0xb0 - 0x1df  Free. Add more parameters here if you really need them.
0x1e0 unsigned long ALT_MEM_K, alternative mem check, in Kb

0x1e8 char  number of entries in E820MAP (below)

0x1f1 char  size of setup.S, number of sectors
0x1f2 unsigned short MOUNT_ROOT_RDONLY (if !=0)
0x1f4 unsigned short size of compressed kernel-part in the
(b)zImage-file (in 16 byte units, rounded up)
0x1f6 unsigned short swap_dev (unused AFAIK)
0x1f8 unsigned short RAMDISK_FLAGS
0x1fa unsigned short VGA-Mode (old one)
0x1fc unsigned short ORIG_ROOT_DEV (high=Major, low=minor)
0x1ff char  AUX_DEVICE_INFO
0x200 short jump to start of setup code aka "reserved" field.
0x202 4 bytes  Signature for SETUP-header, ="HdrS"
0x206 unsigned short Version number of header format
Current version is 0x0201...
0x208 8 bytes  (used by setup.S for communication with boot loaders,
look there)
0x210 char  LOADER_TYPE, = 0, old one
else it is set by the loader:
0xTV: T=0 for LILO
1 for Loadlin
2 for bootsect-loader
3 for SYSLINUX
4 for ETHERBOOT
V = version
0x211 char  loadflags:
bit0 = 1: kernel is loaded high (bzImage)
bit7 = 1: Heap and pointer (see below) set by boot
loader.
0x212 unsigned short (setup.S)
0x214 unsigned long KERNEL_START, where the loader started the kernel
0x218 unsigned long INITRD_START, address of loaded ramdisk image
0x21c unsigned long INITRD_SIZE, size in bytes of ramdisk image
0x220 4 bytes  (setup.S)
0x224 unsigned short setup.S heap end pointer
0x2d0 - 0x600  E820MAP
0x800 string, 2K max COMMAND_LINE, the kernel commandline as
copied using CL_OFFSET.
Note: this will be copied once more by setup.c
into a local buffer which is only 256 bytes long.
( #define COMMAND_LINE_SIZE 256 )


loader_ok:
# Get memory size (extended mem, kB)
 xorl %eax, %eax
movl %eax, (0x1e0)

#ifndef STANDARD_MEMORY_BIOS_CALL
movb %al, (E820NR)  # E820NR=0x1e8 number of entries in E820MAP
# Try three different memory detection schemes.  First, try
# e820h, which lets us assemble a memory map, then try e801h,
# which returns a 32-bit memory size, and finally 88h, which
# returns 0-64m
# method E820H:
# the memory map from hell.  e820h returns memory classified into
# a whole bunch of different types, and allows memory holes and
# everything.  We scan through this memory map and build a list
# of the first 32 memory areas, which we return at [E820MAP].
# This is documented at http://www.teleport.com/~acpi/acpihtml/topic245.htm
#define SMAP  0x534d4150
meme820:
xorl %ebx, %ebx   # continuation counter
movw $E820MAP, %di   # point into the whitelist
# so we can have the bios
# directly write into it.
jmpe820:
movl $0x0000e820, %eax  # e820, upper word zeroed
movl $SMAP, %edx   # ascii 'SMAP'
movl $20, %ecx   # size of the e820rec
pushw %ds    # data record.
popw %es
int $0x15    # make the call
jc bail820    # fall to e801 if it fails
 cmpl $SMAP, %eax   # check the return is `SMAP'
jne bail820    # fall to e801 if it fails
# cmpl $1, 16(%di)   # is this usable memory?
# jne again820
 # If this is usable memory, we save it by simply advancing %di by
# sizeof(e820rec).
#
good820:
movb (E820NR), %al   # up to 32 entries
cmpb $E820MAX, %al
jnl bail820
 incb (E820NR)
movw %di, %ax
addw $20, %ax
movw %ax, %di
again820:
cmpl $0, %ebx   # check to see if
jne jmpe820    # %ebx is set to EOF
bail820:


通过上面的汇编指令,就把可用内存的Entry描述块顺序放到了empty_zero_page的
0x2d0 - 0x600  E820MAP
处.那么计算内存大小也就不困难了.
 


Int 15/AX=E801h

reference:http://www.ctyme.com/intr/rb-1739.htm

Phoenix BIOS v4.0 - GET MEMORY SIZE FOR >64M CONFIGURATIONS

AX = E801h

Return:

CF clear if successful
AX = extended memory between 1M and 16M, in K (max 3C00h = 15MB)
BX = extended memory above 16M, in 64K blocks
CX = configured memory 1M to 16M, in K
DX = configured memory above 16M, in 64K blocks
CF set on error
Notes:
Supported by the A03 level (6/14/94) and later XPS P90 BIOSes, as well as
the Compaq Contura, 3/8/93 DESKPRO/i, and 7/26/93 LTE Lite 386 ROM BIOS.
Supported by AMI BIOSes dated 8/23/94 or later. On some systems, the BIOS returns
AX=BX=0000h; in this case, use CX and DX instead of AX and BX. This interface is
used by Windows NT 3.1, OS/2 v2.11/2.20, and is used as a fall-back by newer
versions if AX=E820h is not supported. This function is not used by MS-DOS 6.0
HIMEM.SYS when an EISA machine (for example with parameter /EISA)
(see also MEM F000h:FFD9h), or no Compaq machine was detected, or parameter
/NOABOVE16 was given. 
 
 


 
 
meme801:
stc     # fix to work around buggy
xorw %cx,%cx    # BIOSes which dont clear/set
xorw %dx,%dx    # carry on pass/error of
# e801h memory size call
# or merely pass cx,dx though
# without changing them.
movw $0xe801, %ax
int $0x15
jc mem88
 cmpw $0x0, %cx   # Kludge to handle BIOSes
jne e801usecxdx   # which report their extended
cmpw $0x0, %dx   # memory in AX/BX rather than
jne e801usecxdx   # CX/DX.  The spec I have read
movw %ax, %cx   # seems to indicate AX/BX
movw %bx, %dx   # are more reasonable anyway...
e801usecxdx:
andl $0xffff, %edx   # clear sign extend
shll $6, %edx   # and go from 64k to 1k chunks
movl %edx, (0x1e0)   # store extended memory size
andl $0xffff, %ecx   # clear sign extend
addl %ecx, (0x1e0)   # and add lower memory into
# total size.

BIOS E820 等相关中断相关推荐

  1. Hyper-V 2016 系列教程29 主流品牌服务器的BIOS的虚拟化相关设定

    企业正式环境中服务器的稳定性非常重要正常情况下是要求7*24小时不间断运行的除了硬件的质量外还有就是系统的设定和优化其中BIOS的设定如果设定不当的话也会引起服务器的不稳定希望这个小小的BIOS能引起 ...

  2. SYS/BIOS内存分配相关问题

    问题描述: 需要更改SYS/BIOS的内存分配,不能单纯地更改cmd文件中的地址和数据长度,SYS/BIOS中的地址需要通过更改/新建RTSC Platform文件来进行更改/分配. 解决方案: 情况 ...

  3. 汇编语言--BIOS和DOS中断例程

    ❤️强烈推荐人工智能学习网站❤️ BIOS和DOS提供的中断例程是如何安装到内存中的呢? 1.开机后,CPU一加电,初始化(CS)= 0FFFFH,(IP)= 0,自动从FFFF:0单元开始执行程序. ...

  4. linux内核那些事之E820

    <early boot memory-memblock>中可以看到memblock中的region添加是由E820模块调用e820__memblock_setup()函数将e820_tab ...

  5. e820内存数据处理

    e820参数的存储 在setup.S中, 311 meme820: 312 xorl %ebx, %ebx # continuation counter 313 movw $E820MAP, %di ...

  6. windows无盘启动技术开发之传统BIOS(Legacy BIOS)引导程序开发之一

    by fanxiushu 2023-03-01 转载或引用请注明原始作者. 这个话题可能有点老,UEFI BIOS 已经大量存在,而Legacy BIOS最终会被取代. 但是也是作为无盘启动技术里不可 ...

  7. 汇编语言随笔(13)- 外中断(可屏蔽中断)、实验15

    端口的作用 在PC系统的接口卡和主板上,装有各种接口芯片.这些外设接口芯片内部有若干寄存器,CPU将这些寄存器当作端口来访问.       外设的输入不直接送入内存和CPU,而是送入相关的接口芯片的端 ...

  8. 【整理】BIOS、BootLoader、uboot对比

    bios BIOS是英文"Basic Input Output System"的缩略语,直译过来后中文名称就是"基本输入输出系统".其实,它是一组固化到计算机内 ...

  9. 外中断02 - 零基础入门学习汇编语言70

    第十五章:外中断02 让编程改变世界 Change the world by program 小甲鱼和大家谈谈心 一个帖子引发小甲鱼的反省! 猫姐曾经说过,步子别迈太大,容易扯着蛋! 结果还真蛋疼了- ...

最新文章

  1. “昊论坛”热力来袭!一网打尽【微生物绝对定量】技术特色和应用
  2. 如何给图片赋值_医学数据的变量类型及在SPSS中的赋值方法(医学统计前的重要步骤)——【杏花开医学统计】...
  3. 函数和构造函数的区别
  4. 超牛逼的异步协程爬虫
  5. 树莓派换源、vim更新:树莓派更换国内可用镜像源
  6. Java并发编程艺术读书笔记
  7. 【每日SQL打卡】​​​​​​​​​​​​​​​DAY 7丨好友申请 I :总体通过率【难度简单】
  8. 下载的oracle如何解压,深度概述Ubuntu oracle下载解压
  9. _java5条件阻塞Condition的应用
  10. careercup-递归和动态规划 9.2
  11. ZBrush中的Clip剪切笔刷怎么快速运用
  12. UVa 10673 Play with Floor and Ceil
  13. OpenCV之图像二值化
  14. 华为手机计算机怎么用根号,根号下怎么打_根号怎么打出来华为_根号怎么打出来手机-Guide信息网...
  15. 简单Python爬取链接二手房信息
  16. Java 八皇后游戏
  17. 【2022-New】Flutter doctor 检测报错,Android toolchain - develop for Android devices
  18. 其实大多数人没必要关注iPhone5
  19. python求全排列
  20. 魔兽争霸 php文件,[War3]Fdf文件详解,简单的UI教程演示-by CarlosX

热门文章

  1. 记录一次补丁服务器异常处理的过程
  2. android4.4 systrace,android – 在尝试使用KitKat在Moto X上使用systrace时获得’Permission denied(13)’...
  3. 什么叫做支路_道路上什么是支路和干路
  4. 美通社企业新闻汇总 | 百度英业达合作研发超级AI计算平台;《2019大中华薪资指南》发布...
  5. greasemonkey_使用GreaseMonkey自定义GMail
  6. js 获取中文的拼音首字母
  7. matlab贝叶斯编程代码,bnt 基于matlab的贝叶斯工具箱 各种程序与算法,在 网络编程中作为调用 238万源代码下载- www.pudn.com...
  8. 横河电机收购电网和可再生能源高速控制软件开发商 PXiSE
  9. 86-17农固微观数据
  10. PTA|程序设计类实验辅助教学平台:基础编程题目集:编程题7-2