OpenCores
URL https://opencores.org/ocsvn/eco32/eco32/trunk

Subversion Repositories eco32

[/] [eco32/] [trunk/] [disk/] [tools/] [shpart/] [shpart.c] - Diff between revs 17 and 258

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 17 Rev 258
Line 13... Line 13...
#define NPE             (SECTOR_SIZE / sizeof(PartEntry))
#define NPE             (SECTOR_SIZE / sizeof(PartEntry))
#define DESCR_SIZE      20
#define DESCR_SIZE      20
 
 
 
 
typedef struct {
typedef struct {
  unsigned long type;
  unsigned int type;
  unsigned long start;
  unsigned int start;
  unsigned long size;
  unsigned int size;
  char descr[DESCR_SIZE];
  char descr[DESCR_SIZE];
} PartEntry;
} PartEntry;
 
 
PartEntry ptr[NPE];
PartEntry ptr[NPE];
 
 
Line 40... Line 40...
 
 
 
 
/**************************************************************/
/**************************************************************/
 
 
 
 
unsigned long getNumber(unsigned char *p) {
unsigned int getNumber(unsigned char *p) {
  return (unsigned long) *(p + 0) << 24 |
  return (unsigned int) *(p + 0) << 24 |
         (unsigned long) *(p + 1) << 16 |
         (unsigned int) *(p + 1) << 16 |
         (unsigned long) *(p + 2) <<  8 |
         (unsigned int) *(p + 2) <<  8 |
         (unsigned long) *(p + 3) <<  0;
         (unsigned int) *(p + 3) <<  0;
}
}
 
 
 
 
void convertPartitionTable(PartEntry *e, int n) {
void convertPartitionTable(PartEntry *e, int n) {
  int i;
  int i;
Line 68... Line 68...
 
 
int main(int argc, char *argv[]) {
int main(int argc, char *argv[]) {
  char *diskName;
  char *diskName;
  FILE *disk;
  FILE *disk;
  unsigned long diskSize;
  unsigned long diskSize;
  unsigned long numSectors;
  unsigned int numSectors;
  unsigned long partLast;
  unsigned int partLast;
  int i, j;
  int i, j;
  char c;
  char c;
 
 
  /* check command line arguments */
  /* check command line arguments */
  if (argc != 2) {
  if (argc != 2) {
Line 88... Line 88...
  }
  }
  fseek(disk, 0, SEEK_END);
  fseek(disk, 0, SEEK_END);
  diskSize = ftell(disk);
  diskSize = ftell(disk);
  numSectors = diskSize / SECTOR_SIZE;
  numSectors = diskSize / SECTOR_SIZE;
  fclose(disk);
  fclose(disk);
  printf("Disk '%s' has %lu (0x%lX) sectors.\n",
  printf("Disk '%s' has %u (0x%X) sectors.\n",
         diskName, numSectors, numSectors);
         diskName, numSectors, numSectors);
  if (numSectors < 32) {
  if (numSectors < 32) {
    error("disk is too small");
    error("disk is too small");
  }
  }
  if (diskSize % SECTOR_SIZE != 0) {
  if (diskSize % SECTOR_SIZE != 0) {
Line 116... Line 116...
    if (ptr[i].type != 0) {
    if (ptr[i].type != 0) {
      partLast = ptr[i].start + ptr[i].size - 1;
      partLast = ptr[i].start + ptr[i].size - 1;
    } else {
    } else {
      partLast = 0;
      partLast = 0;
    }
    }
    printf("%2d %s 0x%08lX 0x%08lX 0x%08lX 0x%08lX ",
    printf("%2d %s 0x%08X 0x%08X 0x%08X 0x%08X ",
           i,
           i,
           ptr[i].type & 0x80000000 ? "*" : " ",
           ptr[i].type & 0x80000000 ? "*" : " ",
           ptr[i].type & 0x7FFFFFFF,
           ptr[i].type & 0x7FFFFFFF,
           ptr[i].start,
           ptr[i].start,
           partLast,
           partLast,

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.