Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Copy some software code from the original Milkymist SoC.
Libbase should keep its RAM usage to a minimum as it is meant to be executed before the SDRAM is up and running. (Having lots of code is OK though as we XIP from the flash)
- Loading branch information
Sebastien Bourdeauducq
committed
Feb 3, 2012
1 parent
b5cb108
commit 1a4a6eb
Showing
44 changed files
with
5,360 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Mico32 toolchain | ||
# | ||
CROSS_COMPILER=lm32-rtems4.11- | ||
|
||
CC_normal := $(CROSS_COMPILER)gcc | ||
AR_normal := $(CROSS_COMPILER)ar | ||
AS_normal := $(CROSS_COMPILER)as | ||
LD_normal := $(CROSS_COMPILER)ld | ||
OBJCOPY_normal := $(CROSS_COMPILER)objcopy | ||
RANLIB_normal := $(CROSS_COMPILER)ranlib | ||
|
||
CC_quiet = @echo " CC " $@ && $(CROSS_COMPILER)gcc | ||
AR_quiet = @echo " AR " $@ && $(CROSS_COMPILER)ar | ||
AS_quiet = @echo " AS " $@ && $(CROSS_COMPILER)as | ||
LD_quiet = @echo " LD " $@ && $(CROSS_COMPILER)ld | ||
OBJCOPY_quiet = @echo " OBJCOPY " $@ && $(CROSS_COMPILER)objcopy | ||
RANLIB_quiet = @echo " RANLIB " $@ && $(CROSS_COMPILER)ranlib | ||
|
||
ifeq ($(V),1) | ||
CC = $(CC_normal) | ||
AR = $(AR_normal) | ||
AS = $(AS_normal) | ||
LD = $(LD_normal) | ||
OBJCOPY = $(OBJCOPY_normal) | ||
RANLIB = $(RANLIB_normal) | ||
else | ||
CC = $(CC_quiet) | ||
AR = $(AR_quiet) | ||
AS = $(AS_quiet) | ||
LD = $(LD_quiet) | ||
OBJCOPY = $(OBJCOPY_quiet) | ||
RANLIB = $(RANLIB_quiet) | ||
endif | ||
|
||
# Toolchain options | ||
# | ||
INCLUDES_NOLIBC ?= -nostdinc -I$(MMDIR)/software/include/base | ||
INCLUDES = $(INCLUDES_NOLIBC) -I$(MMDIR)/software/include -I$(MMDIR)/tools | ||
ASFLAGS = $(INCLUDES) -nostdinc | ||
# later: -Wmissing-prototypes | ||
CFLAGS = -O9 -Wall -Wstrict-prototypes -Wold-style-definition -Wshadow \ | ||
-mbarrel-shift-enabled -mmultiply-enabled -mdivide-enabled \ | ||
-msign-extend-enabled -fno-builtin -fsigned-char \ | ||
-fsingle-precision-constant $(INCLUDES) | ||
LDFLAGS = -nostdlib -nodefaultlibs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Milkymist SoC (Software) | ||
* Copyright (C) 2007, 2008, 2009 Sebastien Bourdeauducq | ||
* Copyright (C) Linux kernel developers | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, version 3 of the License. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY 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. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef __ASSERT_H | ||
#define __ASSERT_H | ||
|
||
#define assert(x) | ||
|
||
#endif /* __ASSERT_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Milkymist SoC (Software) | ||
* Copyright (C) 2007, 2008, 2009, 2010, 2011 Sebastien Bourdeauducq | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, version 3 of the License. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY 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. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef __BOARD_H | ||
#define __BOARD_H | ||
|
||
#define BOARD_NAME_LEN 32 | ||
|
||
struct board_desc { | ||
unsigned short int id; | ||
char name[BOARD_NAME_LEN]; | ||
unsigned int ethernet_phyadr; | ||
}; | ||
|
||
const struct board_desc *get_board_desc_id(unsigned short int id); | ||
const struct board_desc *get_board_desc(void); | ||
int get_pcb_revision(void); | ||
void get_soc_version(unsigned int *major, unsigned int *minor, unsigned int *subminor, unsigned int *rc); | ||
void get_soc_version_formatted(char *version); | ||
|
||
#endif /* __BOARD_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Milkymist SoC (Software) | ||
* Copyright (C) 2007, 2008, 2009, 2010 Sebastien Bourdeauducq | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, version 3 of the License. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY 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. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef __CONSOLE_H | ||
#define __CONSOLE_H | ||
|
||
typedef void (*console_write_hook)(char); | ||
typedef char (*console_read_hook)(void); | ||
typedef int (*console_read_nonblock_hook)(void); | ||
|
||
void console_set_write_hook(console_write_hook h); | ||
void console_set_read_hook(console_read_hook r, console_read_nonblock_hook rn); | ||
|
||
char readchar(void); | ||
int readchar_nonblock(void); | ||
|
||
int puts(const char *s); | ||
void putsnonl(const char *s); | ||
|
||
#endif /* __CONSOLE_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* Milkymist SoC (Software) | ||
* Copyright (C) 2007, 2008, 2009 Sebastien Bourdeauducq | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, version 3 of the License. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY 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. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef __CTYPE_H | ||
#define __CTYPE_H | ||
|
||
static inline int isdigit(char c) | ||
{ | ||
return (c >= '0') && (c <= '9'); | ||
} | ||
|
||
static inline int isxdigit(char c) | ||
{ | ||
return isdigit(c) || ((c >= 'a') && (c <= 'f')) || ((c >= 'A') && (c <= 'F')); | ||
} | ||
|
||
static inline int isupper(char c) | ||
{ | ||
return (c >= 'A') && (c <= 'Z'); | ||
} | ||
|
||
static inline int islower(char c) | ||
{ | ||
return (c >= 'a') && (c <= 'z'); | ||
} | ||
|
||
static inline unsigned char tolower(unsigned char c) | ||
{ | ||
if (isupper(c)) | ||
c -= 'A'-'a'; | ||
return c; | ||
} | ||
|
||
static inline unsigned char toupper(unsigned char c) | ||
{ | ||
if (islower(c)) | ||
c -= 'a'-'A'; | ||
return c; | ||
} | ||
|
||
static inline char isspace(unsigned char c) | ||
{ | ||
if(c == ' ' | ||
|| c == '\f' | ||
|| c == '\n' | ||
|| c == '\r' | ||
|| c == '\t' | ||
|| c == '\v') | ||
return 1; | ||
|
||
return 0; | ||
} | ||
|
||
#endif /* __CTYPE_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Milkymist SoC (Software) | ||
* Copyright (C) 2007, 2008, 2009 Sebastien Bourdeauducq | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, version 3 of the License. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY 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. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef __ENDIAN_H | ||
#define __ENDIAN_H | ||
|
||
#define __LITTLE_ENDIAN 0 | ||
#define __BIG_ENDIAN 1 | ||
#define __BYTE_ORDER __BIG_ENDIAN | ||
|
||
static inline unsigned int le32toh(unsigned int val) | ||
{ | ||
return (val & 0xff) << 24 | | ||
(val & 0xff00) << 8 | | ||
(val & 0xff0000) >> 8 | | ||
(val & 0xff000000) >> 24; | ||
} | ||
|
||
static inline unsigned short le16toh(unsigned short val) | ||
{ | ||
return (val & 0xff) << 8 | | ||
(val & 0xff00) >> 8; | ||
} | ||
|
||
#endif /* __ENDIAN_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Milkymist SoC (Software) | ||
* Copyright (C) 2007, 2008, 2009 Sebastien Bourdeauducq | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, version 3 of the License. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY 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. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef __IRQ_H | ||
#define __IRQ_H | ||
|
||
static inline void irq_enable(unsigned int en) | ||
{ | ||
__asm__ __volatile__("wcsr IE, %0" : : "r" (en)); | ||
} | ||
|
||
static inline unsigned int irq_getmask(void) | ||
{ | ||
unsigned int mask; | ||
__asm__ __volatile__("rcsr %0, IM" : "=r" (mask)); | ||
return mask; | ||
} | ||
|
||
static inline void irq_setmask(unsigned int mask) | ||
{ | ||
__asm__ __volatile__("wcsr IM, %0" : : "r" (mask)); | ||
} | ||
|
||
static inline unsigned int irq_pending(void) | ||
{ | ||
unsigned int pending; | ||
__asm__ __volatile__("rcsr %0, IP" : "=r" (pending)); | ||
return pending; | ||
} | ||
|
||
static inline void irq_ack(unsigned int mask) | ||
{ | ||
__asm__ __volatile__("wcsr IP, %0" : : "r" (mask)); | ||
} | ||
|
||
static inline unsigned int irq_getie(void) | ||
{ | ||
unsigned int ie; | ||
__asm__ __volatile__("rcsr %0, IE" : "=r" (ie)); | ||
return ie; | ||
} | ||
|
||
static inline void irq_setie(unsigned int ie) | ||
{ | ||
__asm__ __volatile__("wcsr IE, %0" : : "r" (ie)); | ||
} | ||
|
||
#endif /* __IRQ_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Milkymist SoC (Software) | ||
* Copyright (C) 2007, 2008, 2009 Sebastien Bourdeauducq | ||
* Copyright (C) Linux kernel developers | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, version 3 of the License. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY 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. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef __LIMITS_H | ||
#define __LIMITS_H | ||
|
||
#define INT_MIN ((((unsigned long)-1) >> 1) + 1) | ||
#define INT_MAX (((unsigned long)-1) >> 1) | ||
|
||
#endif /* __LIMITS_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Milkymist SoC (Software) | ||
* Copyright (C) 2007, 2008, 2009 Sebastien Bourdeauducq | ||
* Copyright (C) Linux kernel developers | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, version 3 of the License. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY 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. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef __STDARG_H | ||
#define __STDARG_H | ||
|
||
#include <stdlib.h> | ||
|
||
#if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) | ||
#define va_start(v,l) __builtin_va_start((v),l) | ||
#else | ||
#define va_start(v,l) __builtin_stdarg_start((v),l) | ||
#endif | ||
|
||
#define va_arg(ap, type) \ | ||
__builtin_va_arg((ap), type) | ||
|
||
#define va_end(ap) \ | ||
__builtin_va_end(ap) | ||
|
||
#define va_list \ | ||
__builtin_va_list | ||
|
||
int vsnprintf(char *buf, size_t size, const char *fmt, va_list args); | ||
int vscnprintf(char *buf, size_t size, const char *fmt, va_list args); | ||
int vsprintf(char *buf, const char *fmt, va_list args); | ||
|
||
#endif /* __STDARG_H */ |
Oops, something went wrong.