xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org
Cc: Juergen Gross <jgross@suse.com>,
	samuel.thibault@ens-lyon.org, wei.liu2@citrix.com
Subject: [PATCH v2 04/22] mini-os: make some memory management related macros usable from assembler
Date: Wed, 24 Aug 2016 12:11:26 +0200	[thread overview]
Message-ID: <1472033504-23180-5-git-send-email-jgross@suse.com> (raw)
In-Reply-To: <1472033504-23180-1-git-send-email-jgross@suse.com>

Especially page table entry definitions are currently not usable from
assembler sources on x86 as the constants are defined with ULL suffix.
Change this by adding the suffix only when the header is included from
a C source.

Hide some C prototypes when in assembler environment.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
---
 include/x86/arch_mm.h | 56 +++++++++++++++++++++++++++++++--------------------
 1 file changed, 34 insertions(+), 22 deletions(-)

diff --git a/include/x86/arch_mm.h b/include/x86/arch_mm.h
index 690a919..2b18b34 100644
--- a/include/x86/arch_mm.h
+++ b/include/x86/arch_mm.h
@@ -29,11 +29,16 @@
 #include <xen/xen.h>
 #if defined(__i386__)
 #include <xen/arch-x86_32.h>
+#define __CONST(x) x ## ULL
 #elif defined(__x86_64__)
 #include <xen/arch-x86_64.h>
+#define __CONST(x) x ## UL
 #else
 #error "Unsupported architecture"
 #endif
+#define CONST(x) __CONST(x)
+#else
+#define CONST(x) x
 #endif
 
 /*
@@ -81,14 +86,16 @@
 #define PRIpte "016llx"
 #ifndef __ASSEMBLY__
 typedef uint64_t pgentry_t;
+#else
+#define PTE(val) .long val; .long 0
 #endif
 
-#define MAX_MEM_SIZE            0x3f000000UL
-#define VIRT_KERNEL_AREA        0x3f000000UL
-#define VIRT_DEMAND_AREA        0x40000000UL
-#define VIRT_HEAP_AREA          0xb0000000UL
+#define MAX_MEM_SIZE            CONST(0x3f000000)
+#define VIRT_KERNEL_AREA        CONST(0x3f000000)
+#define VIRT_DEMAND_AREA        CONST(0x40000000)
+#define VIRT_HEAP_AREA          CONST(0xb0000000)
 
-#define DEMAND_MAP_PAGES        0x6ffffUL
+#define DEMAND_MAP_PAGES        CONST(0x6ffff)
 #define HEAP_PAGES_MAX          ((HYPERVISOR_VIRT_START - VIRT_HEAP_AREA) / \
                                  PAGE_SIZE - 1)
 
@@ -115,15 +122,17 @@ typedef uint64_t pgentry_t;
 #define PRIpte "016lx"
 #ifndef __ASSEMBLY__
 typedef unsigned long pgentry_t;
+#else
+#define PTE(val) .quad val
 #endif
 
-#define MAX_MEM_SIZE            (512ULL << 30)
-#define VIRT_KERNEL_AREA        0x0000008000000000UL
-#define VIRT_DEMAND_AREA        0x0000100000000000UL
-#define VIRT_HEAP_AREA          0x0000200000000000UL
+#define MAX_MEM_SIZE            (CONST(512) << 30)
+#define VIRT_KERNEL_AREA        CONST(0x0000008000000000)
+#define VIRT_DEMAND_AREA        CONST(0x0000100000000000)
+#define VIRT_HEAP_AREA          CONST(0x0000200000000000)
 
-#define DEMAND_MAP_PAGES        0x8000000UL
-#define HEAP_PAGES_MAX          0x8000000UL
+#define DEMAND_MAP_PAGES        CONST(0x8000000)
+#define HEAP_PAGES_MAX          CONST(0x8000000)
 
 #endif
 
@@ -147,16 +156,16 @@ typedef unsigned long pgentry_t;
   (((_a) >> L4_PAGETABLE_SHIFT) & (L4_PAGETABLE_ENTRIES - 1))
 #endif
 
-#define _PAGE_PRESENT  0x001ULL
-#define _PAGE_RW       0x002ULL
-#define _PAGE_USER     0x004ULL
-#define _PAGE_PWT      0x008ULL
-#define _PAGE_PCD      0x010ULL
-#define _PAGE_ACCESSED 0x020ULL
-#define _PAGE_DIRTY    0x040ULL
-#define _PAGE_PAT      0x080ULL
-#define _PAGE_PSE      0x080ULL
-#define _PAGE_GLOBAL   0x100ULL
+#define _PAGE_PRESENT  CONST(0x001)
+#define _PAGE_RW       CONST(0x002)
+#define _PAGE_USER     CONST(0x004)
+#define _PAGE_PWT      CONST(0x008)
+#define _PAGE_PCD      CONST(0x010)
+#define _PAGE_ACCESSED CONST(0x020)
+#define _PAGE_DIRTY    CONST(0x040)
+#define _PAGE_PAT      CONST(0x080)
+#define _PAGE_PSE      CONST(0x080)
+#define _PAGE_GLOBAL   CONST(0x100)
 
 #if defined(__i386__)
 #define L1_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED)
@@ -191,12 +200,14 @@ typedef unsigned long pgentry_t;
 #define L3_P2M_IDX(pfn) (((pfn) >> L2_P2M_SHIFT) & P2M_MASK)
 #define INVALID_P2M_ENTRY (~0UL)
 
+#ifndef __ASSEMBLY__
 void p2m_chk_pfn(unsigned long pfn);
 
 static inline unsigned long p2m_pages(unsigned long pages)
 {
     return (pages + P2M_ENTRIES - 1) >> L1_P2M_SHIFT;
 }
+#endif
 
 #include "arch_limits.h"
 #define PAGE_SIZE       __PAGE_SIZE
@@ -239,7 +250,6 @@ static __inline__ paddr_t machine_to_phys(maddr_t machine)
 	phys = (phys << PAGE_SHIFT) | (machine & ~PAGE_MASK);
 	return phys;
 }
-#endif
 
 #define VIRT_START                 ((unsigned long)&_text)
 
@@ -288,4 +298,6 @@ static __inline__ paddr_t machine_to_phys(maddr_t machine)
 
 pgentry_t *need_pgt(unsigned long addr);
 
+#endif
+
 #endif /* _ARCH_MM_H_ */
-- 
2.6.6


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  parent reply	other threads:[~2016-08-24 10:11 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-24 10:11 [PATCH v2 00/22] mini-os: support HVMlite mode Juergen Gross
2016-08-24 10:11 ` [PATCH v2 01/22] mini-os: resync xen headers Juergen Gross
2016-08-24 10:11 ` [PATCH v2 02/22] mini-os: make dump_regs() work in early boot Juergen Gross
2016-08-24 10:11 ` [PATCH v2 03/22] mini-os: add CONFIG_PARAVIRT Juergen Gross
2016-08-24 10:11 ` Juergen Gross [this message]
2016-08-24 10:11 ` [PATCH v2 05/22] mini-os: add boot code for HVMlite support Juergen Gross
2016-08-24 10:21   ` Samuel Thibault
2016-08-24 10:11 ` [PATCH v2 06/22] mini-os: setup hypercall page for HVMlite Juergen Gross
2016-08-24 10:11 ` [PATCH v2 07/22] mini-os: support hvm_op hypercall Juergen Gross
2016-08-24 10:11 ` [PATCH v2 08/22] mini-os: initialize trap handling for HVMlite Juergen Gross
2016-08-24 10:11 ` [PATCH v2 09/22] mini-os: support HVMlite traps Juergen Gross
2016-08-24 10:11 ` [PATCH v2 10/22] mini-os: make p2m related code depend on CONFIG_PARAVIRT Juergen Gross
2016-08-24 10:11 ` [PATCH v2 11/22] mini-os: add static page tables for virtual kernel area for HVMlite Juergen Gross
2016-08-24 10:11 ` [PATCH v2 12/22] mini-os: add x86 native page table handling Juergen Gross
2016-08-24 10:11 ` [PATCH v2 13/22] mini-os: correct wrong calculation of alloc bitmap size Juergen Gross
2016-08-24 10:11 ` [PATCH v2 14/22] mini-os: add map_frame_virt() function Juergen Gross
2016-08-24 10:11 ` [PATCH v2 15/22] mini-os: setup console interface parameters Juergen Gross
2016-08-24 10:11 ` [PATCH v2 16/22] mini-os: setup xenbus " Juergen Gross
2016-08-24 10:11 ` [PATCH v2 17/22] mini-os: add get_cmdline() function Juergen Gross
2016-08-24 10:11 ` [PATCH v2 18/22] mini-os: map shared info page for HVMlite Juergen Gross
2016-08-24 10:11 ` [PATCH v2 19/22] mini-os: remove using start_info in architecture independent code Juergen Gross
2016-08-24 10:11 ` [PATCH v2 20/22] mini-os: print start of day messages depending on domain type Juergen Gross
2016-08-24 10:11 ` [PATCH v2 21/22] mini-os: get physical memory map Juergen Gross
2016-08-24 10:11 ` [PATCH v2 22/22] mini-os: support idle for HVMlite Juergen Gross
2016-08-24 10:38 ` [PATCH v2 00/22] mini-os: support HVMlite mode Wei Liu

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=1472033504-23180-5-git-send-email-jgross@suse.com \
    --to=jgross@suse.com \
    --cc=minios-devel@lists.xenproject.org \
    --cc=samuel.thibault@ens-lyon.org \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).