testing
This commit is contained in:
parent
e177b17ad8
commit
7a8ae11ce1
@ -1,6 +1,16 @@
|
|||||||
all:
|
all:
|
||||||
gcc -c loader_test.c
|
gcc -c loader_test.c
|
||||||
gcc -c inflate.c
|
gcc -c inflate.c
|
||||||
gcc -c neginf/neginf.c
|
gcc -c neginf/neginf.c
|
||||||
gcc -c inflate_test.c
|
gcc -c inflate_test.c
|
||||||
gcc -o inflate_test inflate.o neginf.o inflate_test.o loader_test.o
|
gcc -c ringbuffer.c
|
||||||
|
gcc -o inflate_test inflate.o neginf.o inflate_test.o loader_test.o ringbuffer.o
|
||||||
|
loader:
|
||||||
|
python ../../scripts/conv_zip_test.py ../../roms/qd16boot02_half.smc
|
||||||
|
|
||||||
|
test:
|
||||||
|
./inflate_test
|
||||||
|
@md5sum out.smc
|
||||||
|
@md5sum out_ref.smc
|
||||||
|
@md5sum ../../roms/qd16boot02_half.smc
|
||||||
|
|
||||||
|
|||||||
@ -19,29 +19,49 @@
|
|||||||
*/
|
*/
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "neginf/neginf.h"
|
#include "neginf/neginf.h"
|
||||||
#include "inflate.h"
|
#include "inflate.h"
|
||||||
|
#include "assert.h"
|
||||||
|
#include "ringbuffer.h"
|
||||||
|
|
||||||
char inflate_done = 0;
|
char inflate_done = 0;
|
||||||
char *mem;
|
char *mem;
|
||||||
|
char *mem_ref;
|
||||||
|
|
||||||
int addr = 0;
|
int addr = 0;
|
||||||
|
int addr_ref = 0;
|
||||||
|
|
||||||
|
|
||||||
void inflate_init()
|
void inflate_init()
|
||||||
{
|
{
|
||||||
neginf_init(0);
|
neginf_init(0);
|
||||||
mem = (char*)malloc(2<<16);
|
mem = (char*)malloc(2<<15);
|
||||||
|
mem_ref = (char*)malloc(2<<15);
|
||||||
|
addr_ref = 0;
|
||||||
addr = 0;
|
addr = 0;
|
||||||
|
rb_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void inflate_flush()
|
void inflate_flush()
|
||||||
{
|
{
|
||||||
|
while(!rb_isempty()){
|
||||||
|
|
||||||
|
mem[addr++] = rb_get();
|
||||||
|
printf("final fill addr=0x%06x size=%i\n",addr,rb_free());
|
||||||
|
}
|
||||||
|
printf("write out.smc\n");
|
||||||
FILE *file;
|
FILE *file;
|
||||||
file = fopen("out.smc","w");
|
file = fopen("out.smc","w");
|
||||||
fwrite(mem,2<<16,1,file);
|
fwrite(mem,2<<15,1,file);
|
||||||
fclose(file);
|
fclose(file);
|
||||||
|
|
||||||
|
printf("write out_ref.smc\n");
|
||||||
|
file = fopen("out_ref.smc","w");
|
||||||
|
fwrite(mem_ref,2<<15,1,file);
|
||||||
|
fclose(file);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void neginf_cb_completed()
|
void neginf_cb_completed()
|
||||||
@ -51,18 +71,33 @@ void neginf_cb_completed()
|
|||||||
|
|
||||||
void neginf_cb_seq_byte(nbyte byte)
|
void neginf_cb_seq_byte(nbyte byte)
|
||||||
{
|
{
|
||||||
mem[addr] = byte;
|
|
||||||
addr++;
|
mem_ref[addr_ref++] = byte;
|
||||||
|
|
||||||
|
|
||||||
|
if (rb_isfull())
|
||||||
|
mem[addr++] = rb_get();
|
||||||
|
|
||||||
|
printf("addr=%x byte=%i size=%i\n",addr,byte, rb_free());
|
||||||
|
rb_put(byte);
|
||||||
|
//assert(!rb_isfull());
|
||||||
}
|
}
|
||||||
|
|
||||||
void neginf_cb_copy(nsize from, nsize to, nint length)
|
void neginf_cb_copy(nsize from, nsize to, nint length)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
printf("neginf_cb_copy from=0x%06x to=0x%06x len=%i\n",from, to, length);
|
|
||||||
for (i=0; i<length;i++)
|
printf("neginf_cb_copy addr=0x%06x from=0x%06x to=0x%06x len=%i\n",addr,from, to, length);
|
||||||
mem[to+i] = mem[from+i];
|
|
||||||
|
for (i=0; i<length;i++){
|
||||||
|
mem_ref[to+i] = mem_ref[from+i];
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i=0; i<length;i++){
|
||||||
|
mem[to+i] = mem_ref[from+i];
|
||||||
|
}
|
||||||
addr = to + length;
|
addr = to + length;
|
||||||
|
addr_ref = to + length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -27,7 +27,7 @@
|
|||||||
extern const char _rom[];
|
extern const char _rom[];
|
||||||
extern char inflate_done;
|
extern char inflate_done;
|
||||||
|
|
||||||
void main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
|
||||||
int j;
|
int j;
|
||||||
@ -39,4 +39,5 @@ void main(int argc, char **argv)
|
|||||||
while(!inflate_done)
|
while(!inflate_done)
|
||||||
neginf_process_byte(0x00);
|
neginf_process_byte(0x00);
|
||||||
inflate_flush();
|
inflate_flush();
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@ -2,6 +2,6 @@
|
|||||||
#ifndef __FIFO_H__
|
#ifndef __FIFO_H__
|
||||||
#define __FIFO_H__
|
#define __FIFO_H__
|
||||||
|
|
||||||
#define ROM_ZIP_SIZE 35945
|
#define ROM_ZIP_SIZE 35543
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
62
avr/usbload/ringbuffer.c
Normal file
62
avr/usbload/ringbuffer.c
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
// AT90USB/ringbuffer.c
|
||||||
|
// Simple Ring-Buffer (FIFO) for Elements of type char
|
||||||
|
// S. Salewski, 19-MAR-2007
|
||||||
|
|
||||||
|
/*
|
||||||
|
t-> o
|
||||||
|
o <-w
|
||||||
|
x
|
||||||
|
x <-r
|
||||||
|
b-> x
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "ringbuffer.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static char buf[ringbuffer_size];
|
||||||
|
int rb_count;
|
||||||
|
|
||||||
|
#define t &buf[ringbuffer_size - 1]
|
||||||
|
#define b &buf[0]
|
||||||
|
|
||||||
|
//char *t = &buf[ringbuffer_size - 1];
|
||||||
|
//char *b = &buf[0];
|
||||||
|
|
||||||
|
char *r; // position from where we can read (if rb_count > 0)
|
||||||
|
char *w; // next free position (if rb_count < ringbuffer_size))
|
||||||
|
|
||||||
|
void rb_init(void)
|
||||||
|
{
|
||||||
|
r = b;
|
||||||
|
w = b;
|
||||||
|
rb_count = 0;
|
||||||
|
memset(buf,0,ringbuffer_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
char rb_get(void)
|
||||||
|
{
|
||||||
|
rb_count--;
|
||||||
|
if (r > t) r = b;
|
||||||
|
return *r++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
char rb_read(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (r > t) r = b;
|
||||||
|
return *r++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void rb_put(char el)
|
||||||
|
{
|
||||||
|
rb_count++;
|
||||||
|
if (w > t){
|
||||||
|
w = b;
|
||||||
|
printf("wrap around\n");
|
||||||
|
}
|
||||||
|
*w++ = el;
|
||||||
|
}
|
||||||
18
avr/usbload/ringbuffer.h
Normal file
18
avr/usbload/ringbuffer.h
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
#ifndef _RING_BUFFER_H_
|
||||||
|
#define _RING_BUFFER_H_
|
||||||
|
|
||||||
|
|
||||||
|
#define ringbuffer_size 32
|
||||||
|
|
||||||
|
extern int rb_count;
|
||||||
|
|
||||||
|
#define rb_free() (ringbuffer_size - rb_count)
|
||||||
|
#define rb_isfull() (rb_count == ringbuffer_size)
|
||||||
|
#define rb_isempty() (rb_count == 0)
|
||||||
|
|
||||||
|
void rb_init(void);
|
||||||
|
void rb_put(char el);
|
||||||
|
char rb_get(void);
|
||||||
|
|
||||||
|
#endif
|
||||||
BIN
roms/qd16boot02_half.smc
Normal file
BIN
roms/qd16boot02_half.smc
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user