wok diff syslinux/stuff/iso2exe/meminfo.S @ rev 15981

syslinux-tools: add meminfo.exe
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Mar 01 19:10:36 2014 +0000 (2014-03-01)
parents
children 45e76a6c05d7
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/syslinux/stuff/iso2exe/meminfo.S	Sat Mar 01 19:10:36 2014 +0000
     1.3 @@ -0,0 +1,209 @@
     1.4 +	.text
     1.5 +	.code16
     1.6 +	.org	0
     1.7 +stacktop	= 0xFFFE
     1.8 +
     1.9 +	.globl	_start
    1.10 +_start:
    1.11 +#if 1
    1.12 +#define EXEADRS(x)	x+0xE0
    1.13 +#define CODESZ 0x200
    1.14 +	decw	%bp			// Magic number: MZ
    1.15 +	popw	%dx
    1.16 +	jmp	start			// Bytes on last page of file
    1.17 +	.word	(CODESZ+511)/512	// Pages in file
    1.18 +	.word	0			// Relocations
    1.19 +	.word	(end_header-_start)/16	// Size of header in paragraphs
    1.20 +	.word	4096			// Minimum extra paragraphs needed
    1.21 +	.word	-1			// Maximum extra paragraphs needed
    1.22 +	.word	(CODESZ+15)/16		// Initial (relative) SS value
    1.23 +	.word	stacktop		// Initial SP value
    1.24 +	.word	0			// Checksum
    1.25 +	.word	EXEADRS(comstart)	// Initial IP value
    1.26 +	.word	0xFFF0			// Initial (relative) CS value
    1.27 +//	.word	0x001C			// File address of relocation table
    1.28 +//	.word	0,0,0			// Overlay number
    1.29 +start:
    1.30 +	pushw	%dx
    1.31 +	cld
    1.32 +	pushw	%cs
    1.33 +	call	comstart2
    1.34 +stop:
    1.35 +	hlt
    1.36 +	jmp	stop
    1.37 +end_header:
    1.38 +#endif
    1.39 +comstart:
    1.40 +	pushw	%cs
    1.41 +	call	comstart2
    1.42 +	int	$0x20
    1.43 +comstart2:
    1.44 +	call	here
    1.45 +here:
    1.46 +	popw	%ax
    1.47 +	subw	$here-_start, %ax
    1.48 +	shrw	$4, %ax
    1.49 +	movw	%cs, %dx
    1.50 +	addw	%ax, %dx
    1.51 +	pushw	%dx
    1.52 +	pushw	$go
    1.53 +	retf
    1.54 +go:
    1.55 +	pushw	%cs
    1.56 +	popw	%ds
    1.57 +	pushw	%cs
    1.58 +	popw	%es
    1.59 +	xorl	%ebx, %ebx
    1.60 +e820lp:
    1.61 +	movl	$0xe820, %eax
    1.62 +	movl	$0x534d4150, %edx
    1.63 +	movl	$20, %ecx
    1.64 +	movw	$buffer, %di
    1.65 +	int	$0x15
    1.66 +	jc	fail
    1.67 +	cmpl	$0x534d4150, %eax
    1.68 +	jne	fail
    1.69 +	cmpl	$20, %ecx
    1.70 +	jc	fail
    1.71 +	pushl	%ebx
    1.72 +	movw	$header_e820, %si
    1.73 +	call	puts64
    1.74 +	movw	$usable, %si
    1.75 +	cmpl	$1, (%di)
    1.76 +	je	show_status
    1.77 +	movw	$acpi_reclaim, %si
    1.78 +	cmpl	$3, (%di)
    1.79 +	je	show_status
    1.80 +	movw	$acpi_nvs, %si
    1.81 +	cmpl	$4, (%di)
    1.82 +	je	show_status
    1.83 +	movw	$reserved, %si
    1.84 +show_status:
    1.85 +	call	putcs
    1.86 +	popl	%ebx
    1.87 +	orl	%ebx, %ebx
    1.88 +	jnz	e820lp
    1.89 +fail:
    1.90 +	movb	$10, %al
    1.91 +	call	putc
    1.92 +	movw	$8*4, %cx
    1.93 +	movw	$buffer, %di
    1.94 +	pushw	%di
    1.95 +	xorw	%ax, %ax
    1.96 +	rep
    1.97 +	  stosw
    1.98 +	movw	$0xE801, %ax
    1.99 +	int	$0x15
   1.100 +	popw	%di
   1.101 +	jc	fail2
   1.102 +	movb	$0x10, 0+2(%di)		// 1M
   1.103 +	movb	$0x10, 32+2(%di)	// 1M
   1.104 +	movb	$0x1, 16+3(%di)		// 16M
   1.105 +	movb	$0x1, 48+3(%di)		// 16M
   1.106 +	incb	%bh
   1.107 +	movw	%bx, 24+2(%di)
   1.108 +	incb	%dh
   1.109 +	movw	%dx, 56+2(%di)
   1.110 +	shrw	$6, %ax		// 1K -> 64K
   1.111 +	jz	e801_configured
   1.112 +	shrw	$6, %cx		// 1K -> 64K
   1.113 +	addw	$0x10, %ax
   1.114 +	addw	$0x10, %cx
   1.115 +	movw	%ax, 8+2(%di)
   1.116 +	movw	%cx, 40+2(%di)
   1.117 +	movw	$extended, %si
   1.118 +	call	pute801
   1.119 +	call	pute801
   1.120 +e801_configured:
   1.121 +	movw	$buffer+32, %di
   1.122 +	movw	$configured, %si
   1.123 +	call	pute801
   1.124 +	call	pute801
   1.125 +fail2:
   1.126 +	movb	$10, %al
   1.127 +	call	putc
   1.128 +	retf
   1.129 +
   1.130 +puts64:
   1.131 +	call	puts
   1.132 +	call	put64
   1.133 +	movw	$middle, %si
   1.134 +	call	putcs
   1.135 +put64:
   1.136 +	movw	$8, %cx
   1.137 +	addw	%cx, %di
   1.138 +	pushw	%di
   1.139 +put64lp:
   1.140 +	decw	%di
   1.141 +	movb	(%di), %al
   1.142 +	shrb	$4, %al
   1.143 +	call	putx
   1.144 +	movb	(%di), %al
   1.145 +	call	putx
   1.146 +	loop	put64lp
   1.147 +	popw	%di
   1.148 +	ret
   1.149 +
   1.150 +pute801:
   1.151 +	pushw	%si
   1.152 +	movw	$header_e801, %si
   1.153 +	call	puts64
   1.154 +	popw	%si
   1.155 +	pushw	%si
   1.156 +	call	putcs
   1.157 +	popw	%si
   1.158 +	ret
   1.159 +putcs:
   1.160 +	movb	$0x20, %al
   1.161 +putslp:
   1.162 +	call	putc
   1.163 +puts:
   1.164 +	lodsb
   1.165 +	orb	%al, %al
   1.166 +	jnz	putslp
   1.167 +	ret
   1.168 +
   1.169 +putx:
   1.170 +	andb	$0xF, %al
   1.171 +	addb	$0x90, %al
   1.172 +	daa
   1.173 +	adcb	$0x40, %al
   1.174 +	daa
   1.175 +putc:
   1.176 +	movw	$7, %bx
   1.177 +	movb	$0xE, %ah
   1.178 +	int	$0x10
   1.179 +	ret
   1.180 +
   1.181 +header_e801:
   1.182 +	.byte	13,10
   1.183 +	.ascii  "BIOS-e801: "
   1.184 +	.byte	0
   1.185 +extended:
   1.186 +	.ascii	"(extended)"
   1.187 +	.byte	0
   1.188 +configured:
   1.189 +	.ascii	"(configured)"
   1.190 +	.byte	0
   1.191 +header_e820:
   1.192 +	.byte	13,10
   1.193 +	.ascii  "BIOS-e820: "
   1.194 +	.byte	0
   1.195 +middle:
   1.196 +	.ascii	"- "
   1.197 +	.byte	0
   1.198 +usable:		// 1
   1.199 +	.ascii	"(usable)"
   1.200 +	.byte	0
   1.201 +reserved:	// 2
   1.202 +	.ascii	"(reserved)"
   1.203 +	.byte	0
   1.204 +acpi_reclaim:	// 3
   1.205 +	.ascii	"(ACPI Reclaim)"
   1.206 +	.byte	0
   1.207 +acpi_nvs:	// 4
   1.208 +	.ascii	"(ACPI NVS)"
   1.209 +	.byte	0
   1.210 +buffer:
   1.211 +	.org	510
   1.212 +	.word	0xAA55