Changeset 8784


Ignore:
Timestamp:
Mar 14, 2008, 3:03:37 PM (11 years ago)
Author:
andreas
Message:
  • Ignore wrong platform in image loading
  • Excessive debugging of memory management
  • Ignore bogus return value of read()
Location:
branches/win64/lisp-kernel
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/win64/lisp-kernel/area.h

    r8408 r8784  
    171171#ifdef WINDOWS
    172172#ifdef X8664
    173 #define IMAGE_BASE_ADDRESS 0x300000000000LL
     173#define IMAGE_BASE_ADDRESS 0x100000000LL
    174174#endif
    175175#endif
  • branches/win64/lisp-kernel/image.c

    r8707 r8784  
    158158  if (flags != PLATFORM) {
    159159    fprintf(stderr, "Heap image was saved for another platform.\n");
    160     return false;
     160    return true; // false;
    161161  }
    162162  return true;
     
    171171  int
    172172    mem_size = sect->memory_size;
    173   void *addr;
    174173  area *a;
    175174
  • branches/win64/lisp-kernel/memory.c

    r8707 r8784  
    2121#include <ctype.h>
    2222#include <stdio.h>
     23#include <stdlib.h>
    2324#include <stddef.h>
    2425#include <string.h>
     
    2627#include <errno.h>
    2728#include <stdio.h>
     29#include <unistd.h>
    2830#ifdef LINUX
    2931#include <strings.h>
     
    4042{
    4143  char buf[64];
    42   sprintf(buf, "Can't allocate %s of size %d bytes.", pointerp ? "pointer" : "handle", size);
     44  sprintf(buf, "Can't allocate %s of size %Id bytes.", pointerp ? "pointer" : "handle", size);
    4345  Fatal(":   Kernel memory allocation failure.  ", buf);
    4446}
     
    174176                       PAGE_NOACCESS);
    175177  if (!start) {
     178    fprintf(stderr, "Can't get desired heap address at 0x%Ix\n", want);
    176179    start = VirtualAlloc(0,
    177180                         totalsize + heap_segment_size,
     
    204207  mprotect(start, totalsize, PROT_NONE);
    205208#endif
     209  fprintf(stderr, "Reserving heap at 0x%Ix, size 0x%Ix\n", start, totalsize);
    206210  return start;
    207211}
     
    210214CommitMemory (LogicalAddress start, natural len) {
    211215  LogicalAddress rc;
     216  fprintf(stderr, "Committing memory at 0x%Ix, size 0x%Ix\n", start, len);
    212217#ifdef WINDOWS
    213218  rc = VirtualAlloc(start, len, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
     
    235240void
    236241UnCommitMemory (LogicalAddress start, natural len) {
     242  fprintf(stderr, "Uncommitting memory at 0x%Ix, size 0x%Ix\n", start, len);
    237243#ifdef WINDOWS
    238244  int rc = VirtualFree(start, len, MEM_DECOMMIT);
     
    259265MapMemory(LogicalAddress addr, natural nbytes, int protection)
    260266{
     267  fprintf(stderr, "Mapping memory at 0x%Ix, size 0x%Ix\n", addr, nbytes);
    261268#ifdef WINDOWS
    262269  return VirtualAlloc(addr, nbytes, MEM_RESERVE|MEM_COMMIT, MEMPROTECT_RWX);
     
    269276MapMemoryForStack(natural nbytes)
    270277{
     278  fprintf(stderr, "Mapping stack of size 0x%Ix\n", nbytes);
    271279#ifdef WINDOWS
    272280  return VirtualAlloc(0, nbytes, MEM_RESERVE|MEM_COMMIT, MEMPROTECT_RWX);
     
    279287UnMapMemory(LogicalAddress addr, natural nbytes)
    280288{
     289  fprintf(stderr, "Unmapping memory at 0x%Ix, size 0x%Ix\n", addr, nbytes);
    281290#ifdef WINDOWS
    282291  /* Can't MEM_RELEASE here because we only want to free a chunk */
     
    290299ProtectMemory(LogicalAddress addr, natural nbytes)
    291300{
     301  fprintf(stderr, "Protecting memory at 0x%Ix, size 0x%Ix\n", addr, nbytes);
    292302#ifdef WINDOWS
    293303  DWORD oldProtect;
     
    296306  if(!status) {
    297307    wperror("ProtectMemory VirtualProtect");
    298     Bug(NULL, "couldn't protect %d bytes at %x, errno = %d", nbytes, addr, status);
     308    Bug(NULL, "couldn't protect %Id bytes at %x, errno = %d", nbytes, addr, status);
    299309  }
    300310  return status;
     
    304314  if (status) {
    305315    status = errno;
    306     Bug(NULL, "couldn't protect %d bytes at %x, errno = %d", nbytes, addr, status);
     316    Bug(NULL, "couldn't protect %Id bytes at %Ix, errno = %d", nbytes, addr, status);
    307317  }
    308318  return status;
     
    313323UnProtectMemory(LogicalAddress addr, natural nbytes)
    314324{
     325  fprintf(stderr, "Unprotecting memory at 0x%Ix, size 0x%Ix\n", addr, nbytes);
    315326#ifdef WINDOWS
    316327  DWORD oldProtect;
     
    353364                       addr);
    354365#else
    355   size_t count;
    356 
     366  size_t count, total = 0;
     367  size_t opos;
     368
     369  opos = lseek(fd, 0, SEEK_CUR);
    357370  CommitMemory(addr, nbytes);
    358371  lseek(fd, pos, SEEK_SET);
    359   count = read(fd, pos, nbytes);
    360  
    361   return count == nbytes;
     372
     373  //  while (total < nbytes) {
     374    count = read(fd, addr + total, nbytes - total);
     375    //   total += count;
     376    //fprintf(stderr, "read %Id bytes, for a total of %Id out of %Id so far\n", count, total, nbytes);
     377    //if (!(count > 0))
     378    // return false;
     379    //}
     380
     381  lseek(fd, opos, SEEK_SET);
     382
     383  return true;
    362384#endif
    363385#else
  • branches/win64/lisp-kernel/pmcl-kernel.c

    r8732 r8784  
    394394#endif
    395395#ifdef WINDOWS
    396 #define MAXIMUM_MAPPABLE_MEMORY (512<<30LL)
     396#define MAXIMUM_MAPPABLE_MEMORY (512LL<<30LL)
    397397#endif
    398398#else
     
    17821782  }
    17831783  if (image_nil == 0) {
     1784#ifdef WINDOWS
     1785    wperror("Couldn't load lisp heap image");
     1786#else
    17841787    fprintf(stderr, "Couldn't load lisp heap image from %s:\n%s\n", path, strerror(errno));
     1788#endif
    17851789    exit(-1);
    17861790  }
  • branches/win64/lisp-kernel/win64/Makefile

    r8735 r8784  
    2626M4FLAGS = -DWIN64 -DWINDOWS -DX86 -DX8664 -DHAVE_TLS -DEMUTLS
    2727CDEFINES = -DWIN64 -DWINDOWS -D_REENTRANT -DX86 -DX8664 -D_GNU_SOURCE -DHAVE_TLS -DEMUTLS #-DDISABLE_EGC
    28 CDEBUG = -g
     28CDEBUG = -g -Wall
    2929COPT = -O0
    3030
Note: See TracChangeset for help on using the changeset viewer.