Common include files
authorSebastien Bourdeauducq <sebastien@milkymist.org>
Wed, 16 May 2012 08:20:04 +0000 (10:20 +0200)
committerSebastien Bourdeauducq <sebastien@milkymist.org>
Wed, 16 May 2012 08:20:04 +0000 (10:20 +0200)
common/csrbase.h [new file with mode: 0644]
common/sfl.h [new file with mode: 0644]
common/version.h [new file with mode: 0644]
software/bios/ddrinit.c
software/include.mak
software/include/base/version.h [deleted file]
software/include/hw/dfii.h
software/include/hw/uart.h
tools/Makefile
tools/sfl.h [deleted file]

diff --git a/common/csrbase.h b/common/csrbase.h
new file mode 100644 (file)
index 0000000..76d6a56
--- /dev/null
@@ -0,0 +1,8 @@
+#ifndef __CSRBASE_H
+#define __CSRBASE_H
+
+#define UART_BASE      0xe0000000
+#define DFII_BASE      0xe0000800
+#define ID_BASE                0xe0001000
+
+#endif /* __CSRBASE_H */
diff --git a/common/sfl.h b/common/sfl.h
new file mode 100644 (file)
index 0000000..90a205f
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Milkymist SoC
+ * 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 __SFL_H
+#define __SFL_H
+
+#define SFL_MAGIC_LEN 14
+#define SFL_MAGIC_REQ "sL5DdSMmkekro\n"
+#define SFL_MAGIC_ACK "z6IHG7cYDID6o\n"
+
+struct sfl_frame {
+       unsigned char length;
+       unsigned char crc[2];
+       unsigned char cmd;
+       unsigned char payload[255];
+} __attribute__((packed));
+
+/* General commands */
+#define SFL_CMD_ABORT          0x00
+#define SFL_CMD_LOAD           0x01
+#define SFL_CMD_JUMP           0x02
+
+/* Linux-specific commands */
+#define SFL_CMD_CMDLINE                0x03
+#define SFL_CMD_INITRDSTART    0x04
+#define SFL_CMD_INITRDEND      0x05
+
+/* Replies */
+#define SFL_ACK_SUCCESS                'K'
+#define SFL_ACK_CRCERROR       'C'
+#define SFL_ACK_UNKNOWN                'U'
+#define SFL_ACK_ERROR          'E'
+
+#endif /* __SFL_H */
diff --git a/common/version.h b/common/version.h
new file mode 100644 (file)
index 0000000..68bd4c9
--- /dev/null
@@ -0,0 +1,6 @@
+#ifndef __VERSION_H
+#define __VERSION_H
+
+#define VERSION "2.0"
+
+#endif /* __VERSION_H */
index 84990ac14144d4b7e5d28200ea849d4e3d6a810e..010efb74595f44e983caeeebdb507e2b5dbcd326 100644 (file)
@@ -204,7 +204,7 @@ void memtest(void)
 
 int ddrinit(void)
 {
-       printf("Initializing DDRAM...\n");
+       printf("Initializing DDR SDRAM...\n");
        
        init_sequence();
        CSR_DFII_CONTROL = DFII_CONTROL_SEL|DFII_CONTROL_CKE;
index 227ba3afd1c6d246d92693a4b20d5b364151eb18..0f904505f077c0ebedb9b4c23be79b278e2b5a37 100644 (file)
@@ -36,7 +36,7 @@ endif
 # Toolchain options
 #
 INCLUDES_NOLIBC ?= -nostdinc -I$(M2DIR)/software/include/base
-INCLUDES = $(INCLUDES_NOLIBC) -I$(M2DIR)/software/include -I$(M2DIR)/tools
+INCLUDES = $(INCLUDES_NOLIBC) -I$(M2DIR)/software/include -I$(M2DIR)/common
 ASFLAGS = $(INCLUDES) -nostdinc
 CFLAGS = -O9 -Wall -Wstrict-prototypes -Wold-style-definition -Wshadow \
         -Wmissing-prototypes -fsigned-char $(INCLUDES)
diff --git a/software/include/base/version.h b/software/include/base/version.h
deleted file mode 100644 (file)
index 3f70d0e..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef __VERSION_H
-#define __VERSION_H
-
-#define VERSION "2.0-X"
-
-#endif /* __VERSION_H */
index fc13090cf2e7f9fec429ad80b6b2d02b5e3cbad6..4cf07f3cd81888a049d3f7cfa1c427872814bc70 100644 (file)
 #define __HW_DFII_H
 
 #include <hw/common.h>
+#include <csrbase.h>
 
-#define CSR_DFII_CONTROL               MMPTR(0xe0000800)
+#define DFII_CSR(x)                    MMPTR(DFII_BASE+(x))
 
-#define DFII_CONTROL_SEL               (0x01)
-#define DFII_CONTROL_CKE               (0x02)
+#define CSR_DFII_CONTROL               DFII_CSR(0x00)
 
-#define CSR_DFII_COMMAND_P0            MMPTR(0xe0000804)
-#define CSR_DFII_AH_P0                 MMPTR(0xe0000808)
-#define CSR_DFII_AL_P0                 MMPTR(0xe000080C)
-#define CSR_DFII_BA_P0                 MMPTR(0xe0000810)
-#define CSR_DFII_WD0_P0                        MMPTR(0xe0000814)
-#define CSR_DFII_WD1_P0                        MMPTR(0xe0000818)
-#define CSR_DFII_WD2_P0                        MMPTR(0xe000081C)
-#define CSR_DFII_WD3_P0                        MMPTR(0xe0000820)
-#define CSR_DFII_WD4_P0                        MMPTR(0xe0000824)
-#define CSR_DFII_WD5_P0                        MMPTR(0xe0000828)
-#define CSR_DFII_WD6_P0                        MMPTR(0xe000082C)
-#define CSR_DFII_WD7_P0                        MMPTR(0xe0000830)
-#define CSR_DFII_RD0_P0                        MMPTR(0xe0000834)
-#define CSR_DFII_RD1_P0                        MMPTR(0xe0000838)
-#define CSR_DFII_RD2_P0                        MMPTR(0xe000083C)
-#define CSR_DFII_RD3_P0                        MMPTR(0xe0000840)
-#define CSR_DFII_RD4_P0                        MMPTR(0xe0000844)
-#define CSR_DFII_RD5_P0                        MMPTR(0xe0000848)
-#define CSR_DFII_RD6_P0                        MMPTR(0xe000084C)
-#define CSR_DFII_RD7_P0                        MMPTR(0xe0000850)
+#define DFII_CONTROL_SEL               0x01
+#define DFII_CONTROL_CKE               0x02
 
-#define CSR_DFII_COMMAND_P1            MMPTR(0xe0000854)
-#define CSR_DFII_AH_P1                 MMPTR(0xe0000858)
-#define CSR_DFII_AL_P1                 MMPTR(0xe000085C)
-#define CSR_DFII_BA_P1                 MMPTR(0xe0000860)
-#define CSR_DFII_WD0_P1                        MMPTR(0xe0000864)
-#define CSR_DFII_WD1_P1                        MMPTR(0xe0000868)
-#define CSR_DFII_WD2_P1                        MMPTR(0xe000086C)
-#define CSR_DFII_WD3_P1                        MMPTR(0xe0000870)
-#define CSR_DFII_WD4_P1                        MMPTR(0xe0000874)
-#define CSR_DFII_WD5_P1                        MMPTR(0xe0000878)
-#define CSR_DFII_WD6_P1                        MMPTR(0xe000087C)
-#define CSR_DFII_WD7_P1                        MMPTR(0xe0000880)
-#define CSR_DFII_RD0_P1                        MMPTR(0xe0000884)
-#define CSR_DFII_RD1_P1                        MMPTR(0xe0000888)
-#define CSR_DFII_RD2_P1                        MMPTR(0xe000088C)
-#define CSR_DFII_RD3_P1                        MMPTR(0xe0000890)
-#define CSR_DFII_RD4_P1                        MMPTR(0xe0000894)
-#define CSR_DFII_RD5_P1                        MMPTR(0xe0000898)
-#define CSR_DFII_RD6_P1                        MMPTR(0xe000089C)
-#define CSR_DFII_RD7_P1                        MMPTR(0xe00008a0)
+#define CSR_DFII_COMMAND_P0            DFII_CSR(0x04)
+#define CSR_DFII_AH_P0                 DFII_CSR(0x08)
+#define CSR_DFII_AL_P0                 DFII_CSR(0x0C)
+#define CSR_DFII_BA_P0                 DFII_CSR(0x10)
+#define CSR_DFII_WD0_P0                        DFII_CSR(0x14)
+#define CSR_DFII_WD1_P0                        DFII_CSR(0x18)
+#define CSR_DFII_WD2_P0                        DFII_CSR(0x1C)
+#define CSR_DFII_WD3_P0                        DFII_CSR(0x20)
+#define CSR_DFII_WD4_P0                        DFII_CSR(0x24)
+#define CSR_DFII_WD5_P0                        DFII_CSR(0x28)
+#define CSR_DFII_WD6_P0                        DFII_CSR(0x2C)
+#define CSR_DFII_WD7_P0                        DFII_CSR(0x30)
+#define CSR_DFII_RD0_P0                        DFII_CSR(0x34)
+#define CSR_DFII_RD1_P0                        DFII_CSR(0x38)
+#define CSR_DFII_RD2_P0                        DFII_CSR(0x3C)
+#define CSR_DFII_RD3_P0                        DFII_CSR(0x40)
+#define CSR_DFII_RD4_P0                        DFII_CSR(0x44)
+#define CSR_DFII_RD5_P0                        DFII_CSR(0x48)
+#define CSR_DFII_RD6_P0                        DFII_CSR(0x4C)
+#define CSR_DFII_RD7_P0                        DFII_CSR(0x50)
 
-#define DFII_COMMAND_CS                        (0x01)
-#define DFII_COMMAND_WE                        (0x02)
-#define DFII_COMMAND_CAS               (0x04)
-#define DFII_COMMAND_RAS               (0x08)
-#define DFII_COMMAND_WRDATA            (0x10)
-#define DFII_COMMAND_RDDATA            (0x20)
+#define CSR_DFII_COMMAND_P1            DFII_CSR(0x54)
+#define CSR_DFII_AH_P1                 DFII_CSR(0x58)
+#define CSR_DFII_AL_P1                 DFII_CSR(0x5C)
+#define CSR_DFII_BA_P1                 DFII_CSR(0x60)
+#define CSR_DFII_WD0_P1                        DFII_CSR(0x64)
+#define CSR_DFII_WD1_P1                        DFII_CSR(0x68)
+#define CSR_DFII_WD2_P1                        DFII_CSR(0x6C)
+#define CSR_DFII_WD3_P1                        DFII_CSR(0x70)
+#define CSR_DFII_WD4_P1                        DFII_CSR(0x74)
+#define CSR_DFII_WD5_P1                        DFII_CSR(0x78)
+#define CSR_DFII_WD6_P1                        DFII_CSR(0x7C)
+#define CSR_DFII_WD7_P1                        DFII_CSR(0x80)
+#define CSR_DFII_RD0_P1                        DFII_CSR(0x84)
+#define CSR_DFII_RD1_P1                        DFII_CSR(0x88)
+#define CSR_DFII_RD2_P1                        DFII_CSR(0x8C)
+#define CSR_DFII_RD3_P1                        DFII_CSR(0x90)
+#define CSR_DFII_RD4_P1                        DFII_CSR(0x94)
+#define CSR_DFII_RD5_P1                        DFII_CSR(0x98)
+#define CSR_DFII_RD6_P1                        DFII_CSR(0x9C)
+#define CSR_DFII_RD7_P1                        DFII_CSR(0xA0)
+
+#define DFII_COMMAND_CS                        0x01
+#define DFII_COMMAND_WE                        0x02
+#define DFII_COMMAND_CAS               0x04
+#define DFII_COMMAND_RAS               0x08
+#define DFII_COMMAND_WRDATA            0x10
+#define DFII_COMMAND_RDDATA            0x20
 
 #endif /* __HW_DFII_H */
index d472e5d727afd44027f63d8e0ee028c16f2ead8e..1ee37869970aac6fb3fe795975703e81182233e4 100644 (file)
 #define __HW_UART_H
 
 #include <hw/common.h>
+#include <csrbase.h>
 
-#define CSR_UART_RXTX          MMPTR(0xe0000000)
-#define CSR_UART_DIVISORH      MMPTR(0xe0000004)
-#define CSR_UART_DIVISORL      MMPTR(0xe0000008)
+#define UART_CSR(x)            MMPTR(UART_BASE+(x))
 
-#define CSR_UART_EV_STAT       MMPTR(0xe000000c)
-#define CSR_UART_EV_PENDING    MMPTR(0xe0000010)
-#define CSR_UART_EV_ENABLE     MMPTR(0xe0000014)
+#define CSR_UART_RXTX          UART_CSR(0x00)
+#define CSR_UART_DIVISORH      UART_CSR(0x04)
+#define CSR_UART_DIVISORL      UART_CSR(0x08)
 
-#define UART_EV_TX             (0x1)
-#define UART_EV_RX             (0x2)
+#define CSR_UART_EV_STAT       UART_CSR(0x0c)
+#define CSR_UART_EV_PENDING    UART_CSR(0x10)
+#define CSR_UART_EV_ENABLE     UART_CSR(0x14)
+
+#define UART_EV_TX             0x1
+#define UART_EV_RX             0x2
 
 #endif /* __HW_UART_H */
index a880230be3859a4b047487c726b21ef37c8e97b9..134be463b5f583017a6442663f0531fd7e3d1cb2 100644 (file)
@@ -4,7 +4,7 @@ CC=clang
 all: $(TARGETS)
 
 %: %.c
-       $(CC) -O2 -Wall -I. -s -o $@ $<
+       $(CC) -O2 -Wall -I../common -s -o $@ $<
 
 install: mkmmimg flterm
        install -d /usr/local/bin
diff --git a/tools/sfl.h b/tools/sfl.h
deleted file mode 100644 (file)
index 90a205f..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Milkymist SoC
- * 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 __SFL_H
-#define __SFL_H
-
-#define SFL_MAGIC_LEN 14
-#define SFL_MAGIC_REQ "sL5DdSMmkekro\n"
-#define SFL_MAGIC_ACK "z6IHG7cYDID6o\n"
-
-struct sfl_frame {
-       unsigned char length;
-       unsigned char crc[2];
-       unsigned char cmd;
-       unsigned char payload[255];
-} __attribute__((packed));
-
-/* General commands */
-#define SFL_CMD_ABORT          0x00
-#define SFL_CMD_LOAD           0x01
-#define SFL_CMD_JUMP           0x02
-
-/* Linux-specific commands */
-#define SFL_CMD_CMDLINE                0x03
-#define SFL_CMD_INITRDSTART    0x04
-#define SFL_CMD_INITRDEND      0x05
-
-/* Replies */
-#define SFL_ACK_SUCCESS                'K'
-#define SFL_ACK_CRCERROR       'C'
-#define SFL_ACK_UNKNOWN                'U'
-#define SFL_ACK_ERROR          'E'
-
-#endif /* __SFL_H */