FileIO Schema started

This commit is contained in:
felsabbagh3
2019-11-12 00:31:30 -05:00
parent 7ed88ce4c1
commit ef83285c6c
23 changed files with 81258 additions and 26 deletions

View File

@@ -86,12 +86,12 @@ void Core::printStats() const {
for (unsigned i = 0; i < w.size(); ++i)
insts += w[i].insts;
cout << "Total steps: " << steps << endl;
cerr << "Total steps: " << steps << endl;
cout << "Total insts: " << insts << endl;
for (unsigned i = 0; i < w.size(); ++i) {
cout << "=== Warp " << i << " ===" << endl;
w[i].printStats();
}
// for (unsigned i = 0; i < w.size(); ++i) {
// cout << "=== Warp " << i << " ===" << endl;
// w[i].printStats();
// }
}
Warp::Warp(Core *c, Word id) :

Binary file not shown.

Binary file not shown.

View File

@@ -103,6 +103,8 @@ int emu_main(int argc, char **argv) {
std::cout << "ABOUT TO START\n";
while (core.running()) { console.poll(); core.step(); }
printf("-----------------------------------\n\n\n\n");
if (showStats) core.printStats();

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1,4 +1,4 @@
echo start > results.txt
# echo ../kernel/vortex_test.hex
./harptool -E -a rv32i --core ../runtime/mains/dev/vx_dev_main.hex -s -b 1> emulator.debug
./harptool -E -a rv32i --core ../runtime/mains/nlTest/vx_nl_main.hex -s -b 1> emulator.debug

View File

@@ -9,7 +9,7 @@
// Uncomment the below line if NW=1
// `define ONLY
`define SYN 1
// `define SYN 1
`define ASIC 1
`define NUM_BARRIERS 4

27
runtime/fileIo/fileio.c Normal file
View File

@@ -0,0 +1,27 @@
#include "fileio.h"
void __attribute__ ((section (".FileIO"))) vx_close()
{
}
void __attribute__ ((section (".FileIO"))) vx_fstat()
{
}
void __attribute__ ((section (".FileIO"))) vx_isatty()
{
}
void __attribute__ ((section (".FileIO"))) vx_read()
{
}
void __attribute__ ((section (".FileIO"))) vx_write()
{
}

22
runtime/fileIo/fileio.h Normal file
View File

@@ -0,0 +1,22 @@
#ifndef FILE_IOO
#define FILE_IOO
#include <sys/stat.h>
#include <errno.h>
#include <stdio.h>
void vx_close();
void vx_fstat();
void vx_isatty();
void vx_read();
void vx_write();
#endif

View File

@@ -3,22 +3,22 @@
void vx_print_hex(unsigned f)
{
vx_print_str(hextoa[f]);
// if (f < 16)
// {
// vx_print_str(hextoa[f]);
// return;
// }
// int temp;
// int sf = 32;
// bool start = false;
// do
// {
// temp = (f >> (sf - 4)) & 0xf;
// if (temp != 0) start = true;
// if (start) vx_print_str(hextoa[temp]);
// sf -= 4;
// } while(sf > 0);
// vx_print_str(hextoa[f]);
if (f < 16)
{
vx_print_str(hextoa[f]);
return;
}
int temp;
int sf = 32;
bool start = false;
do
{
temp = (f >> (sf - 4)) & 0xf;
if (temp != 0) start = true;
if (start) vx_print_str(hextoa[temp]);
sf -= 4;
} while(sf > 0);
}

View File

@@ -0,0 +1,29 @@
COMP = /opt/riscv/bin/riscv32-unknown-elf-gcc
# CC_FLAGS = -march=rv32im -mabi=ilp32 -O0 -Wl,-Bstatic,-T,linker.ld -ffreestanding -nostdlib
CC_FLAGS = -march=rv32im -mabi=ilp32 -O0 -Wl,-Bstatic,-T,linker.ld -ffreestanding -nostartfiles -nostdlib
DMP = /opt/riscv/bin/riscv32-unknown-elf-objdump
CPY = /opt/riscv/bin/riscv32-unknown-elf-objcopy
NEWLIB = ../../newlib/newlib.c ../../newlib/newlib_notimp.c ../../newlib/newlib.s
VX_STR = ../../startup/vx_start.s
VX_INT = ../../intrinsics/vx_intrinsics.s
VX_IO = ../../io/vx_io.s ../../io/vx_io.c
VX_API = ../../vx_api/vx_api.c
VX_TEST = ../../tests/tests.c
VX_FIO = ../../fileio/fileio.c
VX_MAIN = ./vx_nl_main.c
all: HEX DUMP ELF
DUMP: ELF
$(DMP) -D vx_nl_main.elf > vx_nl_main.dump
HEX: ELF
$(CPY) -O ihex vx_nl_main.elf vx_nl_main.hex
ELF:
$(COMP) $(CC_FLAGS) $(VX_STR) $(VX_FIO) $(NEWLIB) $(VX_INT) $(VX_IO) $(VX_API) $(VX_TEST) $(VX_MAIN) /opt/riscv/riscv32-unknown-elf/lib/libc.a /opt/riscv/riscv32-unknown-elf/lib/libstdc++.a -static-libgcc -lgcc -o vx_nl_main.elf

View File

@@ -0,0 +1,53 @@
/* ---- Original Script: /opt/riscv32i/riscv32-unknown-elf/lib/ldscripts/elf32lriscv.x ---- */
/* Default linker script, for normal executables */
/* Copyright (C) 2014-2017 Free Software Foundation, Inc.
Copying and distribution of this script, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved. */
OUTPUT_FORMAT("elf32-littleriscv", "elf32-littleriscv",
"elf32-littleriscv")
OUTPUT_ARCH(riscv)
ENTRY(_start)
SECTIONS
{
. = 0x70000000;
.FileIO :
{
}
. = 0x80000000;
.text :
{
*(.text)
*(.text.unlikely .text.*_unlikely .text.unlikely.*)
*(.text.exit .text.exit.*)
*(.text.startup .text.startup.*)
*(.text.hot .text.hot.*)
*(.stub .text.* .gnu.linkonce.t.*)
/* .gnu.warning sections are handled specially by elf32.em. */
*(.gnu.warning)
}
.init :
{
KEEP (*(SORT_NONE(.init)))
}
.plt : { *(.plt) }
.iplt : { *(.iplt) }
.fini :
{
KEEP (*(SORT_NONE(.fini)))
}
PROVIDE (__etext = .);
PROVIDE (_etext = .);
PROVIDE (etext = .);
PROVIDE (_edata = .);
PROVIDE (_end = .);
PROVIDE (__global_pointer$ = .);
. = 0x81000000;
.rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
.rodata1 : { *(.rodata1) }
. = 0x82000000;
.comment : { *(.comment) }
}

View File

@@ -0,0 +1,36 @@
#include "../../intrinsics/vx_intrinsics.h"
#include "../../io/vx_io.h"
#include "../../tests/tests.h"
#include "../../vx_api/vx_api.h"
#include "../../fileio/fileio.h"
// #include <utlist.h>
#include <string.h>
#include <unistd.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h>
// Newlib
#include <stdio.h>
int main()
{
// Main is called with all threads active of warp 0
vx_tmc(1);
printf("printf: Newlib Main %d\n", 456);
vx_close();
return 0;
}

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

165
runtime/newlib/newlib.c Normal file
View File

@@ -0,0 +1,165 @@
#include "../io/vx_io.h"
#include "../fileio/fileio.h"
#include <sys/stat.h>
#include <errno.h>
#include <stdio.h>
#define CLOSE 1
#define ISATTY 2
#define LSEEK 3
#define READ 4
#define WRITE 5
#define FSTAT 6
#define FILE_IO_WRITE 0x71000000
#define FILE_IO_READ 0x72000000
void upload(char ** ptr, char * src, int size)
{
char * drain = *ptr;
*drain = size;
drain += 4;
for (int i = 0; i < size; i++)
{
(*drain) = src[i];
drain += 1;
}
*ptr = drain;
}
void download(char ** ptr, char * drain)
{
char * src = *ptr;
int size;
size = *((int *) src);
src += 4;
for (int i = 0; i < size; i++)
{
drain[i] = (*src);
src += 1;
}
*ptr = src;
}
void _close()
{
vx_print_str("Hello from _close\n");
}
int _fstat(int file, struct stat * st)
{
char * write_buffer = (char *) FILE_IO_WRITE;
int cmd_id = FSTAT;
upload((char **) &write_buffer, (char *) &cmd_id, sizeof(int));
upload((char **) &write_buffer, (char *) &file , sizeof(int));
vx_fstat();
char * read_buffer = (char *) FILE_IO_READ;
download((char **) &read_buffer, (char *) st);
}
int _isatty (int file)
{
vx_print_str("Hello from _isatty\n");
return 1;
}
void _lseek()
{
vx_print_str("Hello from _lseek\n");
}
void _read()
{
vx_print_str("Hello from _read\n");
}
int _write (int file, char *buf, int nbytes)
{
char * write_buffer = (char *) FILE_IO_WRITE;
int cmd_id = WRITE;
upload((char **) &write_buffer, (char *) &cmd_id, sizeof(int));
upload((char **) &write_buffer, (char *) &file , sizeof(int));
upload((char **) &write_buffer, (char *) buf , nbytes);
vx_write();
// int i;
// unsigned int volatile * const print_addr = (unsigned int *) 0x00010000;
// for (i = 0; i < nbytes; i++)
// {
// (*print_addr) = buf[i];
// }
// return nbytes;
}
static int heap_start = (int) 0x10000000;
static int head_end = (int) 0x20000000;
void * _sbrk (int nbytes)
{
//vx_print_str("Hello from _sbrk\n");
//vx_printf("nbytes: ", nbytes);
//if (nbytes < 0) vx_print_str("nbytes less than zero\n");
// printf("nBytes: %d\n", nbytes);
if (nbytes < 0)
{
nbytes = nbytes * -1;
}
if (nbytes > 10240)
{
nbytes = 10240;
}
// if (((unsigned) head_end) > ((unsigned) (heap_ptr + nbytes)))
if (true)
{
int base = heap_start;
heap_start += nbytes;
//vx_print_str("_sbrk returning: ");
//vx_print_hex((unsigned) base);
//vx_print_str("\n");
return (void *) base;
}
else
{
errno = ENOMEM;
return (void *) -1;
}
} /* _sbrk () */

182
runtime/newlib/newlib.s Normal file
View File

@@ -0,0 +1,182 @@
# .type __lttf2, @function
# .global __lttf2
# __lttf2:
# ret
# .type __extenddftf2, @function
# .global __extenddftf2
# __extenddftf2:
# ret
# .type __trunctfdf2, @function
# .global __trunctfdf2
# __trunctfdf2:
# ret
# .type __multf3, @function
# .global __multf3
# __multf3:
# ret
# .type __fixtfsi, @function
# .global __fixtfsi
# __fixtfsi:
# ret
# .type __floatsitf, @function
# .global __floatsitf
# __floatsitf:
# ret
# .type __subtf3, @function
# .global __subtf3
# __subtf3:
# ret
# .type __gttf2, @function
# .global __gttf2
# __gttf2:
# ret
# .type __eqtf2, @function
# .global __eqtf2
# __eqtf2:
# ret
# .type __netf2, @function
# .global __netf2
# __netf2:
# ret
# define __udivdi3 __udivsi3
# define __umoddi3 __umodsi3
# define __divdi3 __divsi3
# define __moddi3 __modsi3
# .type __udivsi3, @function
# .global __udivsi3
# __udivsi3:
# move t0, ra
# jal __udivdi3
# jr t0
# .type __umodsi3, @function
# .global __umodsi3
# __umodsi3:
# move t0, ra
# jal __udivdi3
# mv a0, a1
# jr t0
# .type __divsi3, @function
# .global __divsi3
# __divsi3:
# ret
# #endif
# .type __divdi3, @function
# .global __divdi3
# __divdi3:
# bltz a0, .L10
# bltz a1, .L11
# /* Since the quotient is positive, fall into __udivdi3. */
# .type __udivdi3, @function
# .global __udivdi3
# __udivdi3:
# mv a2, a1
# mv a1, a0
# li a0, -1
# beqz a2, .L5
# li a3, 1
# bgeu a2, a1, .L2
# .L1:
# blez a2, .L2
# slli a2, a2, 1
# slli a3, a3, 1
# bgtu a1, a2, .L1
# .L2:
# li a0, 0
# .L3:
# bltu a1, a2, .L4
# sub a1, a1, a2
# or a0, a0, a3
# .L4:
# srli a3, a3, 1
# srli a2, a2, 1
# bnez a3, .L3
# .L5:
# ret
# .type __umoddi3, @function
# .global __umoddi3
# __umoddi3:
# move t0, ra
# jal __udivdi3
# move a0, a1
# jr t0
# .L10:
# neg a0, a0
# bgez a1, .L12 /* Compute __udivdi3(-a0, a1), then negate the result. */
# neg a1, a1
# j __udivdi3 /* Compute __udivdi3(-a0, -a1). */
# .L11: /* Compute __udivdi3(a0, -a1), then negate the result. */
# neg a1, a1
# .L12:
# move t0, ra
# jal __udivdi3
# neg a0, a0
# jr t0
# .type __moddi3, @function
# .global __moddi3
# __moddi3:
# move t0, ra
# bltz a1, .L31
# bltz a0, .L32
# .L30:
# jal __udivdi3 /* The dividend is not negative. */
# move a0, a1
# jr t0
# .L31:
# neg a1, a1
# bgez a0, .L30
# .L32:
# neg a0, a0
# jal __udivdi3 /* The dividend is hella negative. */
# neg a0, a1
# jr t0
# .type __modsi3, @function
# .global __modsi3
# __modsi3:
# move t0, ra
# bltz a1, .L34
# bltz a0, .L35
# .L33:
# jal __udivdi3 /* The dividend is not negative. */
# move a0, a1
# jr t0
# .L34:
# neg a1, a1
# bgez a0, .L30
# .L35:
# neg a0, a0
# jal __udivdi3 /* The dividend is hella negative. */
# neg a0, a1
# jr t0

View File

View File

@@ -21,6 +21,7 @@
#include "include/args.h"
#include "include/help.h"
#include <sys/stat.h>
//////////////
/////////////
@@ -122,6 +123,10 @@ int emu_main(int argc, char **argv) {
// count_down = true;
// }
// }
struct stat hello;
fstat(0, &hello);
while (core.running()) { console.poll(); core.step(); }
if (showStats) core.printStats();

View File

@@ -1,7 +1,6 @@
echo start > results.txt
# echo ../kernel/vortex_test.hex
make clean
make
echo "Fasten your seatbelts ladies and gentelmen!!"
cd obj_dir && ./Vcache_simX -E -a rv32i --core ../../runtime/mains/dev/vx_dev_main.hex -s -b 1> emulator.debug
printf "Fasten your seatbelts ladies and gentelmen!!\n\n\n\n"
cd obj_dir && ./Vcache_simX -E -a rv32i --core ../../runtime/mains/nlTest/vx_nl_main.hex -s -b 1> emulator.debug