From patchwork Wed Jan 4 19:59:49 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Graeme Russ X-Patchwork-Id: 134347 X-Patchwork-Delegate: graeme.russ@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 390B01007D6 for ; Thu, 5 Jan 2012 07:02:07 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2739C283EF; Wed, 4 Jan 2012 21:01:19 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id w3kPUNwx-YBd; Wed, 4 Jan 2012 21:01:18 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D768528430; Wed, 4 Jan 2012 21:00:49 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 77987283F7 for ; Wed, 4 Jan 2012 21:00:46 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cLP-9y0N4q4W for ; Wed, 4 Jan 2012 21:00:46 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-vx0-f172.google.com (mail-vx0-f172.google.com [209.85.220.172]) by theia.denx.de (Postfix) with ESMTPS id 763132842A for ; Wed, 4 Jan 2012 21:00:29 +0100 (CET) Received: by mail-vx0-f172.google.com with SMTP id fk13so13532049vcb.3 for ; Wed, 04 Jan 2012 12:00:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :in-reply-to; bh=hMlZ1napmSxfrv2GiY/GO2ngXKl52WylSB2QzL089II=; b=S04iJhlbOHpwiETgPeTYkZUruW4rdXHkOQQLtCqcZiW0imxML5QiD4HQx6itg1rCxt N61gP9/0nH1rgV9EovVVfdqBOcNPLfixAzgJSwCCgaMQ17/VUDhv8ix725lRgj4yNPSH m+dhdA/e34OXfyqYmcw4qVQO3R0IKv3OrBTKM= Received: by 10.220.39.136 with SMTP id g8mr12262980vce.9.1325707229215; Wed, 04 Jan 2012 12:00:29 -0800 (PST) Received: from localhost.localdomain (d110-32-162-141.sbr801.nsw.optusnet.com.au. [110.32.162.141]) by mx.google.com with ESMTPS id eb3sm33049296vdc.5.2012.01.04.12.00.26 (version=SSLv3 cipher=OTHER); Wed, 04 Jan 2012 12:00:28 -0800 (PST) From: Graeme Russ To: u-boot@lists.denx.de Date: Thu, 5 Jan 2012 06:59:49 +1100 Message-Id: <1325707195-3218-11-git-send-email-graeme.russ@gmail.com> X-Mailer: git-send-email 1.7.5.2.317.g391b14 In-Reply-To: <1325707195-3218-1-git-send-email-graeme.russ@gmail.com> References: <1325707195-3218-1-git-send-email-graeme.russ@gmail.com> In-Reply-To: <1325477374-6417-12-git-send-email-graeme.russ@gmail.com> Subject: [U-Boot] [PATCH v2 11/17] x86: Tweak IDT and GDT for alignment and readability X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Signed-off-by: Graeme Russ Acked-by: Simon Glass --- Changes for v2: - Renamed to better reflect nature of changes arch/x86/cpu/interrupts.c | 2 +- arch/x86/cpu/start16.S | 57 +++++++++++++++++++++++++++++++++++--------- 2 files changed, 46 insertions(+), 13 deletions(-) -- 1.7.5.2.317.g391b14 diff --git a/arch/x86/cpu/interrupts.c b/arch/x86/cpu/interrupts.c index e0958eb..43ec3f8 100644 --- a/arch/x86/cpu/interrupts.c +++ b/arch/x86/cpu/interrupts.c @@ -174,7 +174,7 @@ struct desc_ptr { unsigned short segment; } __packed; -struct idt_entry idt[256] __attribute__((aligned(16))); +struct idt_entry idt[256] __aligned(16); struct desc_ptr idt_ptr; diff --git a/arch/x86/cpu/start16.S b/arch/x86/cpu/start16.S index 33e53cd..cc393ff 100644 --- a/arch/x86/cpu/start16.S +++ b/arch/x86/cpu/start16.S @@ -86,7 +86,11 @@ gdt_ptr: .word 0x20 /* limit (32 bytes = 4 GDT entries) */ .long BOOT_SEG + gdt /* base */ - /* The GDT table ... +/* Some CPUs are picky about GDT alignment... */ +.align 16 +gdt: + /* + * The GDT table ... * * Selector Type * 0x00 NULL @@ -94,17 +98,46 @@ gdt_ptr: * 0x10 32bit code * 0x18 32bit data/stack */ + /* The NULL Desciptor - Mandatory */ + .word 0x0000 /* limit_low */ + .word 0x0000 /* base_low */ + .byte 0x00 /* base_middle */ + .byte 0x00 /* access */ + .byte 0x00 /* flags + limit_high */ + .byte 0x00 /* base_high */ -gdt: - .word 0, 0, 0, 0 /* NULL */ - .word 0, 0, 0, 0 /* unused */ + /* Unused Desciptor - (matches Linux) */ + .word 0x0000 /* limit_low */ + .word 0x0000 /* base_low */ + .byte 0x00 /* base_middle */ + .byte 0x00 /* access */ + .byte 0x00 /* flags + limit_high */ + .byte 0x00 /* base_high */ - .word 0xFFFF /* 4Gb - (0x100000*0x1000 = 4Gb) */ - .word 0 /* base address = 0 */ - .word 0x9B00 /* code read/exec */ - .word 0x00CF /* granularity = 4096, 386 (+5th nibble of limit) */ + /* + * The Code Segment Descriptor: + * - Base = 0x00000000 + * - Size = 4GB + * - Access = Present, Ring 0, Exec (Code), Readable + * - Flags = 4kB Granularity, 32-bit + */ + .word 0xffff /* limit_low */ + .word 0x0000 /* base_low */ + .byte 0x00 /* base_middle */ + .byte 0x9b /* access */ + .byte 0xcf /* flags + limit_high */ + .byte 0x00 /* base_high */ - .word 0xFFFF /* 4Gb - (0x100000*0x1000 = 4Gb) */ - .word 0x0 /* base address = 0 */ - .word 0x9300 /* data read/write */ - .word 0x00CF /* granularity = 4096, 386 (+5th nibble of limit) */ + /* + * The Data Segment Descriptor: + * - Base = 0x00000000 + * - Size = 4GB + * - Access = Present, Ring 0, Non-Exec (Data), Writable + * - Flags = 4kB Granularity, 32-bit + */ + .word 0xffff /* limit_low */ + .word 0x0000 /* base_low */ + .byte 0x00 /* base_middle */ + .byte 0x93 /* access */ + .byte 0xcf /* flags + limit_high */ + .byte 0x00 /* base_high */