All of lore.kernel.org
 help / color / mirror / Atom feed
From: Graeme Russ <graeme.russ@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 12/17] CHECKPATCH: arch/x86/lib/*
Date: Thu,  5 Jan 2012 06:59:50 +1100	[thread overview]
Message-ID: <1325707195-3218-12-git-send-email-graeme.russ@gmail.com> (raw)
In-Reply-To: <1325707195-3218-1-git-send-email-graeme.russ@gmail.com>

Signed-off-by: Graeme Russ <graeme.russ@gmail.com>
---
Changes for v2:
 - None

 arch/x86/lib/bios.S            |  134 +++++++++++++++++++++++++--------------
 arch/x86/lib/realmode_switch.S |   61 +++++++++++--------
 2 files changed, 122 insertions(+), 73 deletions(-)

diff --git a/arch/x86/lib/bios.S b/arch/x86/lib/bios.S
index ce8deb5..239aaa9 100644
--- a/arch/x86/lib/bios.S
+++ b/arch/x86/lib/bios.S
@@ -246,11 +246,9 @@ rm_int1f:
 rm_def_int:
 	iret

-
 	/*
-	 * All interrupt jumptable entries jump to here
-	 * after pushing the interrupt vector number onto the
-	 * stack.
+	 * All interrupt jumptable entries jump to here after pushing the
+	 * interrupt vector number onto the stack.
 	 */
 any_interrupt16:
 	MAKE_BIOS_STACK
@@ -272,7 +270,8 @@ gs	movw	OFFS_VECTOR(%bp), %ax
 	je	Lint_1ah
 	movw	$0xffff, %ax
 	jmp	Lout
-Lint_10h:					/* VGA BIOS services */
+Lint_10h:
+	/* VGA BIOS services */
 	call	bios_10h
 	jmp	Lout
 Lint_11h:
@@ -281,35 +280,42 @@ Lint_11h:
 Lint_12h:
 	call	bios_12h
 	jmp	Lout
-Lint_13h:					/* BIOS disk services */
+Lint_13h:
+	/* BIOS disk services */
 	call	bios_13h
 	jmp	Lout
-Lint_15h:					/* Misc. BIOS services */
+Lint_15h:
+	/* Misc. BIOS services */
 	call	bios_15h
 	jmp	Lout
-Lint_16h:					/* keyboard services */
+Lint_16h:
+	/* keyboard services */
 	call	bios_16h
 	jmp	Lout
-Lint_1ah:					/* PCI bios */
+Lint_1ah:
+	/* PCI bios */
 	call	bios_1ah
 	jmp	Lout
 Lout:
 	cmpw	$0, %ax
 	je	Lhandeled

-	/* Insert code for unhandeled INTs here.
+	/*
+	 * Insert code for unhandeled INTs here.
 	 *
-	 * ROLO prints a message to the console
-	 * (we could do that but then we're in 16bit mode
-	 * so we'll have to get back into 32bit mode
-	 * to use the console I/O routines (if we do this
-	 * we shuls make int 0x10 and int 0x16 work as well))
+	 * ROLO prints a message to the console we could do that but then
+	 * we're in 16bit mode so we'll have to get back into 32bit mode
+	 * to use the console I/O routines (if we do this we should make
+	 * int 0x10 and int 0x16 work as well)
 	 */
 Lhandeled:
 	RESTORE_CALLERS_STACK
-	addw	$2,%sp				/* dump vector number */
-	iret					/* return from interrupt */

+	/* dump vector number */
+	addw	$2,%sp
+
+	/* return from interrupt */
+	iret

 /*
  ************************************************************
@@ -327,22 +333,24 @@ gs	movw	OFFS_AX(%bp), %ax
 	je	Lvid_cfg
 	movw	$0xffff, %ax
 	ret
-Lcur_pos:					/* Read Cursor Position and Size */
+Lcur_pos:
+	/* Read Cursor Position and Size */
 gs	movw	$0, OFFS_CX(%bp)
 gs	movw	$0, OFFS_DX(%bp)
 	xorw	%ax, %ax
 	ret
-Lvid_state:					/* Get Video State */
-gs	movw	$(80 << 8|0x03), OFFS_AX(%bp)	/* 80 columns, 80x25, 16 colors */
+Lvid_state:
+	/* Get Video State - 80 columns, 80x25, 16 colors */
+gs	movw	$(80 << 8|0x03), OFFS_AX(%bp)
 gs	movw	$0, OFFS_BX(%bp)
 	xorw	%ax, %ax
 	ret
-Lvid_cfg:	/* Video Subsystem Configuration (EGA/VGA) */
-gs	movw	$0x10, OFFS_BX(%bp)		/* indicate CGA/MDA/HGA */
+Lvid_cfg:
+	/* Video Subsystem Configuration (EGA/VGA) - indicate CGA/MDA/HGA */
+gs	movw	$0x10, OFFS_BX(%bp)
 	xorw	%ax, %ax
 	ret

-
 /*
  ************************************************************
  * BIOS interrupt 11h -- Equipment determination
@@ -355,7 +363,6 @@ gs	movw	%ax, OFFS_AX(%bp)
 	xorw	%ax, %ax
 	ret

-
 /*
  ************************************************************
  * BIOS	interrupt 12h -- Get Memory Size
@@ -370,16 +377,18 @@ cs	movw	ram_in_64kb_chunks, %ax
 b12_more_than_640k:
 	movw	$0x280, %ax
 b12_return:
-gs	movw	%ax, OFFS_AX(%bp)		/* return number of kilobytes in ax */
+	/* return number of kilobytes in ax */
+gs	movw	%ax, OFFS_AX(%bp)

 gs	movw	OFFS_FLAGS(%bp), %ax
-	andw	$0xfffe, %ax			/* clear carry -- function succeeded */
+
+	/* clear carry -- function succeeded */
+	andw	$0xfffe, %ax
 gs	movw	%ax, OFFS_FLAGS(%bp)

 	xorw	%ax, %ax
 	ret

-
 /*
  ************************************************************
  * BIOS interrupt 13h -- Disk services
@@ -394,12 +403,13 @@ gs	movw	OFFS_AX(%bp), %ax
 	ret
 Lfunc_15h:
 gs	movw	OFFS_AX(%bp), %ax
-	andw	$0xff, %ax			/* return AH=0->drive not present */
+
+	/* return AH=0->drive not present */
+	andw	$0x00ff, %ax
 gs	movw	%ax, OFFS_AX(%bp)
 	xorw	%ax, %ax
 	ret

-
 /*
  ***********************************************************
  * BIOS interrupt 15h -- Miscellaneous services
@@ -417,9 +427,12 @@ gs	movw	OFFS_AX(%bp), %ax
 	movw	$0xffff, %ax
 	ret

-Lfunc_c0h:					/* Return System Configuration Parameters (PS2 only) */
+Lfunc_c0h:
+	/* Return System Configuration Parameters (PS2 only) */
 gs	movw	OFFS_FLAGS(%bp), %ax
-	orw	$1, %ax				/* return carry -- function not supported */
+
+	/* return carry -- function not supported */
+	orw	$1, %ax
 gs	movw	%ax, OFFS_FLAGS(%bp)
 	xorw	%ax, %ax
 	ret
@@ -430,38 +443,56 @@ gs	movw	OFFS_AX(%bp), %ax
 	cmpw	$1, %ax
 	je	Lfunc_e801h
 gs	movw	OFFS_FLAGS(%bp), %ax
-	orw	$1, %ax				/* return carry -- function not supported */
+
+	/* return carry -- function not supported */
+	orw	$1, %ax
 gs	movw	%ax, OFFS_FLAGS(%bp)
 	xorw	%ax, %ax
 	ret

-Lfunc_e801h:					/* Get memory size for >64M Configurations */
+Lfunc_e801h:
+	/* Get memory size for >64M Configurations */
 cs	movw	ram_in_64kb_chunks, %ax
 	cmpw	$0x100, %ax
 	ja	e801_more_than_16mb
-	shlw	$6, %ax				/* multiply by 64 */
-	subw	$0x400, %ax			/* 1st meg does not count */

-gs	movw	%ax, OFFS_AX(%bp)		/* return memory size between 1M and 16M in 1kb chunks in AX and CX */
+	/* multiply by 64 */
+	shlw	$6, %ax
+
+	/* 1st meg does not count */
+	subw	$0x400, %ax
+
+	/* return memory size between 1M and 16M in 1kb chunks in AX and CX */
+gs	movw	%ax, OFFS_AX(%bp)
 gs	movw	%ax, OFFS_CX(%bp)
-gs	movw	$0, OFFS_BX(%bp)		/* set BX and DX to 0*/
+
+	/* set BX and DX to 0*/
+gs	movw	$0, OFFS_BX(%bp)
 gs	movw	$0, OFFS_DX(%bp)
 gs	movw	OFFS_FLAGS(%bp), %ax
-	andw	$0xfffe, %ax			/* clear carry -- function succeeded */
+
+	/* clear carry -- function succeeded */
+	andw	$0xfffe, %ax
 gs	movw	%ax, OFFS_FLAGS(%bp)
 	xorw	%ax, %ax
 	ret

 e801_more_than_16mb:
-	subw	$0x100, %ax			/* subtract 16MB */
+	/* subtract 16MB */
+	subw	$0x100, %ax

-gs	movw	$0x3c00, OFFS_AX(%bp)		/* return 0x3c00 (16MB-1MB) in AX and CX */
+	/* return 0x3c00 (16MB-1MB) in AX and CX */
+gs	movw	$0x3c00, OFFS_AX(%bp)
 gs	movw	$0x3c00, OFFS_CX(%bp)
-gs	movw	%ax, OFFS_BX(%bp)		/* set BX and DX to number of 64kb chunks above 16MB */
+
+	/* set BX and DX to number of 64kb chunks above 16MB */
+gs	movw	%ax, OFFS_BX(%bp)
 gs	movw	%ax, OFFS_DX(%bp)

 gs	movw	OFFS_FLAGS(%bp), %ax
-	andw	$0xfffe, %ax			/* clear carry -- function succeeded */
+
+	/* clear carry -- function succeeded */
+	andw	$0xfffe, %ax
 gs	movw	%ax, OFFS_FLAGS(%bp)
 	xorw	%ax, %ax
 	ret
@@ -473,18 +504,22 @@ cs	movw	ram_in_64kb_chunks, %ax
 	movw	$0x100, %ax
 b88_not_more_than16:
 	shlw	$6, %ax
-	subw	$0x400, %ax			/* 1st meg does not count */

-gs	movw	%ax, OFFS_AX(%bp)		/* return number of kilobytes between 16MB and 16MB in ax */
+	/* 1st meg does not count */
+	subw	$0x400, %ax
+
+	/* return number of kilobytes between 16MB and 16MB in ax */
+gs	movw	%ax, OFFS_AX(%bp)

 gs	movw	OFFS_FLAGS(%bp), %ax
-	andw	$0xfffe, %ax			/* clear carry -- function succeeded */
+
+	/* clear carry -- function succeeded */
+	andw	$0xfffe, %ax
 gs	movw	%ax, OFFS_FLAGS(%bp)

 	xorw	%ax, %ax
 	ret

-
 /*
  ************************************************************
  * BIOS interrupt 16h -- keyboard services
@@ -498,7 +533,8 @@ gs	movw	OFFS_AX(%bp), %ax
 	movw	$0xffff, %ax
 	ret
 Lfunc_03h:
-	xorw	%ax, %ax			/* do nothing -- function not supported */
+	/* do nothing -- function not supported */
+	xorw	%ax, %ax
 	ret

 /*
@@ -514,7 +550,9 @@ gs	movw	OFFS_AX(%bp), %ax
 	ret
 Lfunc_b1h:
 	call	realmode_pci_bios
-	xorw	%ax, %ax			/* do nothing -- function not supported */
+
+	/* do nothing -- function not supported */
+	xorw	%ax, %ax
 	ret


diff --git a/arch/x86/lib/realmode_switch.S b/arch/x86/lib/realmode_switch.S
index 7ee709a..c4c4c43 100644
--- a/arch/x86/lib/realmode_switch.S
+++ b/arch/x86/lib/realmode_switch.S
@@ -44,12 +44,13 @@
  *	e40 ss;
  */

-#define a32		.byte 0x67;		/* address size prefix 32 */
-#define o32		.byte 0x66;		/* operand size prefix 32 */
+#define a32		.byte 0x67;	/* address size prefix 32 */
+#define o32		.byte 0x66;	/* operand size prefix 32 */

 .section .realmode, "ax"
 .code16
-						/* 16bit protected mode code here */
+
+	/* 16bit protected mode code here */
 .globl realmode_enter
 realmode_enter:
 o32	pusha
@@ -69,20 +70,23 @@ o32	pushf
 	movw	%ax, %gs

 	lidt	realmode_idt_ptr
-	movl	%cr0, %eax			/* Go back into real mode by */
-	andl	$0x7ffffffe, %eax		/* clearing PE to 0 */
+	/* Go back into real mode by clearing PE to 0 */
+	movl	%cr0, %eax
+	andl	$0x7ffffffe, %eax
 	movl	%eax, %cr0
-	ljmp	$0x0,$do_realmode		/* switch to real mode */

-do_realmode:					/* realmode code from here */
+	/* switch to real mode */
+	ljmp	$0x0,$do_realmode
+
+do_realmode:
+	/* realmode code from here */
 	movw	%cs,%ax
 	movw	%ax,%ds
 	movw	%ax,%es
 	movw	%ax,%fs
 	movw	%ax,%gs

-						/* create a temporary stack */
-
+	/* create a temporary stack */
 	movw	$0xc0, %ax
 	movw	%ax, %ss
 	movw	$0x200, %ax
@@ -114,26 +118,29 @@ o32	popf
 	popw	%ss
 	movl	%eax, %esp
 cs	movl	temp_eax, %eax
-	wbinvd					/* self-modifying code,
-						 * better flush the cache */
+
+	/* self-modifying code, better flush the cache */
+	wbinvd

 	.byte	0x9a				/* lcall */
 temp_ip:
 	.word	0				/* new ip */
 temp_cs:
 	.word	0				/* new cs */
+
 realmode_ret:
-						/* save eax, esp and ss */
+	/* save eax, esp and ss */
 cs	movl	%eax, saved_eax
 	movl	%esp, %eax
 cs	movl	%eax, saved_esp
 	movw	%ss, %ax
 cs	movw	%ax, saved_ss

-	/* restore the stack, note that we set sp to 0x244;
+	/*
+	 * restore the stack, note that we set sp to 0x244;
 	 * pt_regs is 0x44 bytes long and we push the structure
-	 * backwards on to the stack, bottom first */
-
+	 * backwards on to the stack, bottom first
+	 */
 	movw	$0xc0, %ax
 	movw	%ax, %ss
 	movw	$0x244, %ax
@@ -169,12 +176,15 @@ cs	movw	temp_ip, %ax
 	pushl	%ebx

 o32 cs	lidt	saved_idt
-o32 cs	lgdt	saved_gdt			/* Set GDTR */
+o32 cs	lgdt	saved_gdt

-	movl	%cr0, %eax			/* Go back into protected mode */
-	orl	$1,%eax	/* reset PE to 1 */
+	/* Go back into protected mode reset PE to 1 */
+	movl	%cr0, %eax
+	orl	$1,%eax
 	movl	%eax, %cr0
-	jmp	next_line			/* flush prefetch queue */
+
+	/* flush prefetch queue */
+	jmp	next_line
 next_line:
 	movw	$return_ptr, %ax
 	movw	%ax,%bp
@@ -182,12 +192,13 @@ o32 cs	ljmp	*(%bp)

 .code32
 protected_mode:
-	movl	$0x18,%eax			/* reload GDT[3] */
-	movw	%ax,%fs				/* reset FS */
-	movw	%ax,%ds				/* reset DS */
-	movw	%ax,%gs				/* reset GS */
-	movw	%ax,%es				/* reset ES */
-	movw	%ax,%ss				/* reset SS */
+	/* Reload segment registers */
+	movl	$0x18, %eax
+	movw	%ax, %fs
+	movw	%ax, %ds
+	movw	%ax, %gs
+	movw	%ax, %es
+	movw	%ax, %ss
 	movl	saved_protected_mode_esp, %eax
 	movl	%eax, %esp
 	popf
--
1.7.5.2.317.g391b14

  parent reply	other threads:[~2012-01-04 19:59 UTC|newest]

Thread overview: 87+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-02  4:09 [U-Boot] [PATCH 00/17] x86: Rework of board init code (plus support patches) Graeme Russ
2012-01-02  4:09 ` [U-Boot] [PATCH 01/17] x86: Import glibc memcpy implementation Graeme Russ
2012-01-04  5:18   ` Simon Glass
2012-01-04 19:59   ` [U-Boot] [PATCH v2 " Graeme Russ
2012-01-04 19:59     ` [U-Boot] [PATCH v2 02/17] x86: Speed up copy-to-RAM and clear BSS operations Graeme Russ
2012-01-04 20:04       ` Graeme Russ
2012-01-12  4:45       ` Simon Glass
2012-01-04 19:59     ` [U-Boot] [PATCH v2 03/17] x86: Remove GDR related magic numbers Graeme Russ
2012-01-07 22:05       ` Simon Glass
2012-01-12  4:46       ` Simon Glass
2012-01-04 19:59     ` [U-Boot] [PATCH v2 04/17] x86: Rework Global Descriptor Table loading Graeme Russ
2012-01-12  4:47       ` Simon Glass
2012-01-04 19:59     ` [U-Boot] [PATCH v2 05/17] x86: Simplify Flash-to-RAM code execution transition Graeme Russ
2012-01-12  4:48       ` Simon Glass
2012-01-04 19:59     ` [U-Boot] [PATCH v2 06/17] x86: Rework relocation calculations Graeme Russ
2012-01-12  4:49       ` Simon Glass
2012-01-04 19:59     ` [U-Boot] [PATCH v2 07/17] x86: Use fs for global data Graeme Russ
2012-01-12  4:51       ` Simon Glass
2012-01-04 19:59     ` [U-Boot] [PATCH v2 08/17] x86: Set GD_FLG_RELOC after entering in-RAM copy of U-Boot Graeme Russ
2012-01-12  4:51       ` Simon Glass
2012-01-04 19:59     ` [U-Boot] [PATCH v2 09/17] x86: Create weak init_cache() and default enable_caches() functions Graeme Russ
2012-01-12  4:55       ` Simon Glass
2012-01-04 19:59     ` [U-Boot] [PATCH v2 10/17] x86: Allow cache before copy to RAM Graeme Russ
2012-01-12  4:56       ` Simon Glass
2012-01-04 19:59     ` [U-Boot] [PATCH v2 11/17] x86: Tweak IDT and GDT for alignment and readability Graeme Russ
2012-01-12  5:00       ` Simon Glass
2012-01-04 19:59     ` Graeme Russ [this message]
2012-01-12  5:01       ` [U-Boot] [PATCH v2 12/17] CHECKPATCH: arch/x86/lib/* Simon Glass
2012-01-04 19:59     ` [U-Boot] [PATCH v2 13/17] x86: Move do_go_exec() out of board.c Graeme Russ
2012-01-12  5:01       ` Simon Glass
2012-01-04 19:59     ` [U-Boot] [PATCH v2 14/17] x86: Move setup_pcat_compatibility() " Graeme Russ
2012-01-12  5:02       ` Simon Glass
2012-01-04 19:59     ` [U-Boot] [PATCH v2 15/17] x86: Move relocation code " Graeme Russ
2012-01-07 22:15       ` Simon Glass
2012-01-08  9:04         ` Graeme Russ
2012-01-08 17:59           ` Simon Glass
2012-01-12  5:03       ` Simon Glass
2012-01-04 19:59     ` [U-Boot] [PATCH v2 16/17] x86: Split init functions " Graeme Russ
2012-01-12  5:03       ` Simon Glass
2012-01-04 19:59     ` [U-Boot] [PATCH v2 17/17] x86: Convert board_init_f_r to a processing loop Graeme Russ
2012-01-07 22:21       ` Simon Glass
2012-01-08  9:10         ` Graeme Russ
2012-01-08 18:01           ` Simon Glass
2012-01-12  5:04       ` Simon Glass
2012-01-12  4:44     ` [U-Boot] [PATCH v2 01/17] x86: Import glibc memcpy implementation Simon Glass
2012-01-02  4:09 ` [U-Boot] [PATCH 02/17] x86: Speed up copy-to-RAM and clear BSS operations Graeme Russ
2012-01-04  5:21   ` Simon Glass
2012-01-04 10:04     ` Graeme Russ
2012-01-02  4:09 ` [U-Boot] [PATCH 03/17] x86: Remove GDR related magic numbers Graeme Russ
2012-01-04  5:23   ` Simon Glass
2012-01-04 10:20     ` Graeme Russ
2012-01-02  4:09 ` [U-Boot] [PATCH 04/17] x86: Rework Global Descriptor Table loading Graeme Russ
2012-01-04  5:24   ` Simon Glass
2012-01-04 10:30     ` Graeme Russ
2012-01-02  4:09 ` [U-Boot] [PATCH 05/17] x86: Simplify Flash-to-RAM code execution transition Graeme Russ
2012-01-04  5:28   ` Simon Glass
2012-01-04 10:59     ` Graeme Russ
2012-01-02  4:09 ` [U-Boot] [PATCH 06/17] x86: Rework relocation calcuations Graeme Russ
2012-01-04  5:30   ` Simon Glass
2012-01-02  4:09 ` [U-Boot] [PATCH 07/17] x86: Use fs for global data Graeme Russ
2012-01-04  5:36   ` Simon Glass
2012-01-04 11:14     ` Graeme Russ
2012-01-02  4:09 ` [U-Boot] [PATCH 08/17] x86: Set GD_FLG_RELOC after entering in-RAM copy of U-Boot Graeme Russ
2012-01-04  5:37   ` Simon Glass
2012-01-02  4:09 ` [U-Boot] [PATCH 09/17] x86: Create weak init_cache() function Graeme Russ
2012-01-04  5:38   ` Simon Glass
2012-01-04 11:25     ` Graeme Russ
2012-01-02  4:09 ` [U-Boot] [PATCH 10/17] x86: Allow cache before copy to RAM Graeme Russ
2012-01-04  5:40   ` Simon Glass
2012-01-04 11:29     ` Graeme Russ
2012-01-02  4:09 ` [U-Boot] [PATCH 11/17] CHECKPATCH: arch/x86/cpu/* Graeme Russ
2012-01-04  5:42   ` Simon Glass
2012-01-04 11:35     ` Graeme Russ
2012-01-02  4:09 ` [U-Boot] [PATCH 12/17] CHECKPATCH: arch/x86/lib/* Graeme Russ
2012-01-04  5:47   ` Simon Glass
2012-01-02  4:09 ` [U-Boot] [PATCH 13/17] x86: Move do_go_exec() out of board.c Graeme Russ
2012-01-04  5:48   ` Simon Glass
2012-01-02  4:09 ` [U-Boot] [PATCH 14/17] x86: Move setup_pcat_compatibility() " Graeme Russ
2012-01-04  5:48   ` Simon Glass
2012-01-04 11:38     ` Graeme Russ
2012-01-02  4:09 ` [U-Boot] [PATCH 15/17] x86: Move relocation code " Graeme Russ
2012-01-02  4:09 ` [U-Boot] [PATCH 16/17] x86: Simplify board.c Graeme Russ
2012-01-04  5:51   ` Simon Glass
2012-01-04 11:50     ` Graeme Russ
2012-01-02  4:09 ` [U-Boot] [PATCH 17/17] x86: Tweak initialisation procedure Graeme Russ
2012-01-04  5:52   ` Simon Glass
2012-01-04 12:02     ` Graeme Russ

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1325707195-3218-12-git-send-email-graeme.russ@gmail.com \
    --to=graeme.russ@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.