Commit 1351c828 authored by NiteHawk's avatar NiteHawk Committed by GitHub
Browse files

Merge pull request #72 from n1tehawk/contrib

Minor compilation fixes
parents 9a3d62aa beed0028
...@@ -98,8 +98,14 @@ sunxi-fexc: fexc.h script.h script.c \ ...@@ -98,8 +98,14 @@ sunxi-fexc: fexc.h script.h script.c \
script_fex.h script_fex.c script_fex.h script_fex.c
LIBUSB = libusb-1.0 LIBUSB = libusb-1.0
LIBUSB_CFLAGS = `pkg-config --cflags $(LIBUSB)` LIBUSB_CFLAGS ?= `pkg-config --cflags $(LIBUSB)`
LIBUSB_LIBS = `pkg-config --libs $(LIBUSB)` LIBUSB_LIBS ?= `pkg-config --libs $(LIBUSB)`
ifeq ($(OS),Windows_NT)
# Windows lacks mman.h / mmap()
DEFINES += -DNO_MMAP
# portable_endian.h relies on winsock2
LIBS += -lws2_32
endif
sunxi-fel: fel.c fel-to-spl-thunk.h progress.c progress.h sunxi-fel: fel.c fel-to-spl-thunk.h progress.c progress.h
$(CC) $(CFLAGS) $(LIBUSB_CFLAGS) $(LDFLAGS) -o $@ $(filter %.c,$^) $(LIBS) $(LIBUSB_LIBS) $(CC) $(CFLAGS) $(LIBUSB_CFLAGS) $(LDFLAGS) -o $@ $(filter %.c,$^) $(LIBS) $(LIBUSB_LIBS)
......
...@@ -198,7 +198,7 @@ void print_boot_file_head(boot_file_head_t *hdr) ...@@ -198,7 +198,7 @@ void print_boot_file_head(boot_file_head_t *hdr)
void print_boot_dram_para(boot_dram_para_t *dram) void print_boot_dram_para(boot_dram_para_t *dram)
{ {
pprintf(&dram->dram_baseaddr, "DRAM base : %p\n", (void *)(long)dram->dram_baseaddr); pprintf(&dram->dram_baseaddr, "DRAM base : %p\n", (void *)(uintptr_t)dram->dram_baseaddr);
pprintf(&dram->dram_clk, "DRAM clk : %d\n", dram->dram_clk); pprintf(&dram->dram_clk, "DRAM clk : %d\n", dram->dram_clk);
pprintf(&dram->dram_type, "DRAM type : %d\n", dram->dram_type); pprintf(&dram->dram_type, "DRAM type : %d\n", dram->dram_type);
pprintf(&dram->dram_rank_num, "DRAM rank : %d\n", dram->dram_rank_num); pprintf(&dram->dram_rank_num, "DRAM rank : %d\n", dram->dram_rank_num);
......
...@@ -15,6 +15,10 @@ ...@@ -15,6 +15,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "common.h"
#include "portable_endian.h"
#include "progress.h"
#include <libusb.h> #include <libusb.h>
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
...@@ -28,10 +32,6 @@ ...@@ -28,10 +32,6 @@
#include <unistd.h> #include <unistd.h>
#include <sys/stat.h> #include <sys/stat.h>
#include "common.h"
#include "portable_endian.h"
#include "progress.h"
static const uint16_t AW_USB_VENDOR_ID = 0x1F3A; static const uint16_t AW_USB_VENDOR_ID = 0x1F3A;
static const uint16_t AW_USB_PRODUCT_ID = 0xEFE8; static const uint16_t AW_USB_PRODUCT_ID = 0xEFE8;
...@@ -325,7 +325,7 @@ void hexdump(void *data, uint32_t offset, size_t size) ...@@ -325,7 +325,7 @@ void hexdump(void *data, uint32_t offset, size_t size)
unsigned char *buf = data; unsigned char *buf = data;
for (j = 0; j < size; j+=16) { for (j = 0; j < size; j+=16) {
size_t i; size_t i;
printf("%08lx: ",(long int)offset + j); printf("%08zx: ", offset + j);
for (i = 0; i < 16; i++) { for (i = 0; i < 16; i++) {
if (j + i < size) if (j + i < size)
printf("%02x ", buf[j+i]); printf("%02x ", buf[j+i]);
......
...@@ -21,7 +21,9 @@ ...@@ -21,7 +21,9 @@
#include <libgen.h> #include <libgen.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <sys/mman.h> #ifndef NO_MMAP
#include <sys/mman.h>
#endif
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
...@@ -117,6 +119,7 @@ static inline int script_parse(enum script_format format, ...@@ -117,6 +119,7 @@ static inline int script_parse(enum script_format format,
pr_err("%s: %s: %s\n", filename, pr_err("%s: %s: %s\n", filename,
"fstat", strerror(errno)); "fstat", strerror(errno));
goto bin_close; goto bin_close;
#ifndef NO_MMAP
} else if (S_ISREG(sb.st_mode)) { } else if (S_ISREG(sb.st_mode)) {
/* regular file, mmap it */ /* regular file, mmap it */
bin = mmap(0, sb.st_size, PROT_READ, MAP_SHARED, in, 0); bin = mmap(0, sb.st_size, PROT_READ, MAP_SHARED, in, 0);
...@@ -127,6 +130,7 @@ static inline int script_parse(enum script_format format, ...@@ -127,6 +130,7 @@ static inline int script_parse(enum script_format format,
} }
bin_size = sb.st_size; bin_size = sb.st_size;
allocated = 0; allocated = 0;
#endif
} else { } else {
/* something else... just read it all! */ /* something else... just read it all! */
bin = read_all(in, filename, &bin_size); bin = read_all(in, filename, &bin_size);
...@@ -138,10 +142,12 @@ static inline int script_parse(enum script_format format, ...@@ -138,10 +142,12 @@ static inline int script_parse(enum script_format format,
ret = script_decompile_bin(bin, bin_size, filename, script); ret = script_decompile_bin(bin, bin_size, filename, script);
if (allocated) if (allocated)
free(bin); free(bin);
#ifndef NO_MMAP
else if (munmap(bin, bin_size) == -1) { else if (munmap(bin, bin_size) == -1) {
pr_err("%s: %s: %s\n", filename, pr_err("%s: %s: %s\n", filename,
"munmap", strerror(errno)); "munmap", strerror(errno));
} }
#endif
bin_close: bin_close:
close(in); close(in);
}; break; }; break;
......
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
#include <sys/io.h> #include <sys/io.h>
#include <stdbool.h> #include <stdbool.h>
#include "common.h"
typedef uint32_t u32; typedef uint32_t u32;
/* from u-boot code: */ /* from u-boot code: */
...@@ -412,7 +414,7 @@ sun4i_dram_para_print_fex(struct sun4i_dram_para *dram_para) ...@@ -412,7 +414,7 @@ sun4i_dram_para_print_fex(struct sun4i_dram_para *dram_para)
static int static int
sun4i_dram_para_print(bool uboot) sun4i_dram_para_print(bool uboot)
{ {
struct sun4i_dram_para dram_para = {0}; struct sun4i_dram_para dram_para = { .baseaddr = 0 };
int ret; int ret;
ret = sunxi_dram_clock_read(&dram_para.clock); ret = sunxi_dram_clock_read(&dram_para.clock);
...@@ -710,6 +712,7 @@ sun8i_dram_regs_print(void) ...@@ -710,6 +712,7 @@ sun8i_dram_regs_print(void)
static void static void
print_usage(const char *name) print_usage(const char *name)
{ {
puts("sunxi-meminfo " VERSION "\n");
printf("Utility to retrieve DRAM information from registers on " printf("Utility to retrieve DRAM information from registers on "
"Allwinner SoCs.\n"); "Allwinner SoCs.\n");
printf("\n"); printf("\n");
......
...@@ -257,7 +257,7 @@ static void encode_bch(struct bch_control *bch, const uint8_t *data, ...@@ -257,7 +257,7 @@ static void encode_bch(struct bch_control *bch, const uint8_t *data,
} }
/* process first unaligned data bytes */ /* process first unaligned data bytes */
m = ((unsigned long)data) & 3; m = ((uintptr_t)data) & 3;
if (m) { if (m) {
mlen = (len < (4-m)) ? len : 4-m; mlen = (len < (4-m)) ? len : 4-m;
encode_bch_unaligned(bch, data, mlen, bch->ecc_buf); encode_bch_unaligned(bch, data, mlen, bch->ecc_buf);
......
...@@ -24,7 +24,9 @@ ...@@ -24,7 +24,9 @@
#include <unistd.h> #include <unistd.h>
#include <stdlib.h> #include <stdlib.h>
#include <errno.h> #include <errno.h>
#include <sys/mman.h> #ifndef NO_MMAP
#include <sys/mman.h>
#endif
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
...@@ -365,6 +367,10 @@ int main(int argc, char **argv) ...@@ -365,6 +367,10 @@ int main(int argc, char **argv)
if (!in_name && !do_mmap) if (!in_name && !do_mmap)
usage(1); usage(1);
if (do_mmap) { if (do_mmap) {
#ifdef NO_MMAP
errno = ENOSYS; /* Function not implemented */
perror("mmap PIO");
#else
int pagesize = sysconf(_SC_PAGESIZE); int pagesize = sysconf(_SC_PAGESIZE);
int fd = open("/dev/mem",O_RDWR); int fd = open("/dev/mem",O_RDWR);
int addr = 0x01c20800 & ~(pagesize-1); int addr = 0x01c20800 & ~(pagesize-1);
...@@ -380,6 +386,7 @@ int main(int argc, char **argv) ...@@ -380,6 +386,7 @@ int main(int argc, char **argv)
} }
close(fd); close(fd);
buf += offset; buf += offset;
#endif
} }
if (in_name) { if (in_name) {
if (strcmp(in_name, "-") == 0) { if (strcmp(in_name, "-") == 0) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment