Skip to content

Commit

Permalink
OS/X 64bit build support.
Browse files Browse the repository at this point in the history
  • Loading branch information
captain5050 committed May 6, 2010
1 parent 41db47b commit f0b32ca
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 42 deletions.
8 changes: 4 additions & 4 deletions build/targets/x86_64-osx.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
#
target.arch=ia32
target.os=OSX
target.bootimage.code.address=0x35000000
target.bootimage.data.address=0x31000000
target.bootimage.rmap.address=0x38000000
target.max-mappable.address=0x80000000L
target.bootimage.code.address=0x135000000L
target.bootimage.data.address=0x131000000L
target.bootimage.rmap.address=0x138000000L
target.max-mappable.address=0x200000000L
target.address.size=64
target.obj-ext=.o
target.obj-prefix=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,18 @@ static void pln() {
GenerateInterfaceDeclarations() {
}

static int bootImageDataAddress = 0;
static int bootImageCodeAddress = 0;
static int bootImageRMapAddress = 0;
static long bootImageDataAddress = 0;
static long bootImageCodeAddress = 0;
static long bootImageRMapAddress = 0;
static String outFileName;

private static long decodeLong(String s) {
if(s.endsWith("L")) {
s = s.substring(0, s.length()-1);
}
return Long.decode(s);
}

public static void main(String[] args) throws Exception {

// Process command line directives.
Expand All @@ -101,23 +108,23 @@ public static void main(String[] args) throws Exception {
System.err.println("Error: The -da flag requires an argument");
System.exit(VM.EXIT_STATUS_BOGUS_COMMAND_LINE_ARG);
}
bootImageDataAddress = Integer.decode(args[i]);
bootImageDataAddress = decodeLong(args[i]);
continue;
}
if (args[i].equals("-ca")) { // image address
if (++i == args.length) {
System.err.println("Error: The -ca flag requires an argument");
System.exit(VM.EXIT_STATUS_BOGUS_COMMAND_LINE_ARG);
}
bootImageCodeAddress = Integer.decode(args[i]);
bootImageCodeAddress = decodeLong(args[i]);
continue;
}
if (args[i].equals("-ra")) { // image address
if (++i == args.length) {
System.err.println("Error: The -ra flag requires an argument");
System.exit(VM.EXIT_STATUS_BOGUS_COMMAND_LINE_ARG);
}
bootImageRMapAddress = Integer.decode(args[i]);
bootImageRMapAddress = decodeLong(args[i]);
continue;
}
if (args[i].equals("-out")) { // output file
Expand Down Expand Up @@ -355,14 +362,14 @@ static void emitBootRecordInitialization() {

// Emit virtual machine class interface information.
//
static void emitVirtualMachineDeclarations(int bootImageDataAddress, int bootImageCodeAddress,
int bootImageRMapAddress) {
static void emitVirtualMachineDeclarations(long bootImageDataAddress, long bootImageCodeAddress,
long bootImageRMapAddress) {

// load address for the boot image
//
pln("bootImageDataAddress", Address.fromIntZeroExtend(bootImageDataAddress));
pln("bootImageCodeAddress", Address.fromIntZeroExtend(bootImageCodeAddress));
pln("bootImageRMapAddress", Address.fromIntZeroExtend(bootImageRMapAddress));
pln("bootImageDataAddress", Address.fromLong(bootImageDataAddress));
pln("bootImageCodeAddress", Address.fromLong(bootImageCodeAddress));
pln("bootImageRMapAddress", Address.fromLong(bootImageRMapAddress));

// values in Constants, from Configuration
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,14 @@ public void push(String type, String decl, int index) {
*/
private static Object staticsJunk;

/** Decode an address represented as a string */
private static Address decodeAddress(String s) {
if(s.endsWith("L")) {
s = s.substring(0, s.length()-1);
}
return Address.fromLong(Long.decode(s));
}

/**
* Main.
* @param args command line arguments
Expand Down Expand Up @@ -693,21 +701,21 @@ public static void main(String[] args) {
if (args[i].equals("-ca")) {
if (++i >= args.length)
fail("argument syntax error: Got a -ca flag without a following image address");
bootImageCodeAddress = Address.fromIntZeroExtend(Integer.decode(args[i]));
bootImageCodeAddress = decodeAddress(args[i]);
continue;
}
// image data start address
if (args[i].equals("-da")) {
if (++i >= args.length)
fail("argument syntax error: Got a -da flag without a following image address");
bootImageDataAddress = Address.fromIntZeroExtend(Integer.decode(args[i]));
bootImageDataAddress = decodeAddress(args[i]);
continue;
}
// image ref map start address
if (args[i].equals("-ra")) {
if (++i >= args.length)
fail("argument syntax error: Got a -ra flag without a following image address");
bootImageRMapAddress = Address.fromIntZeroExtend(Integer.decode(args[i]));
bootImageRMapAddress = decodeAddress(args[i]);
continue;
}
// file containing names of types to be placed into bootimage
Expand Down
8 changes: 4 additions & 4 deletions tools/bootloader/jvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -458,8 +458,8 @@ static int createVM(int vmInSeparateThread)
}

if (((uint32_t *) bootRecord->spRegister)[-1] != 0xdeadbabe) {
ERROR_PRINTF("%s: image format error: missing stack sanity check marker (%p)\n",
Me, (void*)(((int *) bootRecord->spRegister)[-1]));
ERROR_PRINTF("%s: image format error: missing stack sanity check marker (0x%08x)\n",
Me, (((int *) bootRecord->spRegister)[-1]));
return 1;
}

Expand Down Expand Up @@ -488,8 +488,8 @@ static int createVM(int vmInSeparateThread)
TRACE_PRINTF(" bootImageCodeEnd: %p\n", (void*)bootRecord->bootImageCodeEnd);
TRACE_PRINTF(" bootImageRMapStart: %p\n", (void*)bootRecord->bootImageRMapStart);
TRACE_PRINTF(" bootImageRMapEnd: %p\n", (void*)bootRecord->bootImageRMapEnd);
TRACE_PRINTF(" initialHeapSize: %d\n", bootRecord->initialHeapSize);
TRACE_PRINTF(" maximumHeapSize: %d\n", bootRecord->maximumHeapSize);
TRACE_PRINTF(" initialHeapSize: %lld\n", (long long int)bootRecord->initialHeapSize);
TRACE_PRINTF(" maximumHeapSize: %lld\n", (long long int)bootRecord->maximumHeapSize);
TRACE_PRINTF(" spRegister: %p\n", (void*)bootRecord->spRegister);
TRACE_PRINTF(" ipRegister: %p\n", (void*)bootRecord->ipRegister);
TRACE_PRINTF(" tocRegister: %p\n", (void*)bootRecord->tocRegister);
Expand Down
12 changes: 6 additions & 6 deletions tools/bootloader/sysMemory.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,15 @@ EXTERNAL void sysFree(void *location)
EXTERNAL void sysCopy(void *dst, const void *src, Extent cnt)
{
SYS_START();
TRACE_PRINTF("%s: sysCopy %p %p %d\n", Me, dst, src, cnt);
TRACE_PRINTF("%s: sysCopy %p %p %d\n", Me, dst, src, (int)cnt);
memcpy(dst, src, cnt);
}

/** Zero a range of memory bytes. */
EXTERNAL void sysZero(void *dst, Extent cnt)
{
SYS_START();
TRACE_PRINTF("%s: sysZero %p %d\n", Me, dst, cnt);
TRACE_PRINTF("%s: sysZero %p %d\n", Me, dst, (int)cnt);
memset(dst, 0x00, cnt);
}

Expand Down Expand Up @@ -275,7 +275,7 @@ EXTERNAL void * sysMemoryReserve(char *start, size_t length,
if (result == (void *) -1){
CONSOLE_PRINTF("%s: sysMemoryReserve %p %zd %d %d %d %ld failed with %d.\n",
Me, start, length, protection, flags, fd, (long)offset, errno);
return (void *) errno;
return (void *)((Address) errno);
}
#endif // RVM_FOR_HARMONY
if (result != NULL) {
Expand Down Expand Up @@ -414,9 +414,9 @@ EXTERNAL int sysGetPageSize()
*/
EXTERNAL void findMappable()
{
int i;
int granularity = 1 << 22; // every 4 megabytes
int max = (1 << 30) / (granularity >> 2);
Address i;
Address granularity = 1 << 22; // every 4 megabytes
Address max = (1L << ((sizeof(Address)*8)-2)) / (granularity >> 2);
int pageSize = sysGetPageSize();
SYS_START();
CONSOLE_PRINTF("Attempting to find mappable blocks of size %d\n", pageSize);
Expand Down
49 changes: 35 additions & 14 deletions tools/bootloader/sysSignal_Intel.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,41 @@
#define __MCSS(context) ((ucontext_t*)context)->uc_mcontext->DARWIN_PREFIX(ss)
#define __MCES(context) ((ucontext_t*)context)->uc_mcontext->DARWIN_PREFIX(es)
#define __MCFS(context) ((ucontext_t*)context)->uc_mcontext->DARWIN_PREFIX(fs)
#define IA32_EAX(context) (__MCSS(context).DARWIN_PREFIX(eax))
#define IA32_EBX(context) (__MCSS(context).DARWIN_PREFIX(ebx))
#define IA32_ECX(context) (__MCSS(context).DARWIN_PREFIX(ecx))
#define IA32_EDX(context) (__MCSS(context).DARWIN_PREFIX(edx))
#define IA32_EDI(context) (__MCSS(context).DARWIN_PREFIX(edi))
#define IA32_ESI(context) (__MCSS(context).DARWIN_PREFIX(esi))
#define IA32_EBP(context) (__MCSS(context).DARWIN_PREFIX(ebp))
#define IA32_ESP(context) (__MCSS(context).DARWIN_PREFIX(esp))
#define IA32_SS(context) (__MCSS(context).DARWIN_PREFIX(ss))
#define IA32_EFLAGS(context) (__MCSS(context).DARWIN_PREFIX(eflags))
#define IA32_EIP(context) (__MCSS(context).DARWIN_PREFIX(eip))
#ifndef __x86_64__
# define IA32_EAX(context) (__MCSS(context).DARWIN_PREFIX(eax))
# define IA32_EBX(context) (__MCSS(context).DARWIN_PREFIX(ebx))
# define IA32_ECX(context) (__MCSS(context).DARWIN_PREFIX(ecx))
# define IA32_EDX(context) (__MCSS(context).DARWIN_PREFIX(edx))
# define IA32_EDI(context) (__MCSS(context).DARWIN_PREFIX(edi))
# define IA32_ESI(context) (__MCSS(context).DARWIN_PREFIX(esi))
# define IA32_EBP(context) (__MCSS(context).DARWIN_PREFIX(ebp))
# define IA32_ESP(context) (__MCSS(context).DARWIN_PREFIX(esp))
# define IA32_EFLAGS(context) (__MCSS(context).DARWIN_PREFIX(eflags))
# define IA32_EIP(context) (__MCSS(context).DARWIN_PREFIX(eip))
# define IA32_DS(context) (__MCSS(context).DARWIN_PREFIX(ds))
# define IA32_ES(context) (__MCSS(context).DARWIN_PREFIX(es))
# define IA32_SS(context) (__MCSS(context).DARWIN_PREFIX(ss))
#else
# define IA32_EAX(context) (__MCSS(context).DARWIN_PREFIX(rax))
# define IA32_EBX(context) (__MCSS(context).DARWIN_PREFIX(rbx))
# define IA32_ECX(context) (__MCSS(context).DARWIN_PREFIX(rcx))
# define IA32_EDX(context) (__MCSS(context).DARWIN_PREFIX(rdx))
# define IA32_EDI(context) (__MCSS(context).DARWIN_PREFIX(rdi))
# define IA32_ESI(context) (__MCSS(context).DARWIN_PREFIX(rsi))
# define IA32_EBP(context) (__MCSS(context).DARWIN_PREFIX(rbp))
# define IA32_ESP(context) (__MCSS(context).DARWIN_PREFIX(rsp))
# define IA32_EFLAGS(context) (__MCSS(context).DARWIN_PREFIX(rflags))
# define IA32_EIP(context) (__MCSS(context).DARWIN_PREFIX(rip))
# define IA32_R8(context) (__MCSS(context).DARWIN_PREFIX(r8))
# define IA32_R9(context) (__MCSS(context).DARWIN_PREFIX(r9))
# define IA32_R10(context) (__MCSS(context).DARWIN_PREFIX(r10))
# define IA32_R11(context) (__MCSS(context).DARWIN_PREFIX(r11))
# define IA32_R12(context) (__MCSS(context).DARWIN_PREFIX(r12))
# define IA32_R13(context) (__MCSS(context).DARWIN_PREFIX(r13))
# define IA32_R14(context) (__MCSS(context).DARWIN_PREFIX(r14))
# define IA32_R15(context) (__MCSS(context).DARWIN_PREFIX(r15))
#endif // __x86_64__
#define IA32_CS(context) (__MCSS(context).DARWIN_PREFIX(cs))
#define IA32_DS(context) (__MCSS(context).DARWIN_PREFIX(ds))
#define IA32_ES(context) (__MCSS(context).DARWIN_PREFIX(es))
#define IA32_FS(context) (__MCSS(context).DARWIN_PREFIX(fs))
#define IA32_GS(context) (__MCSS(context).DARWIN_PREFIX(gs))
#define IA32_TRAPNO(context) (__MCES(context).DARWIN_PREFIX(trapno))
Expand Down Expand Up @@ -484,7 +505,7 @@ EXTERNAL void dumpContext(void *context)
#endif
ERROR_PRINTF("trapno 0x%08x\n", IA32_TRAPNO(context));
ERROR_PRINTF("err 0x%08x\n", IA32_ERR(context));
ERROR_PRINTF("eflags 0x%08x\n", IA32_EFLAGS(context));
ERROR_PRINTF("eflags 0x%08x\n", (int)IA32_EFLAGS(context));
/* null if fp registers haven't been used yet */
#ifndef RVM_FOR_OSX
ERROR_PRINTF("fpregs %p\n", IA32_FPREGS(context));
Expand Down

0 comments on commit f0b32ca

Please sign in to comment.