Skip to content

Commit

Permalink
Simplify system ID
Browse files Browse the repository at this point in the history
Sebastien Bourdeauducq committed May 19, 2013

Verified

This commit was signed with the committer’s verified signature.
jtojnar Jan Tojnar
1 parent d487dc6 commit 3eb41f7
Showing 7 changed files with 68 additions and 127 deletions.
1 change: 0 additions & 1 deletion software/bios/boot.c
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@
#include <console.h>
#include <uart.h>
#include <system.h>
#include <board.h>
#include <crc.h>
#include <sfl.h>
#include <string.h>
4 changes: 2 additions & 2 deletions software/bios/main.c
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
#include <string.h>
#include <uart.h>
#include <system.h>
#include <board.h>
#include <id.h>
#include <irq.h>
#include <version.h>
#include <crc.h>
@@ -515,7 +515,7 @@ int main(int i, char **c)
crcbios();
if(rescue)
printf("Rescue mode\n");
board_init();
id_print();
ethreset();
print_mac();
ddr_ok = ddrinit();
27 changes: 0 additions & 27 deletions software/include/base/board.h

This file was deleted.

18 changes: 18 additions & 0 deletions software/include/base/id.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef __ID_H
#define __ID_H

#ifdef __cplusplus
extern "C" {
#endif

void get_sysid_formatted(char *sysid);
void get_soc_version(unsigned int *major, unsigned int *minor, unsigned int *subminor, unsigned int *rc);
void get_soc_version_formatted(char *version);

void id_print(void);

#ifdef __cplusplus
}
#endif

#endif /* __ID_H */
2 changes: 1 addition & 1 deletion software/libbase/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
M2DIR=../..
include $(M2DIR)/software/common.mak

OBJECTS=setjmp.o libc.o errno.o crc16.o crc32.o console.o system.o board.o uart.o qsort.o strtod.o
OBJECTS=setjmp.o libc.o errno.o crc16.o crc32.o console.o system.o id.o uart.o qsort.o strtod.o

all: libbase.a libbase-nofloat.a

96 changes: 0 additions & 96 deletions software/libbase/board.c

This file was deleted.

47 changes: 47 additions & 0 deletions software/libbase/id.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#include <hw/csr.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <version.h>
#include <id.h>

void get_sysid_formatted(char *sysid)
{
sysid[0] = identifier_sysid_read() >> 8;
sysid[1] = identifier_sysid_read();
sysid[2] = 0;
}

void get_soc_version(unsigned int *major, unsigned int *minor, unsigned int *subminor, unsigned int *rc)
{
unsigned int id;

id = identifier_version_read();
*major = (id & 0xf000) >> 12;
*minor = (id & 0x0f00) >> 8;
*subminor = (id & 0x00f0) >> 4;
*rc = id & 0x000f;
}

void get_soc_version_formatted(char *version)
{
unsigned int major, minor, subminor, rc;

get_soc_version(&major, &minor, &subminor, &rc);

version += sprintf(version, "%u.%u", major, minor);
if(subminor != 0)
version += sprintf(version, ".%u", subminor);
if(rc != 0)
sprintf(version, "RC%u", rc);
}

void id_print(void)
{
char soc_version[13];
char sysid[3];

get_soc_version_formatted(soc_version);
get_sysid_formatted(sysid);
printf("Running on Milkymist-ng SoC %s (sysid:%s) at %dMHz\n", soc_version, sysid, identifier_frequency_read()/1000000);
}

0 comments on commit 3eb41f7

Please sign in to comment.