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

Subversion Repositories or1k

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /
    from Rev 1636 to Rev 1637
    Reverse comparison

Rev 1636 → Rev 1637

/trunk/or1ksim/cpu/common/parse.h
38,4 → 38,4
char *strstrip (char *dst, const char *src, int n);
 
/* Loads file to memory starting at address startaddr and returns freemem. */
unsigned long loadcode(char *filename, oraddr_t startaddr, oraddr_t virtphy_transl);
uint32_t loadcode(char *filename, oraddr_t startaddr, oraddr_t virtphy_transl);
/trunk/or1ksim/cpu/common/parse.c
33,7 → 33,10
#include "abstract.h"
#include "dmmu.h"
#include "coff.h"
 
#define OR32_TYPES
#include "elf.h"
 
#include "debug_unit.h"
#include "opcode/or32.h"
#include "parse.h"
57,7 → 60,7
static oraddr_t transl_table;
 
/* Used to signal whether during loading of programs a translation fault occured. */
static unsigned long transl_error;
static uint32_t transl_error;
 
char *
stripwhite (string)
144,12 → 147,12
#if IMM_STATS
int bcnt[33][3] = {0};
int bsum[3] = {0};
unsigned long movhi = 0;
uint32_t movhi = 0;
 
int bits (unsigned long val) {
int bits (uint32_t val) {
int i = 1;
if (!val) return 0;
while (val != 0 && (signed long)val != -1) {i++; val = (signed long)val >> 1;}
while (val != 0 && (int32_t)val != -1) {i++; val = (int32_t)val >> 1;}
return i;
}
 
245,7 → 248,7
FILE *inputfs;
char inputbuf[4];
uint32_t insn;
signed long sectsize;
int32_t sectsize;
COFF_AOUTHDR coffaouthdr;
struct COFF_scnhdr coffscnhdr;
int len;
270,7 → 273,7
}
while(sections--) {
long scnhdr_pos = sizeof(struct COFF_filehdr) + sizeof(coffaouthdr)
uint32_t scnhdr_pos = sizeof(struct COFF_filehdr) + sizeof(coffaouthdr)
+ sizeof(struct COFF_scnhdr) * firstthree;
if (fseek(inputfs, scnhdr_pos, SEEK_SET) == -1) {
fclose(inputfs);
334,10 → 337,10
if (len == 2)
{
fseek(inputfs, -2, SEEK_CUR);
debug(8,"readfile_coff: %lx 0x%x \n", sectsize, insn >> 16);
debug(8,"readfile_coff: %"PRIx32" 0x%x \n", sectsize, insn >> 16);
}
else
debug(8,"readfile_coff: %lx 0x%x \n", sectsize, insn);
debug(8,"readfile_coff: %"PRIx32" 0x%x \n", sectsize, insn);
addprogram (freemem, insn, &breakpoint);
sectsize -= len;
}
359,12 → 362,12
 
/* Load symbols from big-endian COFF file. */
 
void readsyms_coff(char *filename, unsigned long symptr, long syms)
void readsyms_coff(char *filename, uint32_t symptr, uint32_t syms)
{
FILE *inputfs;
struct COFF_syment coffsymhdr;
int count = 0;
long nsyms = syms;
uint32_t nsyms = syms;
if (!(inputfs = fopen(filename, "r"))) {
perror("readsyms_coff");
exit(1);
393,12 → 396,12
if(COFF_SHORT_H(coffsymhdr.e_type) & COFF_N_TMASK & COFF_STYP_TEXT) {
#endif
 
if (*((unsigned long *)coffsymhdr.e.e.e_zeroes)) {
if (*((uint32_t *)coffsymhdr.e.e.e_zeroes)) {
if (strlen(coffsymhdr.e.e_name) && strlen(coffsymhdr.e.e_name) < 9)
add_label(COFF_LONG_H(coffsymhdr.e_value), coffsymhdr.e.e_name);
debug(8, "[%i] Symbol: %s,", count++, coffsymhdr.e.e_name);
} else {
long fpos = ftell (inputfs);
uint32_t fpos = ftell (inputfs);
if (fseek(inputfs, symptr + nsyms * COFF_SYMESZ + COFF_LONG_H(coffsymhdr.e.e.e_offset), SEEK_SET) == 0) {
char tmp[33], *s = &tmp[0];
438,12 → 441,12
struct elf32_phdr *elf_phdata = NULL;
struct elf32_shdr *elf_spnt, *elf_shdata;
struct elf32_sym *sym_tbl = (struct elf32_sym *)0;
unsigned long syms = 0;
uint32_t syms = 0;
char *str_tbl = (char *)0;
char *s_str = (char *)0;
int breakpoint = 0;
unsigned long inputbuf;
unsigned long padd;
uint32_t inputbuf;
uint32_t padd;
uint32_t insn;
int i, j, sectsize, len;
 
569,7 → 572,7
else
PRINTF("Section: noname,");
PRINTF(" vaddr: 0x%.8lx,", ELF_LONG_H(elf_spnt->sh_addr));
PRINTF(" paddr: 0x%.8lx,", padd);
PRINTF(" paddr: 0x%"PRIx32, padd);
PRINTF(" offset: 0x%.8lx,", ELF_LONG_H(elf_spnt->sh_offset));
PRINTF(" size: 0x%.8lx\n", ELF_LONG_H(elf_spnt->sh_size));
627,7 → 630,7
if (fread(&coffhdr, sizeof(coffhdr), 1, inputfs) == 1) {
if (COFF_SHORT_H(coffhdr.f_magic) == 0x17a) {
unsigned long opthdr_size;
uint32_t opthdr_size;
PRINTF("COFF magic: 0x%.4x\n", COFF_SHORT_H(coffhdr.f_magic));
PRINTF("COFF flags: 0x%.4x\n", COFF_SHORT_H(coffhdr.f_flags));
PRINTF("COFF symptr: 0x%.8lx\n", COFF_LONG_H(coffhdr.f_symptr));
638,7 → 641,7
opthdr_size = COFF_SHORT_H(coffhdr.f_opthdr);
if (opthdr_size != sizeof(COFF_AOUTHDR)) {
PRINTF("COFF optional header is missing or not recognized.\n");
PRINTF("COFF f_opthdr: 0x%.2lx\n", opthdr_size);
PRINTF("COFF f_opthdr: 0x%"PRIx32"\n", opthdr_size);
exit(1);
}
fclose(inputfs);
679,7 → 682,7
 
 
/* Loads file to memory starting at address startaddr and returns freemem. */
unsigned long loadcode(char *filename, oraddr_t startaddr, oraddr_t virtphy_transl)
uint32_t loadcode(char *filename, oraddr_t startaddr, oraddr_t virtphy_transl)
{
int breakpoint = 0;
 
/trunk/or1ksim/cpu/common/elf.h
20,11 → 20,19
(((unsigned long)(ps) << 24) & 0xff000000))
#endif
 
typedef unsigned long Elf32_Addr;
typedef unsigned short Elf32_Half;
typedef unsigned long Elf32_Off;
typedef long Elf32_Sword;
typedef unsigned long Elf32_Word;
#ifdef OR32_TYPES
typedef uint32_t Elf32_Addr;
typedef uint16_t Elf32_Half;
typedef uint32_t Elf32_Off;
typedef int32_t Elf32_Sword;
typedef uint32_t Elf32_Word;
#else
typedef unsigned long Elf32_Addr;
typedef unsigned short Elf32_Half;
typedef unsigned long Elf32_Off;
typedef long Elf32_Sword;
typedef unsigned long Elf32_Word;
#endif
 
/* These constants are for the segment types stored in the image headers */
#define PT_NULL 0
/trunk/or1ksim/ChangeLog
1,3 → 1,9
2006-01-04 10:45 rezso
 
* cpu/common/elf.h, cpu/common/parse.c cpu/common/parse.h:
Fix the support for 64bit host platforms.
 
2005-11-26 13:41 nogj
 
* toplevel.c:

powered by: WebSVN 2.1.0

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