1
0
mirror of https://github.com/corundum/corundum.git synced 2025-01-16 08:12:53 +08:00

Move fpga_id into library

Signed-off-by: Alex Forencich <alex@alexforencich.com>
This commit is contained in:
Alex Forencich 2022-04-19 13:36:02 -07:00
parent 730ccf3a5b
commit e6c18cfb68
7 changed files with 12 additions and 10 deletions

View File

@ -11,7 +11,7 @@ CFLAGS += -Wall
CPPFLAGS +=
LIB = libmqnic.a
INCLUDES = mqnic.h mqnic_hw.h mqnic_ioctl.h reg_block.h
INCLUDES = mqnic.h mqnic_hw.h mqnic_ioctl.h reg_block.h fpga_id.h
GENDEPFLAGS = -MD -MP -MF .$(@F).d
@ -22,7 +22,7 @@ all: $(LIB)
%.o: %.c
$(CC) $(ALL_CFLAGS) -c -o $@ $<
libmqnic.a: mqnic.o mqnic_if.o mqnic_sched_block.o mqnic_scheduler.o reg_block.o
libmqnic.a: mqnic.o mqnic_if.o mqnic_sched_block.o mqnic_scheduler.o reg_block.o fpga_id.o
ar rcs $@ $^
install:

View File

@ -1,6 +1,6 @@
/*
Copyright 2020, The Regents of the University of California.
Copyright 2020-2022, The Regents of the University of California.
All rights reserved.
Redistribution and use in source and binary forms, with or without

View File

@ -1,6 +1,6 @@
/*
Copyright 2020, The Regents of the University of California.
Copyright 2020-2022, The Regents of the University of California.
All rights reserved.
Redistribution and use in source and binary forms, with or without

View File

@ -33,6 +33,7 @@ either expressed or implied, of The Regents of the University of California.
#include "mqnic.h"
#include "mqnic_ioctl.h"
#include "fpga_id.h"
#include <dirent.h>
#include <fcntl.h>
@ -406,6 +407,8 @@ open:
dev->git_hash = mqnic_reg_read32(dev->fw_id_rb->regs, MQNIC_RB_FW_ID_REG_GIT_HASH);
dev->rel_info = mqnic_reg_read32(dev->fw_id_rb->regs, MQNIC_RB_FW_ID_REG_REL_INFO);
dev->fpga_part = get_fpga_part(dev->fpga_id);
time_t build_date = dev->build_date;
struct tm *tm_info = gmtime(&build_date);
strftime(dev->build_date_str, sizeof(dev->build_date_str), "%F %T", tm_info);

View File

@ -142,6 +142,7 @@ struct mqnic {
struct reg_block *phc_rb;
uint32_t fpga_id;
const char *fpga_part;
uint32_t fw_id;
uint32_t fw_ver;
uint32_t board_id;

View File

@ -38,7 +38,7 @@ mqnic-config: mqnic-config.o timespec.o $(LIBMQNIC)
mqnic-dump: mqnic-dump.o $(LIBMQNIC)
$(CC) $(ALL_CFLAGS) $(LDFLAGS) $^ -o $@ $(LDLIBS)
mqnic-fw: mqnic-fw.o flash.o flash_spi.o flash_bpi.o fpga_id.o bitfile.o $(LIBMQNIC)
mqnic-fw: mqnic-fw.o flash.o flash_spi.o flash_bpi.o bitfile.o $(LIBMQNIC)
$(CC) $(ALL_CFLAGS) $(LDFLAGS) $^ -o $@ $(LDLIBS)
mqnic-bmc: mqnic-bmc.o $(LIBMQNIC)

View File

@ -45,7 +45,6 @@ either expressed or implied, of The Regents of the University of California.
#include <mqnic/mqnic.h>
#include "bitfile.h"
#include "flash.h"
#include "fpga_id.h"
#define MAX_SEGMENTS 8
@ -655,7 +654,6 @@ int main(int argc, char *argv[])
printf("PCIe ID (upstream port): %s\n", strrchr(pci_port_path, '/')+1);
uint32_t flash_format = 0;
const char *fpga_part = get_fpga_part(dev->fpga_id);
uint8_t flash_configuration = 0;
uint8_t flash_data_width = 0;
@ -664,7 +662,7 @@ int main(int argc, char *argv[])
uint32_t flash_segment0_length = 0;
printf("FPGA ID: 0x%08x\n", dev->fpga_id);
printf("FPGA part: %s\n", fpga_part);
printf("FPGA part: %s\n", dev->fpga_part);
printf("FW ID: 0x%08x\n", dev->fw_id);
printf("FW version: %d.%d.%d.%d\n", dev->fw_ver >> 24,
(dev->fw_ver >> 16) & 0xff,
@ -1053,9 +1051,9 @@ int main(int argc, char *argv[])
goto err;
}
if (stristr(bf->part, fpga_part) != bf->part)
if (stristr(bf->part, dev->fpga_part) != bf->part)
{
fprintf(stderr, "Device mismatch (target is %s, file is %s)\n", fpga_part, bf->part);
fprintf(stderr, "Device mismatch (target is %s, file is %s)\n", dev->fpga_part, bf->part);
bitfile_close(bf);
free(segment);
ret = -1;