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

Subversion Repositories s6soc

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /s6soc/trunk
    from Rev 47 to Rev 48
    Reverse comparison

Rev 47 → Rev 48

/sw/host/byteswap.cpp
0,0 → 1,86
////////////////////////////////////////////////////////////////////////////////
//
// Filename: byteswap.cpp
//
// Project: OpenArty, an entirely open SoC based upon the Arty platform
//
// Purpose:
//
// Creator: Dan Gisselquist, Ph.D.
// Gisselquist Technology, LLC
//
////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015-2016, Gisselquist Technology, LLC
//
// This program is free software (firmware): you can redistribute it and/or
// modify it under the terms of the GNU General Public License as published
// by the Free Software Foundation, either version 3 of the License, or (at
// your option) any later version.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program. (It's in the $(ROOT)/doc directory, run make with no
// target there if the PDF file isn't present.) If not, see
// <http://www.gnu.org/licenses/> for a copy.
//
// License: GPL, v3, as defined and found on www.gnu.org,
// http://www.gnu.org/licenses/gpl.html
//
//
////////////////////////////////////////////////////////////////////////////////
//
//
#include <stdint.h>
#include "byteswap.h"
 
uint32_t
byteswap(uint32_t v) {
uint32_t r = 0;
 
r = (v & 0x0ff);
r <<= 8; v >>= 8;
r |= (v & 0x0ff);
r <<= 8; v >>= 8;
r |= (v & 0x0ff);
r <<= 8; v >>= 8;
r |= (v & 0x0ff);
 
return r;
}
 
uint32_t
buildword(const unsigned char *p) {
uint32_t r = 0;
 
r = (*p++); r <<= 8;
r |= (*p++); r <<= 8;
r |= (*p++); r <<= 8;
r |= (*p );
 
return r;
}
 
uint32_t
buildswap(const unsigned char *p) {
uint32_t r = 0;
 
r = p[3]; r <<= 8;
r |= p[2]; r <<= 8;
r |= p[1]; r <<= 8;
r |= p[0];
 
return r;
}
 
void
byteswapbuf(int ln, uint32_t *buf) {
for(int i=0; i<ln; i++)
buf[i] = byteswap(buf[i]);
}
 
 
/sw/host/byteswap.h
0,0 → 1,54
////////////////////////////////////////////////////////////////////////////////
//
// Filename: byteswap.h
//
// Project: OpenArty, an entirely open SoC based upon the Arty platform
//
// Purpose:
//
// Creator: Dan Gisselquist, Ph.D.
// Gisselquist Technology, LLC
//
////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015-2016, Gisselquist Technology, LLC
//
// This program is free software (firmware): you can redistribute it and/or
// modify it under the terms of the GNU General Public License as published
// by the Free Software Foundation, either version 3 of the License, or (at
// your option) any later version.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program. (It's in the $(ROOT)/doc directory, run make with no
// target there if the PDF file isn't present.) If not, see
// <http://www.gnu.org/licenses/> for a copy.
//
// License: GPL, v3, as defined and found on www.gnu.org,
// http://www.gnu.org/licenses/gpl.html
//
//
////////////////////////////////////////////////////////////////////////////////
//
//
#ifndef BYTESWAP_H
#define BYTESWAP_H
 
#include <stdint.h>
 
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
extern uint32_t byteswap(uint32_t v);
extern void byteswapbuf(int ln, uint32_t *buf);
#else
#define byteswap(A) (A)
#define byteswapbuf(A, B)
#endif
 
extern uint32_t buildword(const unsigned char *p);
extern uint32_t buildswap(const unsigned char *p);
 
#endif
/sw/host/zipelf.cpp
0,0 → 1,251
////////////////////////////////////////////////////////////////////////////////
//
// Filename: zipelf.cpp
//
// Project: OpenArty, an entirely open SoC based upon the Arty platform
//
// Purpose:
//
//
// Creator: Dan Gisselquist, Ph.D.
// Gisselquist Technology, LLC
//
////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015-2017, Gisselquist Technology, LLC
//
// This program is free software (firmware): you can redistribute it and/or
// modify it under the terms of the GNU General Public License as published
// by the Free Software Foundation, either version 3 of the License, or (at
// your option) any later version.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program. (It's in the $(ROOT)/doc directory. Run make with no
// target there if the PDF file isn't present.) If not, see
// <http://www.gnu.org/licenses/> for a copy.
//
// License: GPL, v3, as defined and found on www.gnu.org,
// http://www.gnu.org/licenses/gpl.html
//
//
////////////////////////////////////////////////////////////////////////////////
//
//
 
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <libelf.h>
#include <assert.h>
#include <gelf.h>
#include <string.h>
 
#include "zipelf.h"
 
bool
iself(const char *fname)
{
FILE *fp;
bool ret = true;
fp = fopen(fname, "rb");
 
if (!fp) return false;
if (0x7f != fgetc(fp)) ret = false;
if ('E' != fgetc(fp)) ret = false;
if ('L' != fgetc(fp)) ret = false;
if ('F' != fgetc(fp)) ret = false;
fclose(fp);
return ret;
}
 
void elfread(const char *fname, unsigned &entry, ELFSECTION **&sections)
{
Elf *e;
int fd, i;
size_t n;
char *id;
Elf_Kind ek;
GElf_Ehdr ehdr;
GElf_Phdr phdr;
const bool dbg = false;
 
if (elf_version(EV_CURRENT) == EV_NONE) {
fprintf(stderr, "ELF library initialization err, %s\n", elf_errmsg(-1));
perror("O/S Err:");
exit(EXIT_FAILURE);
} if ((fd = open(fname, O_RDONLY, 0)) < 0) {
fprintf(stderr, "Could not open %s\n", fname);
perror("O/S Err:");
exit(EXIT_FAILURE);
} if ((e = elf_begin(fd, ELF_C_READ, NULL))==NULL) {
fprintf(stderr, "Could not run elf_begin, %s\n", elf_errmsg(-1));
exit(EXIT_FAILURE);
}
 
ek = elf_kind(e);
if (ek == ELF_K_ELF) {
; // This is the kind of file we should expect
} else if (ek == ELF_K_AR) {
fprintf(stderr, "Cannot run an archive!\n");
exit(EXIT_FAILURE);
} else if (ek == ELF_K_NONE) {
;
} else {
fprintf(stderr, "Unexpected ELF file kind!\n");
exit(EXIT_FAILURE);
}
 
if (gelf_getehdr(e, &ehdr) == NULL) {
fprintf(stderr, "getehdr() failed: %s\n", elf_errmsg(-1));
exit(EXIT_FAILURE);
} if ((i=gelf_getclass(e)) == ELFCLASSNONE) {
fprintf(stderr, "getclass() failed: %s\n", elf_errmsg(-1));
exit(EXIT_FAILURE);
} if ((id = elf_getident(e, NULL)) == NULL) {
fprintf(stderr, "getident() failed: %s\n", elf_errmsg(-1));
exit(EXIT_FAILURE);
} if (i != ELFCLASS32) {
fprintf(stderr, "This is a 64-bit ELF file, ZipCPU ELF files are all 32-bit\n");
exit(EXIT_FAILURE);
}
 
if (dbg) {
printf(" %-20s 0x%jx\n", "e_type", (uintmax_t)ehdr.e_type);
printf(" %-20s 0x%jx\n", "e_machine", (uintmax_t)ehdr.e_machine);
printf(" %-20s 0x%jx\n", "e_version", (uintmax_t)ehdr.e_version);
printf(" %-20s 0x%jx\n", "e_entry", (uintmax_t)ehdr.e_entry);
printf(" %-20s 0x%jx\n", "e_phoff", (uintmax_t)ehdr.e_phoff);
printf(" %-20s 0x%jx\n", "e_shoff", (uintmax_t)ehdr.e_shoff);
printf(" %-20s 0x%jx\n", "e_flags", (uintmax_t)ehdr.e_flags);
printf(" %-20s 0x%jx\n", "e_ehsize", (uintmax_t)ehdr.e_ehsize);
printf(" %-20s 0x%jx\n", "e_phentsize", (uintmax_t)ehdr.e_phentsize);
printf(" %-20s 0x%jx\n", "e_shentsize", (uintmax_t)ehdr.e_shentsize);
printf("\n");
}
 
 
// Check whether or not this is an ELF file for the ZipCPU ...
if (ehdr.e_machine != 0x0dad1) {
fprintf(stderr, "This is not a ZipCPU/8 ELF file\n");
exit(EXIT_FAILURE);
}
 
// Get our entry address
entry = ehdr.e_entry;
 
 
// Now, let's go look at the program header
if (elf_getphdrnum(e, &n) != 0) {
fprintf(stderr, "elf_getphdrnum() failed: %s\n", elf_errmsg(-1));
exit(EXIT_FAILURE);
}
 
assert(n != 0);
 
unsigned total_octets = 0, current_offset=0, current_section=0;
for(i=0; i<(int)n; i++) {
total_octets += sizeof(ELFSECTION *)+sizeof(ELFSECTION);
 
if (gelf_getphdr(e, i, &phdr) != &phdr) {
fprintf(stderr, "getphdr() failed: %s\n", elf_errmsg(-1));
exit(EXIT_FAILURE);
}
 
if (dbg) {
printf(" %-20s 0x%x\n", "p_type", phdr.p_type);
printf(" %-20s 0x%jx\n", "p_offset", phdr.p_offset);
printf(" %-20s 0x%jx\n", "p_vaddr", phdr.p_vaddr);
printf(" %-20s 0x%jx\n", "p_paddr", phdr.p_paddr);
printf(" %-20s 0x%jx\n", "p_filesz", phdr.p_filesz);
printf(" %-20s 0x%jx\n", "p_memsz", phdr.p_memsz);
printf(" %-20s 0x%x [", "p_flags", phdr.p_flags);
 
if (phdr.p_flags & PF_X) printf(" Execute");
if (phdr.p_flags & PF_R) printf(" Read");
if (phdr.p_flags & PF_W) printf(" Write");
printf("]\n");
printf(" %-20s 0x%jx\n", "p_align", phdr.p_align);
}
 
total_octets += phdr.p_memsz;
}
 
char *d = (char *)malloc(total_octets + sizeof(ELFSECTION)+sizeof(ELFSECTION *));
memset(d, 0, total_octets);
 
ELFSECTION **r = sections = (ELFSECTION **)d;
current_offset = (n+1)*sizeof(ELFSECTION *);
current_section = 0;
 
for(i=0; i<(int)n; i++) {
r[i] = (ELFSECTION *)(&d[current_offset]);
 
if (gelf_getphdr(e, i, &phdr) != &phdr) {
fprintf(stderr, "getphdr() failed: %s\n", elf_errmsg(-1));
exit(EXIT_FAILURE);
}
 
if (dbg) {
printf(" %-20s 0x%jx\n", "p_offset", phdr.p_offset);
printf(" %-20s 0x%jx\n", "p_vaddr", phdr.p_vaddr);
printf(" %-20s 0x%jx\n", "p_paddr", phdr.p_paddr);
printf(" %-20s 0x%jx\n", "p_filesz", phdr.p_filesz);
printf(" %-20s 0x%jx\n", "p_memsz", phdr.p_memsz);
printf(" %-20s 0x%x [", "p_flags", phdr.p_flags);
 
if (phdr.p_flags & PF_X) printf(" Execute");
if (phdr.p_flags & PF_R) printf(" Read");
if (phdr.p_flags & PF_W) printf(" Write");
printf("]\n");
 
printf(" %-20s 0x%jx\n", "p_align", phdr.p_align);
}
 
current_section++;
 
r[i]->m_start = phdr.p_paddr;
r[i]->m_len = phdr.p_filesz;
 
current_offset += phdr.p_memsz + sizeof(ELFSECTION);
 
// Now, let's read in our section ...
if (lseek(fd, phdr.p_offset, SEEK_SET) < 0) {
fprintf(stderr, "Could not seek to file position %08lx\n", phdr.p_offset);
perror("O/S Err:");
exit(EXIT_FAILURE);
} if (phdr.p_filesz > phdr.p_memsz)
phdr.p_filesz = 0;
if (read(fd, r[i]->m_data, phdr.p_filesz) != (int)phdr.p_filesz) {
fprintf(stderr, "Didnt read entire section\n");
perror("O/S Err:");
exit(EXIT_FAILURE);
}
 
/*
// Next, we need to byte swap it from big to little endian
for(unsigned j=0; j<r[i]->m_len; j++)
r[i]->m_data[j] = byteswap(r[i]->m_data[j]);
*/
 
if (dbg) for(unsigned j=0; j<r[i]->m_len; j++)
fprintf(stderr, "ADR[%04x] = %02x\n", r[i]->m_start+j,
r[i]->m_data[j] & 0x0ff);
}
 
r[i] = (ELFSECTION *)(&d[current_offset]);
r[current_section]->m_start = 0;
r[current_section]->m_len = 0;
 
elf_end(e);
close(fd);
}
 
/sw/host/zipelf.h
0,0 → 1,53
////////////////////////////////////////////////////////////////////////////////
//
// Filename: zipelf.h
//
// Project: CMod S6 System on a Chip, ZipCPU demonstration project
//
// Purpose:
//
//
// Creator: Dan Gisselquist, Ph.D.
// Gisselquist Technology, LLC
//
////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015-2017, Gisselquist Technology, LLC
//
// This program is free software (firmware): you can redistribute it and/or
// modify it under the terms of the GNU General Public License as published
// by the Free Software Foundation, either version 3 of the License, or (at
// your option) any later version.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program. (It's in the $(ROOT)/doc directory. Run make with no
// target there if the PDF file isn't present.) If not, see
// <http://www.gnu.org/licenses/> for a copy.
//
// License: GPL, v3, as defined and found on www.gnu.org,
// http://www.gnu.org/licenses/gpl.html
//
//
////////////////////////////////////////////////////////////////////////////////
//
//
#ifndef ZIPELF_H
#define ZIPELF_H
 
#include <stdint.h>
 
class ELFSECTION {
public:
uint32_t m_start, m_len;
char m_data[4];
};
 
bool iself(const char *fname);
void elfread(const char *fname, uint32_t &entry, ELFSECTION **&sections);
 
#endif
sw/host Property changes : Added: svn:ignore ## -0,0 +1,9 ## +.gitignore +buildsamples +dumpuart +obj-pc +qspiflash-original.bin +readflash +tags +wbregs +zipload Index: sw/zipos/bootloader.h =================================================================== --- sw/zipos/bootloader.h (nonexistent) +++ sw/zipos/bootloader.h (revision 48) @@ -0,0 +1,47 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Filename: bootloader.h +// +// Project: Zip CPU -- a small, lightweight, RISC CPU soft core +// +// Purpose: +// +// +// Creator: Dan Gisselquist, Ph.D. +// Gisselquist Technology, LLC +// +//////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015-2016, Gisselquist Technology, LLC +// +// This program is free software (firmware): you can redistribute it and/or +// modify it under the terms of the GNU General Public License as published +// by the Free Software Foundation, either version 3 of the License, or (at +// your option) any later version. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// License: GPL, v3, as defined and found on www.gnu.org, +// http://www.gnu.org/licenses/gpl.html +// +// +//////////////////////////////////////////////////////////////////////////////// +// +// +#ifndef BOOTLOADER_H +#define BOOTLOADER_H + +extern int _top_of_heap[1], _top_of_stack[1]; + +extern int _sdram[1], _flash[1], _blkram[1]; + +extern int _boot_address[1], + _kernel_image_start[1], _kernel_image_end[1], + _sdram_image_start[1], _sdram_image_end[1], + _bss_image_end[1]; + +extern void _bootloader(void); +#endif Index: sw/zipos/string.c =================================================================== --- sw/zipos/string.c (nonexistent) +++ sw/zipos/string.c (revision 48) @@ -0,0 +1,285 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Filename: string.c +// +// Project: CMod S6 System on a Chip, ZipCPU demonstration project +// +// Purpose: To provide *some* of the C-library's capabilities, without +// using perfectly optimal functions--but rather simple things that +// can be easily tested and debugged. +// +// Creator: Dan Gisselquist, Ph.D. +// Gisselquist Technology, LLC +// +//////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017, Gisselquist Technology, LLC +// +// This program is free software (firmware): you can redistribute it and/or +// modify it under the terms of the GNU General Public License as published +// by the Free Software Foundation, either version 3 of the License, or (at +// your option) any later version. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with this program. (It's in the $(ROOT)/doc directory. Run make with no +// target there if the PDF file isn't present.) If not, see +// for a copy. +// +// License: GPL, v3, as defined and found on www.gnu.org, +// http://www.gnu.org/licenses/gpl.html +// +// +//////////////////////////////////////////////////////////////////////////////// +// +// +#include "string.h" +#include "txfns.h" + +char * +strcpy(char *dst, const char *src) { + char v, *d = dst; + do { + *dst++ = (v = *src++); + } while(v); + + return d; +} + +char * +strcat(char *dst, const char *src) { + char v, *d = dst; + do { + v = *dst++; + } while(v); + + dst--; + strcpy(dst, src); + + return d; +} + +#ifdef C_STRING_FNS +size_t +strlen(const char *str) { + size_t ln = 0; + while(*str++) + ln++; + return ln; +} +#else +asm("\t.section\t.text\n" + "\t.global\tstrlen\n" +"strlen:\n" + "\tMOV\tR1,R2\n" + "\tCLR\tR1\n" +".Lstrlen_loop:\n" + "\tLB\t(R2),R3\n" + "\tCMP\t0,R3\n" + "\tRTN.Z\n" + "\tADD\t1,R2\n" + "\tADD\t1,R1\n" + "\tBRA\t.Lstrlen_loop\n"); +#endif + +#ifdef C_STRING_FNS +void *memcpy(void *dest, const void *src, size_t ln) { + char *d = dest; const char *s = src; + +/* + if (((((unsigned)d ^ (unsigned)s)&3)==0)&&(ln>4)) { + // Source and destination are aligned with each other + + // Align them to a word boundary + int n = (3-(((unsigned)d)&3)); + ln -= n; + while(n>0) { + *d++ = *s++; n--; + } + + int *id = (int *)d; + const int *is = (const int *)s; + while(ln >= 4) { + *id++ = *is++; ln-=4; + } d = (char *)id; s = (const char *)is; + } +*/ + + while(ln > 0) { + *d++ = *s++; ln--; + } return dest; +} +#else +asm("\t.section\t.text\n" + "\t.global\tmemcpy\n" +"memcpy:\n" + "\tCMP 0,R3\n" + "\tRTN.Z\n" + "\tMOV\tR1,R4\n" + "\tSUB 4,SP\n" + "\tSW R5,(SP)\n" + // + "\tTST\t3,R2\n" + "\tBZ\t.Lpre_aligned\n" + "\tLB\t(R2),R5\n" + "\tSB\tR5,(R4),R5\n" + "\tADD\t1,R2\n" + "\tADD\t1,R4\n" + "\tSUB\t1,R3\n" + "\tBZ\t.Lmemcpy_epilogue\n" + // + "\tTST\t3,R2\n" + "\tBZ\t.Lpre_aligned\n" + "\tLB\t(R2),R5\n" + "\tSB\tR5,(R4),R5\n" + "\tADD\t1,R2\n" + "\tADD\t1,R4\n" + "\tSUB\t1,R3\n" + "\tBZ\t.Lmemcpy_epilogue\n" + // + "\tTST\t3,R2\n" + "\tBZ\t.Lpre_aligned\n" + "\tLB\t(R2),R5\n" + "\tSB\tR5,(R4),R5\n" + "\tADD\t1,R2\n" + "\tADD\t1,R4\n" + "\tSUB\t1,R3\n" + "\tBZ\t.Lmemcpy_epilogue\n" + // +".Lpre_aligned:\n" + "\tTST\t1,R4\n" + "\tBNZ\t.Lmemcpy_unaligned\n" + "\tTST\t2,R4\n" + "\tBNZ\t.Lmemcpy_half_aligned\n" +".Lmemcpy_highspeed:\n" + "\tSUB\t32,R3\n" + "\tBLT\t.Lend_of_high_speed\n" + // + "\tLW\t(R2),R5\n" + "\tSW\tR5,(R4)\n" + "\tLW\t4(R2),R5\n" + "\tSW\tR5,4(R4)\n" + "\tLW\t8(R2),R5\n" + "\tSW\tR5,8(R4)\n" + "\tLW\t12(R2),R5\n" + "\tSW\tR5,12(R4)\n" + // + "\tLW\t16(R2),R5\n" + "\tSW\tR5,16(R4)\n" + "\tLW\t20(R2),R5\n" + "\tSW\tR5,20(R4)\n" + "\tLW\t24(R2),R5\n" + "\tSW\tR5,24(R4)\n" + "\tLW\t28(R2),R5\n" + "\tSW\tR5,28(R4)\n" + // + "\tADD\t32,R2\n" + "\tADD\t32,R4\n" + "\tBRA\t.Lmemcpy_highspeed\n" +".Lend_of_high_speed:\n" + "\tADD\t32,R3\n" +".Lmemcpy_half_aligned:\n" + "\tSUB\t4,R3\n" + "\tBLT\t.Lend_of_short_speed\n" + "\tLH\t(R2),R5\n" + "\tSH\tR5,(R4)\n" + "\tLH\t2(R2),R5\n" + "\tSH\tR5,2(R4)\n" + "\tADD\t4,R2\n" + "\tADD\t4,R4\n" + "\tBRA\t.Lmemcpy_half_aligned\n" +".Lend_of_short_speed:\n" + "\tADD\t4,R3\n" +".Lmemcpy_unaligned:\n" + "\tSUB\t1,R3\n" + "\tBLT\t.Lmemcpy_epilogue\n" + "\tLB\t(R2),R5\n" + "\tSB\tR5,(R4)\n" + "\tADD\t1,R2\n" + "\tADD\t1,R4\n" + "\tBRA\t.Lmemcpy_unaligned\n" +".Lmemcpy_epilogue:\n" + "\tLW\t(SP),R5\n" + "\tADD\t4,SP\n" + "\tRETN\n" +); +/* +asm("\t.section\t.text\n" + "\t.global\tmemcpy\n" +"memcpy:\n" + "\tCMP 0,R3\n" + "\tRTN.Z\n" + "\tSUB 8,SP\n" + "\tSW R5,(SP)\n" +#define HIGH_SPEED_MEMCPY +#ifdef HIGH_SPEED_MEMCPY + "\tSW R6,4(SP)\n" + "\tMOV R1,R4\n" + "\tXOR R2,R4\n" + "\tTEST 3,R4\n" + "\tBNZ .Lmemcpy_unaligned\n" + "\tCMP 8,R3\n" + "\tBLT .Lmemcpy_unaligned\n" + + // n = 3+ ~((unsigned)d&3)+1 + "\tMOV\tR1,R4\n" + "\tAND\t3,R4\n" + "\tLDI\t3,R5\n" + "\tSUB\tR4,R5" "\t; R5 = n\n" + "\tMOV\tR1,R4" "\t; R4 = d\n" + "\tBZ\t.Lmemcpy_n_is_zero\n" + + "\tSUB\tR5,R3" "\t; ln -= n\n" + "\tTEST\t1,R5\n" + "\tLB.NZ\t(R2),R6\n" + "\tSB.NZ\tR6,(R4)\n" + "\tADD.NZ\t1,R4\n" + "\tADD.NZ\t1,R2\n" + "\tTEST\t2,R5\n" + "\tLH.NZ\t(R2),R6\n" + "\tSH.NZ\tR6,(R4)\n" + "\tADD.NZ\t2,R4\n" + "\tADD.NZ\t2,R2\n" + +".Lmemcpy_n_is_zero:\n" +".Lmemcpy_word_loop:\n" + "\tSUB\t4,R3\n" + "\tBLT\t.Lmemcpy_pretail\n" + "\tLW\t(R4),R5\n" + "\tSW\tR5,(R2)\n" + "\tADD\t4,R4\n" + "\tADD\t4,R2\n" + "\tBRA\t.Lmemcpy_word_loop\n" +".Lmemcpy_pretail:\n" + "\tADD\t4,R3\n" + "\tBZ\t.Lmemcpy_epilogue\n" + "\tBRA\t.Lmemcpy_unaligned_loop\n" + +".Lmemcpy_unaligned:\n" + "\tCMP 0,R3\n" + "\tBZ .Lmemcpy_epilogue\n" +#endif + "\tMOV\tR1,R4\n" +".Lmemcpy_unaligned_loop:\n" + "\tLB\t(R2),R5\n" + "\tSB\tR5,(R4)\n" + "\tADD\t1,R4\n" + "\tADD\t1,R2\n" + "\tSUB\t1,R3\n" + "\tBNZ\t.Lmemcpy_unaligned_loop\n" +".Lmemcpy_epilogue:\n" + "\tLW\t(SP),R5\n" +#ifdef HIGH_SPEED_MEMCPY + "\tLW\t4(SP),R6\n" +#endif + "\tADD\t8,SP\n" + "\tRTN\n" +); +*/ +#endif + + Index: sw/zipos/string.h =================================================================== --- sw/zipos/string.h (nonexistent) +++ sw/zipos/string.h (revision 48) @@ -0,0 +1,49 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Filename: string.h +// +// Project: CMod S6 System on a Chip, ZipCPU demonstration project +// +// Purpose: +// +// Creator: Dan Gisselquist, Ph.D. +// Gisselquist Technology, LLC +// +//////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015-2017, Gisselquist Technology, LLC +// +// This program is free software (firmware): you can redistribute it and/or +// modify it under the terms of the GNU General Public License as published +// by the Free Software Foundation, either version 3 of the License, or (at +// your option) any later version. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with this program. (It's in the $(ROOT)/doc directory. Run make with no +// target there if the PDF file isn't present.) If not, see +// for a copy. +// +// License: GPL, v3, as defined and found on www.gnu.org, +// http://www.gnu.org/licenses/gpl.html +// +// +//////////////////////////////////////////////////////////////////////////////// +// +// +#ifndef STRING_H +#define STRING_H + +typedef unsigned size_t; + +size_t strlen(const char *s); +char *strcpy(char *d, const char *s); +char *strcat(char *d, const char *s); +// +void *memcpy(void *d, const void *s, size_t n); + +#endif Index: sw/zipos =================================================================== --- sw/zipos (revision 47) +++ sw/zipos (revision 48)
sw/zipos Property changes : Added: svn:ignore ## -0,0 +1,4 ## +.gitignore +doorbell +obj-zip +tags

powered by: WebSVN 2.1.0

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