21 Commits

Author SHA1 Message Date
Matt Jenkins
ecdf678dac dual sramc 2014-08-27 21:45:25 +01:00
Matt Jenkins
d859d3b71d Imported dual sramc driver
This driver allows you to run two SRAMC devices side-by-side as two
separate rdisk devices.
2014-05-10 21:40:23 +01:00
Matt Jenkins
3409198544 Include new rdisk 2014-05-10 14:05:35 +01:00
Matt Jenkins
d6a6d80d6e Fixed parsing of partition data
The previous method of parsing the prepartition data didn't work right
when you had more than one device.  The new version first finds the
device entry and then parses the partitions from that point on.
2014-04-29 17:31:37 +01:00
Matt Jenkins
07b6681eef Improve configsys option parsing
Up until now all the options in the config system have only been
able to take one word (or one string with no spaces) as a parameter.
This update improves it so it takes everything after the = up until
the end of the line (or the first #) as the parameter.
2014-04-29 13:37:09 +01:00
Serge Vakulenko
1b15bcff49 Fixed bug in assembler: incorrect offset in LUI instruction. 2014-04-24 11:56:01 -07:00
Matt Jenkins
8d5a6f60b1 Merge pull request #15 from alexfru/master
Smaller C: Fix a benign typo
2014-04-22 11:15:46 +01:00
Alexey Frunze
bc98f62608 Fix a benign typo 2014-04-22 02:57:42 -07:00
Matt Jenkins
d3e8eefb58 Merge pull request #14 from alexfru/master
Improve variable initialization in Smaller C
2014-04-21 09:25:32 +01:00
Alexey Frunze
fd04710c23 Fix initialization
In the following
typedef struct S0 { char ac[4]; } T1;
int v26 = (int)&((T1*)0)->ac[3];
int v27 = &((T1*)0)->ac[3];
v27 should be initialized to 3 just as v26.
2014-04-21 01:08:49 -07:00
Alexey Frunze
a0a4e242e6 Improve variable initialization in Smaller C
Improvements:
- support initialization of multidimensional arrays
- support initialization of structures
- support initialization of structures and arrays inside functions
- support static inside functions

Notes:
- Only fully-bracketed (sic) initialization of arrays is supported.
- && and || have been partially replaced with & and | to slightly reduce
code size when self compiling for DOS using -seg16.
2014-04-20 20:59:47 -07:00
Matt Jenkins
557a7f6c8f Merge branch 'master' of github.com:RetroBSD/retrobsd 2014-04-20 20:24:33 +01:00
Matt Jenkins
a7d0838ea8 Created global version variable 2014-04-20 20:24:18 +01:00
Matt Jenkins
8577d7082d Merge pull request #12 from sevan/patch-3
Update README.md
2014-04-19 18:43:52 +01:00
Sevan Janiyan
e9ff914f88 Update README.md
On Mpide 0023-macosx-20130715 the path is /Applications/Mpide.app/Contents/Resources/Java/hardware/tools/avr
not
/Applications/Mpide.app/Contents/Resources/Java/hardware/tools
2014-04-19 18:40:07 +01:00
Matt Jenkins
3ac301cade Improved UECIDE compiler path handling 2014-04-19 18:33:40 +01:00
Matt Jenkins
aabc8d8702 Merge pull request #11 from sevan/patch-2
Update README.md
2014-04-19 18:26:29 +01:00
Matt Jenkins
122d7bc73e Merge pull request #10 from sevan/patch-1
Update Makefile
2014-04-19 18:26:19 +01:00
Sevan Janiyan
660b8c3814 Update README.md
Ties in with https://github.com/RetroBSD/retrobsd/pull/10
2014-04-19 16:19:25 +01:00
Sevan Janiyan
da4d3a3a8f Update Makefile
Add target to build MAX32 kernel with Ethernet Shield support
2014-04-19 15:46:33 +01:00
Matt Jenkins
b5a8255248 Changed %2 to %s in string format 2014-04-19 13:37:42 +01:00
49 changed files with 1632 additions and 1540 deletions

View File

@@ -12,6 +12,7 @@
# Supported boards # Supported boards
# #
MAX32 = sys/pic32/max32/MAX32 MAX32 = sys/pic32/max32/MAX32
MAX32-ETH = sys/pic32/max32-eth/MAX32-ETH
UBW32 = sys/pic32/ubw32/UBW32 UBW32 = sys/pic32/ubw32/UBW32
UBW32UART = sys/pic32/ubw32-uart/UBW32-UART UBW32UART = sys/pic32/ubw32-uart/UBW32-UART
UBW32UARTSDRAM = sys/pic32/ubw32-uart-sdram/UBW32-UART-SDRAM UBW32UARTSDRAM = sys/pic32/ubw32-uart-sdram/UBW32-UART-SDRAM

View File

@@ -40,6 +40,7 @@ TARGET = $(MAXCOLOR) # for the Colour Maximite board
TARGET = $(EXPLORER16) # for the Explorer 16 board TARGET = $(EXPLORER16) # for the Explorer 16 board
TARGET = $(STARTERKIT) # for the PIC32 USB or Ethernet Starter Kit TARGET = $(STARTERKIT) # for the PIC32 USB or Ethernet Starter Kit
TARGET = $(MAX32) # default TARGET = $(MAX32) # default
TARGET = $(MAX32-ETH) # for the chipKIT MAX32 board with Arduino Ethernet shield
TARGET = $(DUINOMITE) # for the Duinomite board with USB console TARGET = $(DUINOMITE) # for the Duinomite board with USB console
TARGET = $(DUINOMITEUART) # for the Duinomite board with UART console TARGET = $(DUINOMITEUART) # for the Duinomite board with UART console
TARGET = $(DUINOMITEE) # for the Duinomite E board with USB console TARGET = $(DUINOMITEE) # for the Duinomite E board with USB console
@@ -89,7 +90,7 @@ on a board used.
#### Max32 board: #### Max32 board:
```shell ```shell
$ cd sys/pic32/ubw32 $ cd sys/pic32/ubw32
$ AVRTOOLS=/Applications/Mpide.app/Contents/Resources/Java/hardware/tools $ AVRTOOLS=/Applications/Mpide.app/Contents/Resources/Java/hardware/tools/avr
$AVRTOOLS/bin/avrdude -C$AVRTOOLS/etc/avrdude.conf -c stk500v2 -p pic32 \ $AVRTOOLS/bin/avrdude -C$AVRTOOLS/etc/avrdude.conf -c stk500v2 -p pic32 \
-P /dev/tty.usbserial-* -b 115200 -v -U flash:w:unix.hex:i -P /dev/tty.usbserial-* -b 115200 -v -U flash:w:unix.hex:i
``` ```

0
cross.mk Executable file → Normal file
View File

View File

@@ -1,47 +0,0 @@
typedef union // LITTLE ENDIAN
{
double value;
struct
{
unsigned long lsw;
unsigned long msw;
} parts;
} ieee_double_shape_type;
/* Get two 32 bit ints from a double. */
#define EXTRACT_WORDS(ix0,ix1,d) \
do { \
ieee_double_shape_type ew_u; \
ew_u.value = (d); \
(ix0) = ew_u.parts.msw; \
(ix1) = ew_u.parts.lsw; \
} while (0)
/* Get the more significant 32 bit int from a double. */
#define GET_HIGH_WORD(i,d) \
do { \
ieee_double_shape_type gh_u; \
gh_u.value = (d); \
(i) = gh_u.parts.msw; \
} while (0)
/* Set a double from two 32 bit ints. */
#define INSERT_WORDS(d,ix0,ix1) \
do { \
ieee_double_shape_type iw_u; \
iw_u.parts.msw = (ix0); \
iw_u.parts.lsw = (ix1); \
(d) = iw_u.value; \
} while (0)
#define SET_HIGH_WORD(d,v) \
do { \
ieee_double_shape_type sh_u; \
sh_u.value = (d); \
sh_u.parts.msw = (v); \
(d) = sh_u.value; \
} while (0)

View File

@@ -12,9 +12,8 @@ extern double sinh(), cosh(), tanh();
extern double gamma(); extern double gamma();
extern double j0(), j1(), jn(), y0(), y1(), yn(); extern double j0(), j1(), jn(), y0(), y1(), yn();
// ###PITO #define HUGE 1.701411733192644270e38 #define HUGE 1.701411733192644270e38
#define HUGE 1.79769313486231570000e+308 #define LOGHUGE 39
#define LOGHUGE 307
int isnanf(float x); int isnanf(float x);
int isnan(double x); int isnan(double x);

View File

@@ -22,8 +22,8 @@
#define va_copy(dest, src) __builtin_va_copy((dest), (src)) #define va_copy(dest, src) __builtin_va_copy((dest), (src))
#ifndef _VA_LIST #ifndef _VA_LIST_T
#define _VA_LIST #define _VA_LIST_T
#ifdef __GNUC__ #ifdef __GNUC__
typedef __builtin_va_list va_list; typedef __builtin_va_list va_list;
#endif #endif

1
lib/.gitignore vendored
View File

@@ -11,4 +11,3 @@ ranlib.h
retroImage retroImage
size size
strip strip
gccdump.s

0
lib/Makefile Executable file → Normal file
View File

View File

@@ -1,57 +0,0 @@
#include <stdio.h>
#include <math.h>
#include <sys/time.h>
void print64x( double x ) {
char* p;
int j;
p = (char *) &x;
for( j=0; j< sizeof(x); j++) {
printf("%02X", p[(sizeof(x)-1)-j]&0xFF);
}
}
void print32x( float x ) {
char* p;
int j;
p = (char *) &x;
for( j=0; j< sizeof(x); j++) {
printf("%02X", p[(sizeof(x)-1)-j]&0xFF);
}
}
int main() {
struct timeval start, stop;
volatile double _p64, q64, r64, e64;
long i;
unsigned long elapsed;
_p64 = 3.1415926535897932384626433832795;
for(i=0;i<100;i++) {
// 64bit test
// 9 degree test input
q64 = i;
// Convert to radians
q64 = q64 * _p64 / 180.0;
// Make the test
gettimeofday(&start, NULL);
r64 = (asin(acos(atan(tan(cos(sin(q64)))))));
gettimeofday(&stop, NULL);
// Convert to degree
r64 = r64 * 180.0 / _p64;
elapsed = stop.tv_usec - start.tv_usec;
printf("%ld degree 64bit test result= %1.15e time= %lu " , i, r64, elapsed );
printf("= 0x");
print64x( r64 );
printf("\n");
}
return 0;
}

View File

@@ -1 +0,0 @@
../generic.mk

View File

@@ -17,7 +17,7 @@ SUBDIR = adb adc-demo ar as awk basic cc chflags chpass \
rdprof ranlib re renice retroforth scm setty sl \ rdprof ranlib re renice retroforth scm setty sl \
sed sh smallc smlrc stty sysctl test uname wiznet xargs \ sed sh smallc smlrc stty sysctl test uname wiznet xargs \
zmodem gtest msec unixbench cron compress date2 tip \ zmodem gtest msec unixbench cron compress date2 tip \
talloc devupdate uucp smux 9degree mathtest scantest talloc devupdate uucp smux
# /sbin # /sbin
SUBDIR += chown chroot disktool fsck getty init \ SUBDIR += chown chroot disktool fsck getty init \

View File

@@ -1592,13 +1592,15 @@ foff16: expr_flags = 0;
opcode |= offset & 0xffff; opcode |= offset & 0xffff;
break; break;
case FHIGH16: /* high 16-bit byte address */ case FHIGH16: /* high 16-bit byte address */
if (relinfo.flags != RABS) { if (expr_flags & EXPR_HI) {
/* %hi function - assume signed offset */ /* %hi function - assume signed offset */
relinfo.flags |= (expr_flags & EXPR_HI) ? RHIGH16S : RHIGH16; relinfo.flags |= RHIGH16S;
relinfo.offset = offset & 0xffff; relinfo.offset = offset & 0xffff;
offset += 0x8000; offset += 0x8000;
opcode |= offset >> 16;
} else {
opcode |= offset & 0xffff;
} }
opcode |= offset >> 16;
break; break;
case FOFF18: /* 18-bit PC-relative word address */ case FOFF18: /* 18-bit PC-relative word address */
case FAOFF18: case FAOFF18:

View File

@@ -1,31 +0,0 @@
#==========================================
# Makefile: makefile for adc-demo
# Copyright 2012 Majenko Technolohies
# (matt@majenko.co.uk
# Last Modified: 29/01/2012
#==========================================
TOPSRC = $(shell cd ../../..; pwd)
include $(TOPSRC)/target.mk
PWD = $(shell pwd)
PROG = $(shell basename "$(PWD)")
OBJS = $(PROG).o
SRCS = $(PROG).c
all: $(PROG)
-include Makefile.app
$(PROG): ${OBJS}
${CC} ${LDFLAGS} -o $(PROG).elf ${OBJS} ${LIBS}
${OBJDUMP} -S $(PROG).elf > $(PROG).dis
${SIZE} $(PROG).elf
${ELF2AOUT} $(PROG).elf $@
clean:
-rm -f $(PROG) ${OBJS} $(PROG).elf $(PROG).dis
install: all
install $(PROG) $(DESTDIR)/bin/

View File

@@ -61,7 +61,7 @@ $Binits.o: inits.c; $(CC) $(CFLAGS) -c -I. -o $@ $<
$Binput.o: input.c; $(CC) $(CFLAGS) -c -I. -o $@ $< $Binput.o: input.c; $(CC) $(CFLAGS) -c -I. -o $@ $<
$Blex.o: lex.c; $(CC) $(CFLAGS) -c -I. -o $@ $< $Blex.o: lex.c; $(CC) $(CFLAGS) -c -I. -o $@ $<
$Blist.o: list.c; $(CC) $(CFLAGS) -c -I. -o $@ $< $Blist.o: list.c; $(CC) $(CFLAGS) -c -I. -o $@ $<
$Bmain.o: main.c; $(CC) $(CFLAGS) -DVERSION=\"`svnversion`\" -c -I. -o $@ $< $Bmain.o: main.c; $(CC) $(CFLAGS) -DVERSION=\"$(VERSION)\" -c -I. -o $@ $<
$Bnull.o: null.c; $(CC) $(CFLAGS) -c -I. -o $@ $< $Bnull.o: null.c; $(CC) $(CFLAGS) -c -I. -o $@ $<
$Boutput.o: output.c; $(CC) $(CFLAGS) -c -I. -o $@ $< $Boutput.o: output.c; $(CC) $(CFLAGS) -c -I. -o $@ $<
$Bprof.o: prof.c; $(CC) $(CFLAGS) -c -I. -o $@ $< $Bprof.o: prof.c; $(CC) $(CFLAGS) -c -I. -o $@ $<

View File

@@ -1 +0,0 @@
../generic.mk

View File

@@ -1,49 +0,0 @@
// Pito 12/2013
#include <stdio.h>
#include <math.h>
// print out double (IEEE 64bit) variable in HEX
// ie. 9.0 is 4022000000000000
// more on http://babbage.cs.qc.cuny.edu/IEEE-754/
void print64x( double x ) {
const unsigned char* p;
int j;
p = (unsigned char *) &x;
printf("%02X", p[7]);
printf("%02X", p[6]);
printf("%02X", p[5]);
printf("%02X", p[4]);
printf("%02X", p[3]);
printf("%02X", p[2]);
printf("%02X", p[1]);
printf("%02X", p[0]);
}
void print32x( float x ) {
const char* p;
int j;
p = (char *) &x;
for( j=0; j< sizeof(x); j++) {
printf("%02X", p[(sizeof(x)-1)-j]&0xFF);
}
}
int main() {
volatile double num1 = 1.2499999999999998193580478994e-10;
volatile double num2 = 2.16000000000000081281633984229e-10;
volatile double res = 0;
res = num1 + num2;
// print64x(num1);
// printf(" + ");
// print64x(num2);
// printf(" = ");
// print64x(res);
// printf("\n");
printf("%1.15e + %1.15e = %1.15e\n", num1, num2, res);
return 0;
}

View File

@@ -1 +0,0 @@
../generic.mk

View File

@@ -1,84 +0,0 @@
// Pito 12/2013
#include <stdio.h>
#include <math.h>
// print out double (IEEE 64bit) variable in HEX
// ie. 9.0 is 4022000000000000
// more on http://babbage.cs.qc.cuny.edu/IEEE-754/
void print64x( double x ) {
const unsigned char* p;
int j;
p = (unsigned char *) &x;
printf("%02X", p[7]);
printf("%02X", p[6]);
printf("%02X", p[5]);
printf("%02X", p[4]);
printf("%02X", p[3]);
printf("%02X", p[2]);
printf("%02X", p[1]);
printf("%02X", p[0]);
}
void print32x( float x ) {
const char* p;
int j;
p = (char *) &x;
for( j=0; j< sizeof(x); j++) {
printf("%02X", p[(sizeof(x)-1)-j]&0xFF);
}
}
int main() {
double num;
int i;
double sum;
FILE *InFile, *OutFile;
char str[100];
double backup;
double result;
if ((OutFile = fopen("num.dat","w")) == 0) {
printf("num.dat not found\n");
return (1);
}
for (i=0; i<=10000; i++) {
num = 0.0001L * (double)(i);
num = num * num * num;
fprintf(OutFile, "%1.15e\n", num);
}
fclose(OutFile);
if ((InFile = fopen("num.dat","r")) == 0) {
printf("num.dat not found\n");
return (1);
}
sum = 0;
num = 0;
for (i=0; i<=10000; i++) {
backup = sum;
fgets (str, 80, InFile);
sscanf (str,"%le",&num);
result = sum + num;
if (sum != backup) {
printf("*** SUM CHANGED: %1.15e => %1.15e ***\n", backup, sum);
}
sum = result;
}
printf("Sum test result = %1.15e\n", sum);
printf("Shall be result = 2.500500025000002e+03\n");
printf("Sum test result (HEX) = ");
print64x( sum );
printf("\n");
printf("Shall be result (HEX) = 40A389000346DC62\n");
fclose(InFile);
return 0;
}

File diff suppressed because it is too large Load Diff

0
src/libc/compat/Makefile Executable file → Normal file
View File

4
src/libc/gen/Makefile Executable file → Normal file
View File

@@ -19,7 +19,7 @@ STDSRC = abort.c alarm.c atof.c atoi.c atol.c calloc.c closedir.c crypt.c \
getpass.c getpwent.c getloadavg.c getmntinfo.c \ getpass.c getpwent.c getloadavg.c getmntinfo.c \
getttyent.c getttynam.c getusershell.c getwd.c \ getttyent.c getttynam.c getusershell.c getwd.c \
initgroups.c isatty.c isinff.c isnanf.c ldexp.c malloc.c mktemp.c \ initgroups.c isatty.c isinff.c isnanf.c ldexp.c malloc.c mktemp.c \
modff.c modf.c ndbm.c nlist.c knlist.c opendir.c perror.c popen.c \ modff.c ndbm.c nlist.c knlist.c opendir.c perror.c popen.c \
psignal.c qsort.c random.c readdir.c regex.c scandir.c \ psignal.c qsort.c random.c readdir.c regex.c scandir.c \
seekdir.c setmode.c sethostname.c setenv.c siglist.c \ seekdir.c setmode.c sethostname.c setenv.c siglist.c \
signal.c siginterrupt.c sigsetops.c \ signal.c siginterrupt.c sigsetops.c \
@@ -36,7 +36,7 @@ STDOBJ = abort.o alarm.o atof.o atoi.o atol.o calloc.o closedir.o crypt.o \
getpass.o getpwent.o getloadavg.o getmntinfo.o \ getpass.o getpwent.o getloadavg.o getmntinfo.o \
getttyent.o getttynam.o getusershell.o getwd.o \ getttyent.o getttynam.o getusershell.o getwd.o \
initgroups.o isatty.o isinff.o isnanf.o ldexp.o malloc.o mktemp.o \ initgroups.o isatty.o isinff.o isnanf.o ldexp.o malloc.o mktemp.o \
modff.o modf.o ndbm.o nlist.o knlist.o opendir.o perror.o popen.o \ modff.o ndbm.o nlist.o knlist.o opendir.o perror.o popen.o \
psignal.o qsort.o random.o readdir.o regex.o scandir.o \ psignal.o qsort.o random.o readdir.o regex.o scandir.o \
seekdir.o setmode.o sethostname.o setenv.o siglist.o \ seekdir.o setmode.o sethostname.o setenv.o siglist.o \
signal.o siginterrupt.o sigsetops.o \ signal.o siginterrupt.o sigsetops.o \

View File

@@ -27,4 +27,4 @@ int isinff (float x)
/* /*
* For PIC32, double is the same as float. * For PIC32, double is the same as float.
*/ */
//int isinf (double x) __attribute__((alias ("isinff"))); int isinf (double x) __attribute__((alias ("isinff")));

View File

@@ -27,4 +27,4 @@ int isnanf (float x)
/* /*
* For PIC32, double is the same as float. * For PIC32, double is the same as float.
*/ */
//int isnan (double x) __attribute__((alias ("isnanf"))); int isnan (double x) __attribute__((alias ("isnanf")));

View File

@@ -1,46 +1,46 @@
#include <math.h> #include <math.h>
#include <ieee.h>
static const double
two54 = 1.80143985094819840000e+16, /* 0x43500000, 0x00000000 */
twom54 = 5.55111512312578270212e-17, /* 0x3C900000, 0x00000000 */
huge = 1.0e+308,
tiny = 1.0e-307;
static double
_copysign(double x, double y)
{
unsigned long hx,hy;
GET_HIGH_WORD(hx,x);
GET_HIGH_WORD(hy,y);
SET_HIGH_WORD(x,(hx&0x7fffffff)|(hy&0x80000000));
return x;
}
double double
ldexp(double x, int n) ldexp(fr, exp)
double fr;
int exp;
{ {
unsigned long k,hx,lx; double huge = 1.701411834604692293e38;
EXTRACT_WORDS(hx,lx,x); int neg;
k = (hx&0x7ff00000)>>20; /* extract exponent */ int i;
if (k==0) { /* 0 or subnormal x */
if ((lx|(hx&0x7fffffff))==0) return x; /* +-0 */ neg = 0;
x *= two54; if (fr < 0) {
GET_HIGH_WORD(hx,x); fr = -fr;
k = ((hx&0x7ff00000)>>20) - 54; neg = 1;
if (n< -50000) return tiny*x; /*underflow*/
}
if (k==0x7ff) return x+x; /* NaN or Inf */
k = k+n;
if (k > 0x7fe) return huge*_copysign(huge,x); /* overflow */
if (k > 0) /* normal result */
{SET_HIGH_WORD(x,(hx&0x800fffff)|(k<<20)); return x;}
if (k <= -54) {
if (n > 50000) /* in case integer overflow in n+k */
return huge*_copysign(huge,x); /*overflow*/
else return tiny*_copysign(tiny,x); /*underflow*/
} }
k += 54; /* subnormal result */ fr = frexp(fr, &i);
SET_HIGH_WORD(x,(hx&0x800fffff)|(k<<20)); while (fr < 0.5) {
return x*twom54; fr = 2*fr;
i = i-1;
}
exp = exp+i;
if (exp > 127) {
if (neg)
return(-huge);
else
return(huge);
}
if (exp < -127)
return(0);
while (exp > 30) {
fr = fr*(1L<<30);
exp = exp-30;
}
while (exp < -30) {
fr = fr/(1L<<30);
exp = exp+30;
}
if (exp > 0)
fr = fr*(1L<<exp);
if (exp < 0)
fr = fr/(1L<<-exp);
if (neg)
fr = -fr;
return(fr);
} }

View File

@@ -7,7 +7,18 @@
* is preserved. * is preserved.
*/ */
#include <math.h> #include <math.h>
#include <ieee.h>
/* Get two 32 bit ints from a double. */
#define EXTRACT_WORDS(high,low,d) \
high = *(unsigned long long*) &d; \
low = (*(unsigned long long*) &d) >> 32
/* Set a double from two 32 bit ints. */
#define INSERT_WORDS(d,high,low) \
*(unsigned long long*) &(x) = (unsigned long long) (high) << 32 | (low)
/* /*
* modf(double x, double *iptr) * modf(double x, double *iptr)
@@ -26,12 +37,10 @@ double modf (double x, double *iptr)
unsigned long i; unsigned long i;
EXTRACT_WORDS (i0, i1, x); EXTRACT_WORDS (i0, i1, x);
//
j0 = ((i0 >> 20) & 0x7ff) - 0x3ff; /* exponent of x */ j0 = ((i0 >> 20) & 0x7ff) - 0x3ff; /* exponent of x */
if (j0 < 20) { /* integer part in high x */ if (j0 < 20) { /* integer part in high x */
if (j0 < 0) { /* |x|<1 */ if (j0 < 0) { /* |x|<1 */
INSERT_WORDS (*iptr, i0 & 0x80000000, 0); INSERT_WORDS (*iptr, i0 & 0x80000000, 0);
//
/* *iptr = +-0 */ /* *iptr = +-0 */
return x; return x;
} else { } else {
@@ -39,12 +48,10 @@ double modf (double x, double *iptr)
if (((i0 & i) | i1) == 0) { /* x is integral */ if (((i0 & i) | i1) == 0) { /* x is integral */
*iptr = x; *iptr = x;
INSERT_WORDS (x, i0 & 0x80000000, 0); INSERT_WORDS (x, i0 & 0x80000000, 0);
//
/* return +-0 */ /* return +-0 */
return x; return x;
} else { } else {
INSERT_WORDS (*iptr, i0 & (~i), 0); INSERT_WORDS (*iptr, i0 & (~i), 0);
//
return x - *iptr; return x - *iptr;
} }
} }
@@ -55,7 +62,6 @@ double modf (double x, double *iptr)
return x * one; return x * one;
INSERT_WORDS (x, i0 & 0x80000000, 0); INSERT_WORDS (x, i0 & 0x80000000, 0);
//
/* return +-0 */ /* return +-0 */
return x; return x;
} else { /* fraction part in low x */ } else { /* fraction part in low x */
@@ -63,12 +69,10 @@ double modf (double x, double *iptr)
if ((i1 & i) == 0) { /* x is integral */ if ((i1 & i) == 0) { /* x is integral */
*iptr = x; *iptr = x;
INSERT_WORDS (x, i0 & 0x80000000, 0); INSERT_WORDS (x, i0 & 0x80000000, 0);
//
/* return +-0 */ /* return +-0 */
return x; return x;
} else { } else {
INSERT_WORDS (*iptr, i0, i1 & (~i)); INSERT_WORDS (*iptr, i0, i1 & (~i));
//
return x - *iptr; return x - *iptr;
} }
} }

View File

@@ -52,4 +52,4 @@ float modff (float fx, float *iptr)
/* /*
* For PIC32, double is the same as float. * For PIC32, double is the same as float.
*/ */
//double modf (double x, double *iptr) __attribute__((alias ("modff"))); double modf (double x, double *iptr) __attribute__((alias ("modff")));

0
src/libc/gen/ndbm.c Executable file → Normal file
View File

0
src/libc/mips/sys/Makefile Executable file → Normal file
View File

0
src/libc/stdio/Makefile Executable file → Normal file
View File

View File

@@ -42,9 +42,7 @@
#include <math.h> #include <math.h>
/* Max number conversion buffer length: a long in base 2, plus NUL byte. */ /* Max number conversion buffer length: a long in base 2, plus NUL byte. */
//#define MAXNBUF (sizeof(long) * 8 + 1) #define MAXNBUF (sizeof(long) * 8 + 1)
/* Max number conversion buffer length: MAXEXP(308) + MAXFRACTION(15) + 2 */
#define MAXNBUF 308+15+2
static unsigned char *ksprintn (unsigned char *buf, unsigned long v, unsigned char base, static unsigned char *ksprintn (unsigned char *buf, unsigned long v, unsigned char base,
int width, unsigned char *lp); int width, unsigned char *lp);
@@ -63,8 +61,6 @@ _doprnt (char const *fmt, va_list ap, FILE *stream)
int n, width, dwidth, retval, uppercase, extrazeros, sign; int n, width, dwidth, retval, uppercase, extrazeros, sign;
unsigned long ul; unsigned long ul;
double d;
if (! stream) if (! stream)
return 0; return 0;
if (! fmt) if (! fmt)
@@ -365,11 +361,7 @@ number: if (sign && ((long) ul != 0L)) {
case 'F': case 'F':
case 'g': case 'g':
case 'G': { case 'G': {
double d = va_arg (ap, double);
// ---va_arg alignment fix
d = va_arg(ap, double);
// ---
/* /*
* don't do unrealistic precision; just pad it with * don't do unrealistic precision; just pad it with
* zeroes later, so buffer size stays rational. * zeroes later, so buffer size stays rational.
@@ -591,11 +583,10 @@ cvt (double number, int prec, int sharpflag, unsigned char *negp, unsigned char
* get integer portion of number; put into the end of the buffer; the * get integer portion of number; put into the end of the buffer; the
* .01 is added for modf (356.0 / 10, &integer) returning .59999999... * .01 is added for modf (356.0 / 10, &integer) returning .59999999...
*/ */
p = endp - 1; for (p = endp - 1; integer; ++expcnt) {
for (; integer && p >= startp; ++expcnt) { tmp = modf (integer / 10, &integer);
tmp = modf(integer * 0.1L , &integer); *p-- = (int) ((tmp + .01) * 10) + '0';
*p-- = (int)((tmp + .01L) * 10) + '0'; }
}
switch (fmtch) { switch (fmtch) {
case 'f': case 'f':
/* reverse integer into beginning of buffer */ /* reverse integer into beginning of buffer */

View File

@@ -1,10 +1,6 @@
#include <stdio.h> #include <stdio.h>
#include <ctype.h> #include <ctype.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#define HAVE_FLOAT 1
#define SPC 01 #define SPC 01
#define STP 02 #define STP 02

0
src/libc/stdlib/Makefile Executable file → Normal file
View File

View File

@@ -7,7 +7,7 @@ TOPSRC = $(shell cd ../../..; pwd)
include $(TOPSRC)/target.mk include $(TOPSRC)/target.mk
DEFS = DEFS =
CFLAGS += ${DEFS} CFLAGS += ${DEFS} -Os
SRCS = strcspn.c strpbrk.c strerror.c strsep.c strspn.c strstr.c strtok.c strtok_r.c SRCS = strcspn.c strpbrk.c strerror.c strsep.c strspn.c strstr.c strtok.c strtok_r.c
OBJS = strcspn.o strpbrk.o strerror.o strsep.o strspn.o strstr.o strtok.o strtok_r.o OBJS = strcspn.o strpbrk.o strerror.o strsep.o strspn.o strstr.o strtok.o strtok_r.o

View File

@@ -39,17 +39,15 @@ asin(arg)
double double
acos(arg) acos(arg)
double arg; double arg;
{ {
double sign = 1.0; if(arg < 0)
if(arg < 0.0){ arg = -arg;
arg = -arg;
sign = -1.0;
}
if(arg > 1.0){
errno = EDOM;
return(0.0);
}
return(pio2 - sign*asin(arg)); if(arg > 1.){
errno = EDOM;
return(0.);
}
return(pio2 - asin(arg));
} }

View File

@@ -13,7 +13,7 @@
*/ */
#include <math.h> #include <math.h>
static double sq2p1 =2.414213562373095048802e0; double static sq2p1 =2.414213562373095048802e0;
static double sq2m1 = .414213562373095048802e0; static double sq2m1 = .414213562373095048802e0;
static double pio2 =1.570796326794896619231e0; static double pio2 =1.570796326794896619231e0;
static double pio4 = .785398163397448309615e0; static double pio4 = .785398163397448309615e0;

View File

@@ -1,47 +1,23 @@
typedef union // LITTLE ENDIAN /* Get two 32 bit ints from a double. */
#define EXTRACT_WORDS(high,low,d) \
high = *(unsigned long long*) &d; \
low = (*(unsigned long long*) &d) >> 32
/* Set a double from two 32 bit ints. */
#define INSERT_WORDS(d,high,low) \
*(unsigned long long*) &(x) = (unsigned long long) (high) << 32 | (low)
typedef union
{ {
double value; double value;
struct struct
{ {
unsigned long lsw; uint32_t lsw;
unsigned long msw; uint32_t msw;
} parts; } parts;
} ieee_double_shape_type; } ieee_double_shape_type;
/* Get two 32 bit ints from a double. */
#define EXTRACT_WORDS(ix0,ix1,d) \
do { \
ieee_double_shape_type ew_u; \
ew_u.value = (d); \
(ix0) = ew_u.parts.msw; \
(ix1) = ew_u.parts.lsw; \
} while (0)
/* Get the more significant 32 bit int from a double. */
#define GET_HIGH_WORD(i,d) \
do { \
ieee_double_shape_type gh_u; \
gh_u.value = (d); \
(i) = gh_u.parts.msw; \
} while (0)
/* Set a double from two 32 bit ints. */
#define INSERT_WORDS(d,ix0,ix1) \
do { \
ieee_double_shape_type iw_u; \
iw_u.parts.msw = (ix0); \
iw_u.parts.lsw = (ix1); \
(d) = iw_u.value; \
} while (0)
#define SET_HIGH_WORD(d,v) \
do { \
ieee_double_shape_type sh_u; \
sh_u.value = (d); \
sh_u.parts.msw = (v); \
(d) = sh_u.value; \
} while (0)

View File

@@ -113,7 +113,6 @@ struct sigstack {
struct sigcontext { struct sigcontext {
int sc_onstack; /* sigstack state to restore */ int sc_onstack; /* sigstack state to restore */
long sc_mask; /* signal mask to restore */ long sc_mask; /* signal mask to restore */
int sc_align[2]; /* align to 16 bytes */
int sc_r1; /* r1 to restore */ int sc_r1; /* r1 to restore */
int sc_r2; /* and other registers */ int sc_r2; /* and other registers */
int sc_r3; int sc_r3;

2
sys/kernel/kern_exec.c Executable file → Normal file
View File

@@ -432,7 +432,7 @@ badarg:
*/ */
ucp = USER_DATA_END - nc - NBPW; ucp = USER_DATA_END - nc - NBPW;
ap = ucp - na*NBPW - 2*NBPW; ap = ucp - na*NBPW - 2*NBPW;
u.u_frame [FRAME_SP] = (ap - 16) & ~0xf; /* align to 16 bytes */ u.u_frame [FRAME_SP] = ap - 16;
u.u_frame [FRAME_R4] = na - ne; /* $a0 := argc */ u.u_frame [FRAME_R4] = na - ne; /* $a0 := argc */
u.u_frame [FRAME_R5] = ap; /* $a1 := argv */ u.u_frame [FRAME_R5] = ap; /* $a1 := argv */
u.u_frame [FRAME_R6] = ap + (na-ne+1)*NBPW; /* $a2 := env */ u.u_frame [FRAME_R6] = ap + (na-ne+1)*NBPW; /* $a2 := env */

View File

@@ -69,10 +69,14 @@ const struct diskentry disks[] = {
{sd_preinit, sdinit, sddeinit, sdopen, sdsize, card_read, card_write, 1, RD_DEFAULT}, {sd_preinit, sdinit, sddeinit, sdopen, sdsize, card_read, card_write, 1, RD_DEFAULT},
#endif #endif
#ifdef SRAMC_ENABLED #ifdef SRAMC0_ENABLED
{sramc_init, no_init, no_deinit, sramc_open, sramc_size, sramc_read, sramc_write, 0, RD_PREPART}, {sramc_init, no_init, no_deinit, sramc_open, sramc_size, sramc_read, sramc_write, 0, RD_PREPART},
#endif #endif
#ifdef SRAMC1_ENABLED
{sramc_init, no_init, no_deinit, sramc_open, sramc_size, sramc_read, sramc_write, 1, RD_PREPART},
#endif
#ifdef SDRAMP_ENABLED #ifdef SDRAMP_ENABLED
{sdramp_preinit, no_init, no_deinit, sdramp_open, sdramp_size, sdramp_read, sdramp_write, 0, RD_PREPART}, {sdramp_preinit, no_init, no_deinit, sdramp_open, sdramp_size, sdramp_read, sdramp_write, 0, RD_PREPART},
#endif #endif
@@ -576,100 +580,116 @@ struct buf *prepartition_device(char *devname)
int pnum = 0; int pnum = 0;
int start = 2; int start = 2;
char dev[9]; char dev[9];
char size[9]; int size;
char type[5]; int devsize = 0;
int pos = 0; char *ptdata = NULL;
p = prepartition_schema+1; char *ppstart = prepartition_schema;
q = p;
while (*ppstart == '(') {
ppstart++;
}
printf("PP Schema: %s\n",prepartition_schema); printf("PP Schema: %s\n",prepartition_schema);
printf("Attempting partition of %s...\n", devname);
// Let's get the devname into the "dev" variable and append a ":" on the end of it.
q = dev;
for (p=devname; *p; p++) {
*q = *p;
q++;
devsize++;
}
*q++ = ':';
*q = 0;
devsize++;
printf("%%DBG-PPT: Device Name: %s (%d chars)\n", dev, devsize);
// Now we want to scan the string to find the device name. It has to either
// be at the start of the string or be prefixed by a ' '
for (p = ppstart; *(p+devsize); p++) {
if (strncmp(p, dev, devsize) == 0) {
printf("%%DBG-PPT: Device found.\n");
ptdata = p + devsize;
break;
}
}
if (ptdata == NULL) {
printf("%%DBG-PPT: Device not in partition schema\n");
return NULL;
}
// We must have a pointer to the start of the partition data in ptdata now.
// Now to scan through it and get the data into the structures.
printf("%%DBG-PPT: We now like this bit: %s\n", ptdata);
bp = getnewbuf(); bp = getnewbuf();
if(!bp) if(!bp) {
{ printf("%%DBG-PPT: Unable to allocate buffer!\n");
return NULL; return NULL;
} }
mbr = (struct mbr *)bp->b_addr; mbr = (struct mbr *)bp->b_addr;
while(*p) // Ok, let's scan through the data one character at a time until we hit either a
{ // space or a close-bracket (indicating the end of the data).
while(*q && *q != ' ')
q++;
if(*q == ' ')
{
*q = 0;
q++;
}
pos = 0; p = ptdata;
while((*p) && (*p != ':')) pnum = 0;
{ while ((*p != ' ') && (*p != ')')) {
dev[pos++] = *p; // First let's look to see if we have a valid partition type - it's 2 characters
dev[pos] = 0; // followed by an '@'.
p++;
}
if((*p) == ':') printf("%%DBG-PPT: Looking at: %s\n", p);
{
p++;
} else {
printf("Device Format Error (%c)\n",*p);
brelse(bp);
return NULL;
}
while((*p) && (*p != ' ')) // Active swap space
{ if (strncmp(p, "sa@", 3) == 0) {
pos = 0; mbr->partitions[pnum].type=RDISK_SWAP;
while((*p) && (*p != '@')) mbr->partitions[pnum].status = 0x80;
{ } else
type[pos++] = *p;
type[pos] = 0;
p++;
}
if((*p) == '@') // Inactive swap space
{ if (strncmp(p, "sw@", 3) == 0) {
p++; mbr->partitions[pnum].type=RDISK_SWAP;
} else { } else
printf("Type Format Error\n");
brelse(bp);
return NULL;
}
pos = 0; // General UFS filesystem
while((*p) && (*p != ',') && (*p != ' ') && (*p != ')')) if (strncmp(p, "fs@", 3) == 0) {
{ mbr->partitions[pnum].type=RDISK_FS;
size[pos++] = *p; } else {
size[pos] = 0; printf("%%DBG-PPT: Error parsing partition data: %s\n", p);
p++; brelse(bp);
} return NULL;
}
printf("Found partition on %s of type %s and size %s\n", p+=3;
dev,type,size);
if(!strcmp(dev,devname)) size = 0;
{ while ((*p >= '0') && (*p <= '9')) {
if(!strcmp("sw",type)) size *= 10;
mbr->partitions[pnum].type=RDISK_SWAP; size += *p - '0';
if(!strcmp("sa",type)) p++;
{ }
mbr->partitions[pnum].type=RDISK_SWAP;
mbr->partitions[pnum].status = 0x80;
}
if(!strcmp("fs",type))
mbr->partitions[pnum].type=RDISK_FS;
mbr->partitions[pnum].lbastart = start; mbr->partitions[pnum].lbastart = start;
mbr->partitions[pnum].lbalength = atoi(size)<<1; mbr->partitions[pnum].lbalength = size << 1;
start += mbr->partitions[pnum].lbalength;
pnum++; printf("%%DBG-PPT: Added partition %d type %d size %d at offset %d\n",
} pnum,
p++; mbr->partitions[pnum].type,
} mbr->partitions[pnum].lbalength,
} mbr->partitions[pnum].lbastart
);
start += (size << 1);
pnum++;
if (*p == ',') {
p++;
}
}
if(pnum > 0) if(pnum > 0)
{ {

View File

@@ -5,7 +5,8 @@ SUBDIR = baremetal dip duinomite duinomite-uart duinomite-e \
duinomite-e-uart explorer16 max32 max32-eth maximite \ duinomite-e-uart explorer16 max32 max32-eth maximite \
meb pinguino-micro starter-kit ubw32 ubw32-uart \ meb pinguino-micro starter-kit ubw32 ubw32-uart \
ubw32-uart-sdram baremetal fubarino fubarino-uart \ ubw32-uart-sdram baremetal fubarino fubarino-uart \
fubarino-uart-sramc mmb-mx7 maximite-color 32mxsdram-uart fubarino-uart-sramc mmb-mx7 maximite-color \
32mxsdram-uart
default: default:

View File

@@ -2,6 +2,7 @@ always
file rd_sramc.o file rd_sramc.o
require rdisk require rdisk
define SRAMC_ENABLED YES define SRAMC_ENABLED YES
define SRAMC%0_ENABLED YES
end always end always
option data option data

View File

@@ -24,29 +24,19 @@
* The values are dependant upon the presence of the -fno-short-double * The values are dependant upon the presence of the -fno-short-double
* compiler option. * compiler option.
*/ */
//#define DBL_EPSILON FLT_EPSILON #define DBL_EPSILON FLT_EPSILON
//#define DBL_MAX FLT_MAX #define DBL_MAX FLT_MAX
//#define DBL_MIN FLT_MIN #define DBL_MIN FLT_MIN
//#define DBL_DIG FLT_DIG #define DBL_DIG FLT_DIG
//#define DBL_MANT_DIG FLT_MANT_DIG #define DBL_MANT_DIG FLT_MANT_DIG
//#define DBL_MAX_10_EXP FLT_MAX_10_EXP #define DBL_MAX_10_EXP FLT_MAX_10_EXP
//#define DBL_MAX_EXP FLT_MAX_EXP #define DBL_MAX_EXP FLT_MAX_EXP
//#define DBL_MIN_10_EXP FLT_MIN_10_EXP #define DBL_MIN_10_EXP FLT_MIN_10_EXP
//#define DBL_MIN_EXP FLT_MIN_EXP #define DBL_MIN_EXP FLT_MIN_EXP
/* /*
* These values provide information pertaining to the long double type. * These values provide information pertaining to the long double type.
*/ */
#define DBL_EPSILON 2.2204460492503131E-16
#define DBL_MAX 1.7976931348623157E+308
#define DBL_MIN 2.2250738585072014E-308
#define DBL_DIG 15
#define DBL_MANT_DIG 53
#define DBL_MAX_10_EXP 308
#define DBL_MAX_EXP 1024
#define DBL_MIN_10_EXP (-307)
#define DBL_MIN_EXP (-1021)
#define LDBL_EPSILON 2.2204460492503131E-16 #define LDBL_EPSILON 2.2204460492503131E-16
#define LDBL_MAX 1.7976931348623157E+308 #define LDBL_MAX 1.7976931348623157E+308
#define LDBL_MIN 2.2250738585072014E-308 #define LDBL_MIN 2.2250738585072014E-308

View File

@@ -6,7 +6,7 @@ S = ../../../tools/configsys/../../sys/kernel
vpath %.c $(M):$(S) vpath %.c $(M):$(S)
vpath %.S $(M):$(S) vpath %.S $(M):$(S)
KERNOBJ += _startup.o adc.o clock.o cons.o devsw.o exception.o glcd.o gpio.o init_main.o init_sysent.o kern_clock.o kern_descrip.o kern_exec.o kern_exit.o kern_fork.o kern_mman.o kern_proc.o kern_prot.o kern_prot2.o kern_resource.o kern_sig.o kern_sig2.o kern_subr.o kern_synch.o kern_sysctl.o kern_time.o machdep.o mem.o oc.o rd_sd.o rdisk.o signal.o spi_bus.o subr_prf.o subr_rmap.o swap.o sys_generic.o sys_inode.o sys_pipe.o sys_process.o syscalls.o sysctl.o tty.o tty_subr.o tty_tty.o ufs_alloc.o ufs_bio.o ufs_bmap.o ufs_dsort.o ufs_fio.o ufs_inode.o ufs_mount.o ufs_namei.o ufs_subr.o ufs_syscalls.o ufs_syscalls2.o usb_device.o usb_function_cdc.o usb_uart.o vers.o vfs_vnops.o vm_sched.o vm_swap.o vm_swp.o KERNOBJ += _startup.o adc.o clock.o cons.o devsw.o exception.o gpio.o init_main.o init_sysent.o kern_clock.o kern_descrip.o kern_exec.o kern_exit.o kern_fork.o kern_mman.o kern_proc.o kern_prot.o kern_prot2.o kern_resource.o kern_sig.o kern_sig2.o kern_subr.o kern_synch.o kern_sysctl.o kern_time.o machdep.o mem.o oc.o rd_sd.o rd_sramc.o rdisk.o signal.o spi.o spi_bus.o subr_prf.o subr_rmap.o swap.o sys_generic.o sys_inode.o sys_pipe.o sys_process.o syscalls.o sysctl.o tty.o tty_subr.o tty_tty.o uart.o ufs_alloc.o ufs_bio.o ufs_bmap.o ufs_dsort.o ufs_fio.o ufs_inode.o ufs_mount.o ufs_namei.o ufs_subr.o ufs_syscalls.o ufs_syscalls2.o vers.o vfs_vnops.o vm_sched.o vm_swap.o vm_swp.o
EXTRA_TARGETS = bootloader EXTRA_TARGETS = bootloader
DEFS += -DADC_ENABLED=YES DEFS += -DADC_ENABLED=YES
@@ -16,11 +16,11 @@ DEFS += -DBL_CRYSTAL=8
DEFS += -DBL_LED_PIN=5 DEFS += -DBL_LED_PIN=5
DEFS += -DBL_LED_PORT=TRISE DEFS += -DBL_LED_PORT=TRISE
DEFS += -DBUS_DIV=1 DEFS += -DBUS_DIV=1
DEFS += -DBUS_KHZ=80000 DEFS += -DBUS_KHZ=120000
DEFS += -DCONSOLE_DEVICE=ttyUSB0 DEFS += -DCONSOLE_DEVICE=tty1
DEFS += -DCPU_IDIV=2 DEFS += -DCPU_IDIV=1
DEFS += -DCPU_KHZ=80000 DEFS += -DCPU_KHZ=120000
DEFS += -DCPU_MUL=20 DEFS += -DCPU_MUL=15
DEFS += -DCPU_ODIV=1 DEFS += -DCPU_ODIV=1
DEFS += -DCRYSTAL=8 DEFS += -DCRYSTAL=8
DEFS += -DDC0_DEBUG=DEVCFG0_DEBUG_DISABLED DEFS += -DDC0_DEBUG=DEVCFG0_DEBUG_DISABLED
@@ -35,8 +35,8 @@ DEFS += -DDC1_POSCMOD=DEVCFG1_POSCMOD_HS
DEFS += -DDC1_SOSC=0 DEFS += -DDC1_SOSC=0
DEFS += -DDC1_WDTEN=0 DEFS += -DDC1_WDTEN=0
DEFS += -DDC1_WDTPS=DEVCFG1_WDTPS_1 DEFS += -DDC1_WDTPS=DEVCFG1_WDTPS_1
DEFS += -DDC2_PLLIDIV=DEVCFG2_FPLLIDIV_2 DEFS += -DDC2_PLLIDIV=DEVCFG2_FPLLIDIV_1
DEFS += -DDC2_PLLMUL=DEVCFG2_FPLLMUL_20 DEFS += -DDC2_PLLMUL=DEVCFG2_FPLLMUL_15
DEFS += -DDC2_PLLODIV=DEVCFG2_FPLLODIV_1 DEFS += -DDC2_PLLODIV=DEVCFG2_FPLLODIV_1
DEFS += -DDC2_UPLL=0 DEFS += -DDC2_UPLL=0
DEFS += -DDC2_UPLLIDIV=DEVCFG2_UPLLIDIV_2 DEFS += -DDC2_UPLLIDIV=DEVCFG2_UPLLIDIV_2
@@ -48,7 +48,6 @@ DEFS += -DDC3_USBID=DEVCFG3_FUSBIDIO
DEFS += -DDC3_USERID=0xffff DEFS += -DDC3_USERID=0xffff
DEFS += -DDC3_VBUSON=DEVCFG3_FVBUSONIO DEFS += -DDC3_VBUSON=DEVCFG3_FVBUSONIO
DEFS += -DFLASH_JUMP=0x9d000000 DEFS += -DFLASH_JUMP=0x9d000000
DEFS += -DGLCD_ENABLED=YES
DEFS += -DGPIO_ENABLED=YES DEFS += -DGPIO_ENABLED=YES
DEFS += -DHID_FEATURE_REPORT_BYTES=2 DEFS += -DHID_FEATURE_REPORT_BYTES=2
DEFS += -DHID_INPUT_REPORT_BYTES=2 DEFS += -DHID_INPUT_REPORT_BYTES=2
@@ -56,24 +55,36 @@ DEFS += -DHID_INT_IN_EP_SIZE=64
DEFS += -DHID_INT_OUT_EP_SIZE=64 DEFS += -DHID_INT_OUT_EP_SIZE=64
DEFS += -DHID_OUTPUT_REPORT_BYTES=2 DEFS += -DHID_OUTPUT_REPORT_BYTES=2
DEFS += -DHID_RPT01_SIZE=29 DEFS += -DHID_RPT01_SIZE=29
DEFS += -DHZ=1000
DEFS += -DKERNEL DEFS += -DKERNEL
DEFS += -DLED_KERNEL_PIN=5 DEFS += -DLED_KERNEL_PIN=5
DEFS += -DLED_KERNEL_PORT=TRISE DEFS += -DLED_KERNEL_PORT=TRISE
DEFS += -DNBUF=8
DEFS += -DNMOUNT=3
DEFS += -DNPROC=25
DEFS += -DOC_ENABLED=YES DEFS += -DOC_ENABLED=YES
DEFS += -DPARTITION="sramc0:sa@2048,fs@6140"
DEFS += -DPIC32MX7 DEFS += -DPIC32MX7
DEFS += -DSD0_CS_PIN=9 DEFS += -DSD0_CS_PIN=9
DEFS += -DSD0_CS_PORT=TRISG DEFS += -DSD0_CS_PORT=TRISG
DEFS += -DSD0_MHZ=20
DEFS += -DSD0_PORT=2 DEFS += -DSD0_PORT=2
DEFS += -DUARTUSB_ENABLED=YES DEFS += -DSPI_ENABLED=YES
DEFS += -DSRAMC0_ENABLED=YES
DEFS += -DSRAMC_ENABLED=YES
DEFS += -DUART1_BAUD=115200
DEFS += -DUART1_ENABLED=YES
DEFS += -DUART2_BAUD=115200
DEFS += -DUART2_ENABLED=YES
DEFS += -DUCB_METER DEFS += -DUCB_METER
DEFS += -DUSB_EP0_BUFF_SIZE=8 DEFS += -DUSB_EP0_BUFF_SIZE=8
DEFS += -DUSB_MAX_EP_NUMBER=3 DEFS += -DUSB_MAX_EP_NUMBER=1
DEFS += -DUSB_NUM_STRING_DESCRIPTORS=3 DEFS += -DUSB_NUM_STRING_DESCRIPTORS=3
LDSCRIPT = ../../../tools/configsys/../../sys/pic32/cfg/bootloader.ld LDSCRIPT = ../../../tools/configsys/../../sys/pic32/cfg/bootloader.ld
CONFIG = FUBARINO CONFIG = FUBARINO-UART2CONS-UART1-SRAMC
CONFIGPATH = ../../../tools/configsys CONFIGPATH = ../../../tools/configsys
include ../../../tools/configsys/../../sys/pic32/kernel-post.mk include ../../../tools/configsys/../../sys/pic32/kernel-post.mk

2
sys/pic32/gcc-config.mk Executable file → Normal file
View File

@@ -1,7 +1,7 @@
# chipKIT PIC32 compiler from UECIDE # chipKIT PIC32 compiler from UECIDE
ifdef UECIDE ifdef UECIDE
ifndef GCCPREFIX ifndef GCCPREFIX
GCCPREFIX = ${HOME}/.uecide/compilers/pic32-tools/bin/pic32- GCCPREFIX = ${UECIDE}/compilers/pic32-tools/bin/pic32-
LDFLAGS = -Wl,--oformat=elf32-tradlittlemips LDFLAGS = -Wl,--oformat=elf32-tradlittlemips
endif endif
endif endif

0
sys/pic32/kernel-post.mk Executable file → Normal file
View File

View File

@@ -3,6 +3,7 @@
* *
* This version is for 8MB RAMDISK v.1.1 and compatible * This version is for 8MB RAMDISK v.1.1 and compatible
* Pito 7.4.2014 - PIC32MX PMP bus version * Pito 7.4.2014 - PIC32MX PMP bus version
* Pito 28.4.2014 - Mod for 2 Units
* Under by retrobsd.org used Licence * Under by retrobsd.org used Licence
* No warranties of any kind * No warranties of any kind
* *
@@ -29,23 +30,29 @@
int sw_dkn = -1; /* Statistics slot number */ int sw_dkn = -1; /* Statistics slot number */
// Ramdisk v.1.1. wiring // 8MB Ramdisk v.1.1. wiring
// PMP RAMDISK // PMP RAMDISK
// =================== // ===================
// PMD<D0-D7> D0-D7 // PMD<D0-D7> D0-D7
// PMRD /RD // PMRD /RD
// PMWR /WR // PMWR /WR
// PMA<0> /DATA // PMA<0> /DATA
// PMA<1> 0-Unit0
// PMA<10> 0-Unit1
//#define NDATA (1<<0)
//#define UNIT0 (1<<1)
//#define UNIT1 (1<<10)
// RD and WR pulses duration settings // RD and WR pulses duration settings
// Minimal recommended settings, increase them when unstable // Minimal recommended settings, increase them when unstable
// No warranties of any kind // No warranties of any kind
// for 120MHz clock, 70ns PSRAM, Ramdisk v.1.1. // for 120MHz clock, 70ns PSRAM, 8MB Ramdisk v.1.1.
#define ADR_PULSE 1 #define ADR_PULSE 1
#define WR_PULSE 5 #define WR_PULSE 5
#define RD_PULSE 11 #define RD_PULSE 11
// for 80MHz clock, 70ns PSRAM, Ramdisk v.1.1. // for 80MHz clock, 70ns PSRAM, 8MB Ramdisk v.1.1.
//#define ADR_PULSE 1 //#define ADR_PULSE 1
//#define WR_PULSE 3 //#define WR_PULSE 3
//#define RD_PULSE 8 //#define RD_PULSE 8
@@ -61,35 +68,31 @@ int sw_dkn = -1; /* Statistics slot number */
//#define RD_PULSE 4 //#define RD_PULSE 4
typedef union { typedef union {
unsigned value; unsigned int value;
struct { struct {
unsigned nib1: 4; // lowest nibble unsigned nib1: 4; // lowest nibble
unsigned nib2: 4; unsigned nib2: 4;
unsigned nib3: 4; unsigned nib3: 4;
unsigned nib4: 4; unsigned nib4: 4;
unsigned nib5: 4; unsigned nib5: 4;
unsigned nib6: 4; unsigned nib6: 4;
unsigned nib7: 4; unsigned nib7: 4;
unsigned nib8: 4; // highest nibble unsigned nib8: 4; // highest nibble
}; };
} nybbles ; } nybbles;
/* /*
* Load the 24 bit address to Ramdisk. * Load the 24 bit address to Ramdisk.
* *
*/ */
inline static void inline static void dev_load_address (unsigned int addr)
dev_load_address (addr)
unsigned addr;
{ {
nybbles temp; nybbles temp;
temp.value = addr; temp.value = addr;
while(PMMODE & 0x8000); // Poll - if busy, wait while(PMMODE & 0x8000); // Poll - if busy, wait
PMADDR = 1; // set ADR mode (1) to write the Address
PMMODE = 0b10<<8 | (ADR_PULSE<<2); // full ADR speed PMMODE = 0b10<<8 | (ADR_PULSE<<2); // full ADR speed
PMDIN = temp.nib6; /* write 4 bits */ PMDIN = temp.nib6; /* write 4 bits */
@@ -108,7 +111,6 @@ dev_load_address (addr)
while(PMMODE & 0x8000); // Poll - if busy, wait while(PMMODE & 0x8000); // Poll - if busy, wait
PMDIN = temp.nib1; /* write 4 bits */ PMDIN = temp.nib1; /* write 4 bits */
} }
/* /*
@@ -117,64 +119,82 @@ dev_load_address (addr)
*/ */
int sramc_size ( int unit ) int sramc_size ( int unit )
{ {
return 8192; // 4096 for 4MB ramdisk int srsize;
switch (unit) {
case 0: srsize = 8192; break;
case 1: srsize = 8192; break;
}
return srsize;
} }
/* /*
* Read a block of data. * Read a block of data.
*/ */
inline int sramc_read (int unit, unsigned int blockno, char *data, unsigned int nbytes) inline int sramc_read (int unit, unsigned int blockno, register char *data, register unsigned int nbytes)
{ {
int i;
//DEBUG9("sramc%d: read block %u, length %u bytes, addr %p\n", //printf("sramc%d: rd blockno %u, nbytes %u, addr %p\n", unit, blockno, nbytes, data);
// major(dev), blockno, nbytes, data);
dev_load_address (blockno * DEV_BSIZE);
/* Read data. */
while(PMMODE & 0x8000); // Poll - if busy, wait while(PMMODE & 0x8000); // Poll - if busy, wait
PMADDR = 0; // set DATA mode (0) switch (unit) {
// set Unit address and ADDRESS mode (1)
case 0: PMADDR = 0b10000000001; break;
case 1: PMADDR = 0b00000000011; break;
}
dev_load_address (blockno * DEV_BSIZE);
while(PMMODE & 0x8000); // Poll - if busy, wait
PMMODE = 0b10<<8 | (RD_PULSE<<2); // read slowly PMMODE = 0b10<<8 | (RD_PULSE<<2); // read slowly
PMADDR = PMADDR & 0b10000000010; // set DATA mode
PMDIN; // Read the PMDIN to clear previous data and latch new data PMDIN; // Read the PMDIN to clear previous data and latch new data
for (i=0; i<nbytes; i++) { while (nbytes--) {
while(PMMODE & 0x8000); // Poll - if busy, wait before reading while(PMMODE & 0x8000); // Poll - if busy, wait before reading
*data++ = PMDIN; /* read a byte of data */ *data++ = PMDIN; /* read a byte of data */
} }
while(PMMODE & 0x8000); // Poll - if busy, wait
PMADDR = 0b10000000011; // deselect
return 1; return 1;
} }
/* /*
* Write a block of data. * Write a block of data.
*/ */
inline int sramc_write (int unit, unsigned int blockno, char *data, unsigned int nbytes) inline int sramc_write (int unit, unsigned int blockno, register char *data, register unsigned int nbytes)
{ {
unsigned i;
//DEBUG9("sramc%d: write block %u, length %u bytes, addr %p\n", //printf("sramc%d: wr blockno %u, nbytes %u , addr %p\n", unit, blockno, nbytes, data);
// major(dev), blockno, nbytes, data);
while(PMMODE & 0x8000); // Poll - if busy, wait
switch (unit) {
// set Unit address and ADDRESS mode (1)
case 0: PMADDR = 0b10000000001; break;
case 1: PMADDR = 0b00000000011; break;
}
dev_load_address (blockno * DEV_BSIZE); dev_load_address (blockno * DEV_BSIZE);
/* Write data. */
while (PMMODE & 0x8000); // Poll - if busy, wait while (PMMODE & 0x8000); // Poll - if busy, wait
PMADDR = 0; // set DATA mode (0)
PMMODE = 0b10<<8 | (WR_PULSE<<2); // faster with write PMMODE = 0b10<<8 | (WR_PULSE<<2); // faster with write
for (i=0; i<nbytes; i++) { PMADDR = PMADDR & 0b10000000010; // set DATA mode
while(PMMODE & 0x8000); // Poll - if busy, wait
PMDIN = (*data++); /* write a byte of data */
}
while(nbytes--) {
while(PMMODE & 0x8000); // Poll - if busy, wait
PMDIN = (*data++); /* write a byte of data*/
}
while(PMMODE & 0x8000); // Poll - if busy, wait
PMADDR = 0b10000000011; // deselect
return 1; return 1;
} }
@@ -184,6 +204,8 @@ inline int sramc_write (int unit, unsigned int blockno, char *data, unsigned int
*/ */
void sramc_init (int unit) void sramc_init (int unit)
{ {
// printf("ramdisk%d: init\n",unit);
struct buf *bp; struct buf *bp;
// Initialize PMP hardware // Initialize PMP hardware
@@ -196,31 +218,50 @@ void sramc_init (int unit)
// MODE WAITB WAITM WAITE // MODE WAITB WAITM WAITE
PMMODE = 0b10<<8 | 0 | (14<<2) | 0 ; // Mode2 Master 8bit PMMODE = 0b10<<8 | 0 | (14<<2) | 0 ; // Mode2 Master 8bit
PMAEN = 1; // PMA<0>, use A0 only PMAEN = 0b10000000011; // PMA<>, use A10,A1,A0
PMADDR = 0; // start with DATA mode PMADDR = 0b10000000010; // start with DATA mode
PMCONSET = 1<<15; // PMP enabled PMCONSET = 1<<15; // PMP enabled
asm volatile ("nop"); asm volatile ("nop");
// make a couple of dummy reads - it refreshes the cpld internals a little bit :) // make a couple of dummy reads - it refreshes the cpld internals a little bit :)
while(PMMODE & 0x8000); // Poll - if busy, wait before reading switch (unit) {
PMDIN; /* read a byte of data */
while(PMMODE & 0x8000); // Poll - if busy, wait before reading
PMDIN; /* read a byte of data */
PMADDR = 1; // go with with ADDRESS mode now case 0: PMADDR = 0b10000000000; // start with DATA mode
while(PMMODE & 0x8000); // Poll - if busy, wait before reading
PMDIN; /* read a byte of data */
while(PMMODE & 0x8000); // Poll - if busy, wait before reading
PMDIN; /* read a byte of data */
bp = prepartition_device("sramc0");
DEBUG3("sramc%d: init done\n",unit); if(bp) {
bp = prepartition_device("sramc0");
if(bp)
{
sramc_write(0, 0, bp->b_addr, 512); sramc_write(0, 0, bp->b_addr, 512);
brelse(bp); brelse(bp);
} }
// printf("sramc%d: init done\n",unit);
break;
return;
case 1: PMADDR = 0b00000000010; // start with DATA mode
while(PMMODE & 0x8000); // Poll - if busy, wait before reading
PMDIN; /* read a byte of data */
while(PMMODE & 0x8000); // Poll - if busy, wait before reading
PMDIN; /* read a byte of data */
bp = prepartition_device("sramc1");
if(bp) {
sramc_write(1, 0, bp->b_addr, 512);
brelse(bp);
}
// printf("sramc%d: init done\n",unit);
break;
}
while(PMMODE & 0x8000); // Poll - if busy, wait
PMADDR = 0b10000000011; // go with with ADDRESS mode
} }
/* /*
@@ -228,6 +269,6 @@ void sramc_init (int unit)
*/ */
int sramc_open (int unit) int sramc_open (int unit)
{ {
DEBUG3("sramc%d: open\n",unit); // printf("sramc%d: open done\n",unit);
return 0; return 0;
} }

View File

@@ -44,12 +44,16 @@ int spi_open(unsigned int bus, unsigned int *tris, unsigned int pin)
case 2: case 2:
spi_devices[dno].bus = (struct spireg *)&SPI2CON; spi_devices[dno].bus = (struct spireg *)&SPI2CON;
break; break;
#ifdef SPI3CON
case 3: case 3:
spi_devices[dno].bus = (struct spireg *)&SPI3CON; spi_devices[dno].bus = (struct spireg *)&SPI3CON;
break; break;
#endif
#ifdef SPI4CON
case 4: case 4:
spi_devices[dno].bus = (struct spireg *)&SPI4CON; spi_devices[dno].bus = (struct spireg *)&SPI4CON;
break; break;
#endif
default: default:
return -1; return -1;
} }
@@ -624,11 +628,14 @@ char *spi_name(int dno)
if(spi_devices[dno].bus == (struct spireg *)&SPI2CON) if(spi_devices[dno].bus == (struct spireg *)&SPI2CON)
return "SPI2"; return "SPI2";
#ifdef SPI3CON
if(spi_devices[dno].bus == (struct spireg *)&SPI3CON) if(spi_devices[dno].bus == (struct spireg *)&SPI3CON)
return "SPI3"; return "SPI3";
#endif
#ifdef SPI4CON
if(spi_devices[dno].bus == (struct spireg *)&SPI4CON) if(spi_devices[dno].bus == (struct spireg *)&SPI4CON)
return "SPI4"; return "SPI4";
#endif
return "SPI?"; return "SPI?";
} }

11
target.mk Executable file → Normal file
View File

@@ -1,12 +1,15 @@
MACHINE = mips MACHINE = mips
DESTDIR ?= $(TOPSRC) DESTDIR ?= $(TOPSRC)
RELEASE = 0.0
BUILD = $(shell git rev-list HEAD --count)
VERSION = $(RELEASE)-$(BUILD)
# chipKIT PIC32 compiler from UECIDE # chipKIT PIC32 compiler from UECIDE
ifdef UECIDE ifdef UECIDE
ifndef GCCPREFIX ifndef GCCPREFIX
GCCPREFIX = ${HOME}/.uecide/compilers/pic32-tools/bin/pic32- GCCPREFIX = ${UECIDE}/compilers/pic32-tools/bin/pic32-
LDFLAGS = -Wl,--oformat=elf32-tradlittlemips LDFLAGS = -Wl,--oformat=elf32-tradlittlemips
INCLUDES = -I${HOME}/.uecide/compilers/pic32-tools/lib/gcc/pic32mx/4.5.1/include INCLUDES = -I${UECIDE}/compilers/pic32-tools/lib/gcc/pic32mx/4.5.1/include
endif endif
endif endif
@@ -34,8 +37,8 @@ ifndef GCCPREFIX
INCLUDES = INCLUDES =
endif endif
CC = $(GCCPREFIX)gcc -mips32r2 -EL -msoft-float -fno-short-double -nostdinc -I$(TOPSRC)/include $(INCLUDES) CC = $(GCCPREFIX)gcc -mips32r2 -EL -msoft-float -nostdinc -fshort-double -I$(TOPSRC)/include $(INCLUDES)
CXX = $(GCCPREFIX)g++ -mips32r2 -EL -msoft-float -fno-short-double -nostdinc -I$(TOPSRC)/include $(INCLUDES) CXX = $(GCCPREFIX)g++ -mips32r2 -EL -msoft-float -nostdinc -fshort-double -I$(TOPSRC)/include $(INCLUDES)
LD = $(GCCPREFIX)ld LD = $(GCCPREFIX)ld
AR = $(GCCPREFIX)ar AR = $(GCCPREFIX)ar
RANLIB = $(GCCPREFIX)ranlib RANLIB = $(GCCPREFIX)ranlib

View File

@@ -160,11 +160,19 @@ bool config::load(const char *filename)
pos = temp.find("="); pos = temp.find("=");
if(pos>0) if(pos>0)
{ {
stringstream data;
string l,r; string l,r;
l = temp.substr(0,pos); l = temp.substr(0,pos);
uc(l); uc(l);
r = temp.substr(pos+1,temp.size()); r = temp.substr(pos+1,temp.size());
this->instances["GLOBAL"].settings[l] = r; data << r;
while (in >> temp) {
if (temp[0] == '#') {
break;
}
data << " " << temp;
}
this->instances["GLOBAL"].settings[l] = data.str();
this->instances["GLOBAL"].device="GLOBAL"; this->instances["GLOBAL"].device="GLOBAL";
this->instances["GLOBAL"].unit=0; this->instances["GLOBAL"].unit=0;
} }