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

Subversion Repositories open8_urisc

[/] [open8_urisc/] [trunk/] [Open8 Tools/] [open8_src/] [open8_link/] [check.c] - Blame information for rev 261

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 178 jshamlet
 
2
#include <ctype.h>
3
#include <stdio.h>
4
#include <stdlib.h>
5
#include <string.h>
6
 
7
#include "defines.h"
8
#include "main.h"
9
#include "memory.h"
10
#include "files.h"
11
 
12
 
13
 
14
extern struct object_file *obj_first;
15
extern int emptyfill, sms_checksum, snes_rom_mode, snes_rom_speed, smc_status;
16
extern int gb_checksum, gb_complement_check, snes_checksum, snes_mode, cpu_65816;
17
extern int snes_sramsize;
18
 
19
int emptyfill;
20
 
21
 
22
 
23
int check_file_types(void) {
24
 
25
  struct object_file *o;
26
 
27
 
28
  o = obj_first;
29
  while (o != NULL) {
30
    if (strncmp((char *)o->data, "WLAK", 4) == 0)
31
      o->format = WLA_VERSION_OBJ;
32
    else if (strncmp((char *)o->data, "WLAV", 4) == 0)
33
      o->format = WLA_VERSION_LIB;
34
    else {
35
      fprintf(stderr, "CHECK_FILE_TYPES: File \"%s\" is of unknown format (\"%c%c%c%c\").\n", o->name, o->data[0], o->data[1], o->data[2], o->data[3]);
36
      return FAILED;
37
    }
38
    o = o->next;
39
  }
40
 
41
  return SUCCEEDED;
42
}
43
 
44
 
45
int check_headers(void) {
46
 
47
  struct object_file *o;
48
  int x = 0, misc_bits = 0, more_bits = 0;
49
 
50
 
51
  o = obj_first;
52
  while (o != NULL) {
53
    if (o->format == WLA_VERSION_OBJ) {
54
      if (x == 0) {
55
        /* misc bits */
56
        emptyfill = *(o->data + OBJ_EMPTY_FILL);
57
        misc_bits = *(o->data + OBJ_MISC_BITS);
58
        sms_checksum = misc_bits & 1;
59
        snes_rom_mode = misc_bits & 2;
60
        snes_mode = misc_bits & 4;
61
        snes_rom_speed = misc_bits & 8;
62
        gb_checksum = misc_bits & 16;
63
        gb_complement_check = misc_bits & 32;
64
        snes_checksum = misc_bits & 64;
65
        cpu_65816 = misc_bits & 128;
66
        /* more bits */
67
        more_bits = *(o->data + OBJ_MORE_BITS);
68
        smc_status = more_bits & 1;
69
        snes_sramsize = (more_bits>>1) & 3;
70
        x++;
71
      }
72
      else if (emptyfill != *(o->data + OBJ_EMPTY_FILL) || misc_bits != *(o->data + OBJ_MISC_BITS) || more_bits != *(o->data + OBJ_MORE_BITS)) {
73
        fprintf(stderr, "CHECK_HEADERS: The object files are from different projects.\n");
74
        return FAILED;
75
      }
76
    }
77
 
78
    o = o->next;
79
  }
80
 
81
  if (x == 0) {
82
    fprintf(stderr, "CHECK_HEADERS: There's nothing to link.\n");
83
    return FAILED;
84
  }
85
 
86
  return SUCCEEDED;
87
}

powered by: WebSVN 2.1.0

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