Ejemplo n.º 1
0
int main(int argc, char**argv) {
#if 1
  create_tests(1e-7);
  mtxmul_tests(1e-7);
  mtxmul_eye_tests(1e-7);
  datamul_tests(1e-7);
  datamul_eye_tests(1e-7);
#endif
  datamul_4_2_tests(1024, 1e-7);

  pass();
  return 0;
}
Ejemplo n.º 2
0
int main(int argc, char**argv) {
#if 1
  create_tests(1e-7);
  mtx_copy(1e-7);
  mtx_diff(1e-1);
  mtx_diff(1e-7);
  mtxmul_tests(1e-7);
  mtxmul_eye_tests(1e-7);
  datamul_tests(1e-7);
  datamul_eye_tests(1e-7);
#endif
  datamul_4_2_tests(1024, 1e-7);
  mtxinverse_tests(3e-5);

  return pass();
}
Ejemplo n.º 3
0
int main(int argc, char *argv[])
{
  int i;
  uint rootino, off;
  struct dirent de;
  char buf[512];
  struct dinode din;

  static_assert(sizeof(int) == 4, "Integers must be 4 bytes!");

  if(argc != 3)
  {
    fprintf(stderr, "Usage: mkfs.xv6 <image name> <test|release>\n");
    exit(1);
  }

  assert((512 % sizeof(struct dinode)) == 0);
  assert((512 % sizeof(struct dirent)) == 0);

  fsfd = open(argv[1], O_RDWR|O_CREAT|O_TRUNC, 0666);
  if(fsfd < 0){
    perror(argv[1]);
    exit(1);
  }

  sb.size = xint(size);
  sb.nblocks = xint(nblocks); // so whole disk is size sectors
  sb.ninodes = xint(ninodes);
  sb.nlog = xint(nlog);

  bitblocks = size/(512*8) + 1;
  usedblocks = ninodes / IPB + 3 + bitblocks;
  freeblock = usedblocks;

  if (0)
  {
    printf("used %d (bit %d ninode %zu) free %u log %u total %d\n", usedblocks,
           bitblocks, ninodes/IPB + 1, freeblock, nlog, nblocks+usedblocks+nlog);
  }

  assert(nblocks + usedblocks + nlog == size);

  for(i = 0; i < nblocks + usedblocks + nlog; i++)
    wsect(i, zeroes);

  memset(buf, 0, sizeof(buf));
  memmove(buf, &sb, sizeof(sb));
  wsect(1, buf);

  rootino = ialloc(T_DIR);
  assert(rootino == ROOTINO);

  bzero(&de, sizeof(de));
  de.d_ino = xshort(rootino);
  strcpy(de.d_name, ".");
  iappend(rootino, &de, sizeof(de));

  bzero(&de, sizeof(de));
  de.d_ino = xshort(rootino);
  strcpy(de.d_name, "..");
  iappend(rootino, &de, sizeof(de));

  if (!strcmp(argv[2], "release"))
  {
    create_fhs(rootino, "coreutils/init");
  }
  else if (!strcmp(argv[2], "test"))
  {
    create_fhs(rootino, "tests/init");
    create_tests(rootino);
  }

  // fix size of root inode dir
  rinode(rootino, &din);
  off = xint(din.size);
  off = ((off/BSIZE) + 1) * BSIZE;
  din.size = xint(off);
  winode(rootino, &din);

  balloc(usedblocks);

  exit(0);
}