From fc3828388869fdffcf191b7d7ac3db49b0c0839e Mon Sep 17 00:00:00 2001 From: deraadt Date: Mon, 22 Nov 2004 04:14:17 +0000 Subject: build a tigon firmware file. Saves 150KB or so in GENERIC kernels --- sys/dev/microcode/tigon/Makefile | 25 +++++++++ sys/dev/microcode/tigon/build.c | 116 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 141 insertions(+) create mode 100644 sys/dev/microcode/tigon/Makefile create mode 100644 sys/dev/microcode/tigon/build.c (limited to 'sys/dev/microcode') diff --git a/sys/dev/microcode/tigon/Makefile b/sys/dev/microcode/tigon/Makefile new file mode 100644 index 00000000000..56a42b4d599 --- /dev/null +++ b/sys/dev/microcode/tigon/Makefile @@ -0,0 +1,25 @@ +# $OpenBSD: Makefile,v 1.1 2004/11/22 04:14:18 deraadt Exp $ + +NOPROG= +NOMAN= + +# PCI capable systems only +.if (${MACHINE} == "i386") || (${MACHINE} == "amd64") || \ + (${MACHINE} == "alpha") || (${MACHINE} == "sparc64") || \ + (${MACHINE_ARCH} == "powerpc") || (${MACHINE} == "cats") || \ + (${MACHINE} == "hppa") || (${MACHINE} == "sgi") + +FIRM= tigon1 tigon2 + +CLEANFILES+= ${FIRM} build + +all: build + ${.OBJDIR}/build + +afterinstall: + ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 644 \ + ${FIRM} ${DESTDIR}/etc/firmware +.endif + +.include + diff --git a/sys/dev/microcode/tigon/build.c b/sys/dev/microcode/tigon/build.c new file mode 100644 index 00000000000..d7082b6975b --- /dev/null +++ b/sys/dev/microcode/tigon/build.c @@ -0,0 +1,116 @@ +/* $OpenBSD: build.c,v 1.1 2004/11/22 04:14:18 deraadt Exp $ */ + +/* + * Copyright (c) 2004 Theo de Raadt + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ +#include +#include +#include + +#include "ti_fw.h" +#include "ti_fw2.h" + +static void +output(const char *name, + const int FwReleaseMajor, const int FwReleaseMinor, + const int FwReleaseFix, const u_int32_t FwStartAddr, + const u_int32_t FwTextAddr, const int FwTextLen, + const u_int32_t FwRodataAddr, const int FwRodataLen, + const u_int32_t FwDataAddr, const int FwDataLen, + const u_int32_t FwSbssAddr, const int FwSbssLen, + const u_int32_t FwBssAddr, const int FwBssLen, + const u_int32_t *FwText, int sizetext, + const u_int32_t *FwRodata, int sizerodata, + const u_int32_t *FwData, int sizedata) +{ + struct tigon_firmware tfproto, *tf; + int len, fd, i; + + len = sizeof tf - sizeof(tfproto.data) + sizetext + sizerodata + + sizedata; + tf = (struct tigon_firmware *)malloc(len); + bzero(tf, len); + + tf->FwReleaseMajor = FwReleaseMajor; + tf->FwReleaseMinor = FwReleaseMinor; + tf->FwReleaseFix = FwReleaseFix; + tf->FwStartAddr = FwStartAddr; + + tf->FwTextAddr = FwTextAddr; + tf->FwTextLen = FwTextLen; + + tf->FwRodataAddr = FwRodataAddr; + tf->FwRodataLen = FwRodataLen; + + tf->FwDataAddr = FwDataAddr; + tf->FwDataLen = FwDataLen; + + tf->FwSbssAddr = FwSbssAddr; + tf->FwSbssLen = FwSbssLen; + + tf->FwBssAddr = FwBssAddr; + tf->FwBssLen = FwBssLen; + + tf->FwTextOffset = 0; + tf->FwRodataOffset = sizetext; + tf->FwDataOffset = sizetext + sizerodata; + + bcopy(FwText, &tf->data[tf->FwTextOffset], FwTextLen); + bcopy(FwRodata, &tf->data[tf->FwRodataOffset], FwRodataLen); + bcopy(FwData, &tf->data[tf->FwDataOffset], FwDataLen); + + printf("creating %s length %d [%d+%d+%d] [%d+%d+%d]\n", + name, len, FwTextLen, FwRodataLen, FwDataLen, + sizetext, sizerodata, sizedata); + fd = open(name, O_WRONLY|O_CREAT|O_TRUNC, 0644); + if (fd == -1) + err(1, "%s", name); + + write(fd, tf, len); + free(tf); + close(fd); +} + + +int +main(int argc, char *argv[]) +{ + + output("tigon1", + tigonFwReleaseMajor, tigonFwReleaseMinor, + tigonFwReleaseFix, tigonFwStartAddr, + tigonFwTextAddr, tigonFwTextLen, + tigonFwRodataAddr, tigonFwRodataLen, + tigonFwDataAddr, tigonFwDataLen, + tigonFwSbssAddr, tigonFwSbssLen, + tigonFwBssAddr, tigonFwBssLen, + tigonFwText, sizeof tigonFwText, + tigonFwRodata, sizeof tigonFwRodata, + tigonFwData, sizeof tigonFwData); + + output("tigon2", + tigon2FwReleaseMajor, tigon2FwReleaseMinor, + tigon2FwReleaseFix, tigon2FwStartAddr, + tigon2FwTextAddr, tigon2FwTextLen, + tigon2FwRodataAddr, tigon2FwRodataLen, + tigon2FwDataAddr, tigon2FwDataLen, + tigon2FwSbssAddr, tigon2FwSbssLen, + tigon2FwBssAddr, tigon2FwBssLen, + tigon2FwText, sizeof tigon2FwText, + tigon2FwRodata, sizeof tigon2FwRodata, + tigon2FwData, sizeof tigon2FwData); + + return 0; +} -- cgit v1.3-18-gd494