diff mbox

[1/2] lib: remove fwts_microcode

Message ID 1369837865-22272-2-git-send-email-colin.king@canonical.com
State Accepted
Headers show

Commit Message

Colin Ian King May 29, 2013, 2:31 p.m. UTC
From: Colin Ian King <colin.king@canonical.com>

Remove legacy microcode loading, we won't require this if we just
parse the kernel load and scan for microcode update messages.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/lib/include/fwts.h           |   1 -
 src/lib/include/fwts_microcode.h |  28 ----------
 src/lib/src/Makefile.am          |   1 -
 src/lib/src/fwts_microcode.c     | 117 ---------------------------------------
 4 files changed, 147 deletions(-)
 delete mode 100644 src/lib/include/fwts_microcode.h
 delete mode 100644 src/lib/src/fwts_microcode.c

Comments

Alex Hung May 30, 2013, 2:01 a.m. UTC | #1
Acked-by: Alex Hung <alex.hung@canonical.com>


On Wed, May 29, 2013 at 10:31 PM, Colin King <colin.king@canonical.com>wrote:

> From: Colin Ian King <colin.king@canonical.com>
>
> Remove legacy microcode loading, we won't require this if we just
> parse the kernel load and scan for microcode update messages.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/lib/include/fwts.h           |   1 -
>  src/lib/include/fwts_microcode.h |  28 ----------
>  src/lib/src/Makefile.am          |   1 -
>  src/lib/src/fwts_microcode.c     | 117
> ---------------------------------------
>  4 files changed, 147 deletions(-)
>  delete mode 100644 src/lib/include/fwts_microcode.h
>  delete mode 100644 src/lib/src/fwts_microcode.c
>
> diff --git a/src/lib/include/fwts.h b/src/lib/include/fwts.h
> index 680eab9..ba1b312 100644
> --- a/src/lib/include/fwts.h
> +++ b/src/lib/include/fwts.h
> @@ -59,7 +59,6 @@
>  #include "fwts_formatting.h"
>  #include "fwts_summary.h"
>  #include "fwts_mmap.h"
> -#include "fwts_microcode.h"
>  #include "fwts_interactive.h"
>  #include "fwts_keymap.h"
>  #include "fwts_cmos.h"
> diff --git a/src/lib/include/fwts_microcode.h
> b/src/lib/include/fwts_microcode.h
> deleted file mode 100644
> index 886b4eb..0000000
> --- a/src/lib/include/fwts_microcode.h
> +++ /dev/null
> @@ -1,28 +0,0 @@
> -/*
> - * Copyright (C) 2010-2013 Canonical
> - *
> - * 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; either version 2
> - * of the License, or (at your option) any later version.
> - *
> - * 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, write to the Free Software
> - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
> 02110-1301, USA.
> - *
> - */
> -
> -#ifndef __FWTS_MICROCODE_H__
> -#define __FWTS_MICROCODE_H__
> -
> -#define FWTS_MICROCODE_DEVICE  "/dev/cpu/microcode"
> -#define FWTS_MICROCODE_FILE    "/usr/share/misc/intel-microcode.dat"
> -
> -int fwts_update_microcode(fwts_framework *fw, const char *device, const
> char *filename);
> -
> -#endif
> diff --git a/src/lib/src/Makefile.am b/src/lib/src/Makefile.am
> index 4d9ab38..662d27f 100644
> --- a/src/lib/src/Makefile.am
> +++ b/src/lib/src/Makefile.am
> @@ -54,7 +54,6 @@ libfwts_la_SOURCES =          \
>         fwts_log_plaintext.c    \
>         fwts_log_xml.c          \
>         fwts_memorymap.c        \
> -       fwts_microcode.c        \
>         fwts_mmap.c             \
>         fwts_multiproc.c        \
>         fwts_oops.c             \
> diff --git a/src/lib/src/fwts_microcode.c b/src/lib/src/fwts_microcode.c
> deleted file mode 100644
> index 0bcbc4b..0000000
> --- a/src/lib/src/fwts_microcode.c
> +++ /dev/null
> @@ -1,117 +0,0 @@
> -/*
> - * Copyright 2000 (c) Simon Trimmer, Tigran Aivazian.
> - * Copyright (C) 2010-2013 Canonical
> - *
> - * Originally microcode_ctl.c
> - * Manipulate /dev/cpu/microcode under Linux
> - *
> - * 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; either version 2
> - * of the License, or (at your option) any later version.
> - *
> - * 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, write to the Free Software
> - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
> 02110-1301, USA.
> - *
> - */
> -
> -#include <fcntl.h>
> -#include <stdio.h>
> -#include <stdlib.h>
> -#include <errno.h>
> -#include <unistd.h>
> -#include <string.h>
> -
> -#include "fwts.h"
> -
> -#define BUFFER_SIZE    (4096)
> -#define MICROCODE_SIZE         (128*1024)      /* initial size, expanded
> as needed */
> -
> -/*
> - *  fwts_update_microcode()
> - *     load given microcode file into a processor
> - */
> -int fwts_update_microcode(fwts_framework *fw, const char *device, const
> char *filename)
> -{
> -       FILE *fp;
> -       char line_buffer[BUFFER_SIZE];
> -       size_t microcode_size = MICROCODE_SIZE/sizeof(unsigned);
> -       unsigned *microcode;
> -       size_t pos = 0;
> -       int fd;
> -       int wrote, length;
> -
> -       if ((microcode = calloc(1, microcode_size * sizeof(unsigned))) ==
> NULL) {
> -               fwts_log_error(fw, "Cannot allocate memory.");
> -               return FWTS_ERROR;
> -       }
> -
> -       if ((fp = fopen(filename, "r")) == NULL) {
> -               fwts_log_error(fw, "Cannot open source '%s'.", filename);
> -               free(microcode);
> -               return FWTS_ERROR;
> -       }
> -
> -       while (fgets(line_buffer, BUFFER_SIZE, fp) != NULL) {
> -               /*
> -                * Expand microcode buffer if needed
> -                */
> -               if (microcode_size < pos + 4) {
> -                    microcode_size *= 2;
> -                    microcode = realloc(microcode,
> -                                       microcode_size * sizeof(unsigned
> int));
> -                       if (microcode == NULL) {
> -                               fwts_log_error(fw, "Cannot allocate
> memory.");
> -                               fclose(fp);
> -                               return FWTS_ERROR;
> -                       }
> -               }
> -               /*
> -                * Data lines will are of the form "%x, %x, %x, %x",
> therefore
> -                * lines start with a 0
> -                */
> -               if (*line_buffer == '0') {
> -                       int scanned;
> -                       scanned = sscanf(line_buffer, "%x, %x, %x, %x",
> -                                       microcode + pos,
> -                                       microcode + pos + 1,
> -                                       microcode + pos + 2,
> -                                       microcode + pos + 3);
> -                       if (scanned != 4) {
> -                               fwts_log_error(fw, "%s: invalid file
> format", filename);
> -                               fclose(fp);
> -                               free(microcode);
> -                               return FWTS_ERROR;
> -                       }
> -                       pos += 4;
> -               }
> -       }
> -       fclose(fp);
> -
> -       length = pos * sizeof(unsigned int);
> -
> -       if ((fd = open(device, O_WRONLY)) == -1) {
> -               fwts_log_error(fw, "Cannot open %s for writing errno=%d
> (%s)\n",
> -                               device, errno, strerror(errno));
> -               free(microcode);
> -               return FWTS_ERROR;
> -       }
> -
> -       if ((wrote = write(fd, microcode, length)) < 0) {
> -               fwts_log_error(fw, "Error writing microcode.");
> -               close(fd);
> -               free(microcode);
> -               return FWTS_ERROR;
> -       }
> -
> -       close(fd);
> -       free(microcode);
> -
> -       return FWTS_OK;
> -}
> --
> 1.8.1.2
>
>
> --
> fwts-devel mailing list
> fwts-devel@lists.ubuntu.com
> Modify settings or unsubscribe at:
> https://lists.ubuntu.com/mailman/listinfo/fwts-devel
>
Ivan Hu May 31, 2013, 7:47 a.m. UTC | #2
On 05/29/2013 10:31 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Remove legacy microcode loading, we won't require this if we just
> parse the kernel load and scan for microcode update messages.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/lib/include/fwts.h           |   1 -
>   src/lib/include/fwts_microcode.h |  28 ----------
>   src/lib/src/Makefile.am          |   1 -
>   src/lib/src/fwts_microcode.c     | 117 ---------------------------------------
>   4 files changed, 147 deletions(-)
>   delete mode 100644 src/lib/include/fwts_microcode.h
>   delete mode 100644 src/lib/src/fwts_microcode.c
>
> diff --git a/src/lib/include/fwts.h b/src/lib/include/fwts.h
> index 680eab9..ba1b312 100644
> --- a/src/lib/include/fwts.h
> +++ b/src/lib/include/fwts.h
> @@ -59,7 +59,6 @@
>   #include "fwts_formatting.h"
>   #include "fwts_summary.h"
>   #include "fwts_mmap.h"
> -#include "fwts_microcode.h"
>   #include "fwts_interactive.h"
>   #include "fwts_keymap.h"
>   #include "fwts_cmos.h"
> diff --git a/src/lib/include/fwts_microcode.h b/src/lib/include/fwts_microcode.h
> deleted file mode 100644
> index 886b4eb..0000000
> --- a/src/lib/include/fwts_microcode.h
> +++ /dev/null
> @@ -1,28 +0,0 @@
> -/*
> - * Copyright (C) 2010-2013 Canonical
> - *
> - * 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; either version 2
> - * of the License, or (at your option) any later version.
> - *
> - * 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, write to the Free Software
> - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
> - *
> - */
> -
> -#ifndef __FWTS_MICROCODE_H__
> -#define __FWTS_MICROCODE_H__
> -
> -#define FWTS_MICROCODE_DEVICE	"/dev/cpu/microcode"
> -#define FWTS_MICROCODE_FILE	"/usr/share/misc/intel-microcode.dat"
> -
> -int fwts_update_microcode(fwts_framework *fw, const char *device, const char *filename);
> -
> -#endif
> diff --git a/src/lib/src/Makefile.am b/src/lib/src/Makefile.am
> index 4d9ab38..662d27f 100644
> --- a/src/lib/src/Makefile.am
> +++ b/src/lib/src/Makefile.am
> @@ -54,7 +54,6 @@ libfwts_la_SOURCES = 		\
>   	fwts_log_plaintext.c 	\
>   	fwts_log_xml.c 		\
>   	fwts_memorymap.c 	\
> -	fwts_microcode.c 	\
>   	fwts_mmap.c 		\
>   	fwts_multiproc.c 	\
>   	fwts_oops.c 		\
> diff --git a/src/lib/src/fwts_microcode.c b/src/lib/src/fwts_microcode.c
> deleted file mode 100644
> index 0bcbc4b..0000000
> --- a/src/lib/src/fwts_microcode.c
> +++ /dev/null
> @@ -1,117 +0,0 @@
> -/*
> - * Copyright 2000 (c) Simon Trimmer, Tigran Aivazian.
> - * Copyright (C) 2010-2013 Canonical
> - *
> - * Originally microcode_ctl.c
> - * Manipulate /dev/cpu/microcode under Linux
> - *
> - * 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; either version 2
> - * of the License, or (at your option) any later version.
> - *
> - * 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, write to the Free Software
> - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
> - *
> - */
> -
> -#include <fcntl.h>
> -#include <stdio.h>
> -#include <stdlib.h>
> -#include <errno.h>
> -#include <unistd.h>
> -#include <string.h>
> -
> -#include "fwts.h"
> -
> -#define BUFFER_SIZE	(4096)
> -#define MICROCODE_SIZE 	(128*1024) 	/* initial size, expanded as needed */
> -
> -/*
> - *  fwts_update_microcode()
> - * 	load given microcode file into a processor
> - */
> -int fwts_update_microcode(fwts_framework *fw, const char *device, const char *filename)
> -{
> -	FILE *fp;
> -	char line_buffer[BUFFER_SIZE];
> -	size_t microcode_size = MICROCODE_SIZE/sizeof(unsigned);
> -	unsigned *microcode;
> -	size_t pos = 0;
> -	int fd;
> -	int wrote, length;
> -
> -	if ((microcode = calloc(1, microcode_size * sizeof(unsigned))) == NULL) {
> -		fwts_log_error(fw, "Cannot allocate memory.");
> -		return FWTS_ERROR;
> -	}
> -
> -	if ((fp = fopen(filename, "r")) == NULL) {
> -		fwts_log_error(fw, "Cannot open source '%s'.", filename);
> -		free(microcode);
> -		return FWTS_ERROR;
> -	}
> -
> -	while (fgets(line_buffer, BUFFER_SIZE, fp) != NULL) {
> -		/*
> -		 * Expand microcode buffer if needed
> -		 */
> -		if (microcode_size < pos + 4) {
> -                    microcode_size *= 2;
> -                    microcode = realloc(microcode,
> -                                       microcode_size * sizeof(unsigned int));
> -			if (microcode == NULL) {
> -				fwts_log_error(fw, "Cannot allocate memory.");
> -				fclose(fp);
> -				return FWTS_ERROR;
> -			}
> -		}
> -		/*
> -		 * Data lines will are of the form "%x, %x, %x, %x", therefore
> -		 * lines start with a 0
> -		 */
> -		if (*line_buffer == '0') {
> -			int scanned;
> -			scanned = sscanf(line_buffer, "%x, %x, %x, %x",
> -					microcode + pos,
> -					microcode + pos + 1,
> -					microcode + pos + 2,
> -					microcode + pos + 3);
> -			if (scanned != 4) {
> -				fwts_log_error(fw, "%s: invalid file format", filename);
> -				fclose(fp);
> -				free(microcode);
> -				return FWTS_ERROR;
> -			}
> -			pos += 4;
> -		}
> -	}
> -	fclose(fp);
> -
> -	length = pos * sizeof(unsigned int);
> -
> -	if ((fd = open(device, O_WRONLY)) == -1) {
> -		fwts_log_error(fw, "Cannot open %s for writing errno=%d (%s)\n",
> -				device, errno, strerror(errno));
> -		free(microcode);
> -		return FWTS_ERROR;
> -	}
> -
> -	if ((wrote = write(fd, microcode, length)) < 0) {
> -		fwts_log_error(fw, "Error writing microcode.");
> -		close(fd);
> -		free(microcode);
> -		return FWTS_ERROR;
> -	}
> -
> -	close(fd);
> -	free(microcode);
> -
> -	return FWTS_OK;
> -}
>

Acked-by: Ivan Hu <ivan.hu@canonical.com>
diff mbox

Patch

diff --git a/src/lib/include/fwts.h b/src/lib/include/fwts.h
index 680eab9..ba1b312 100644
--- a/src/lib/include/fwts.h
+++ b/src/lib/include/fwts.h
@@ -59,7 +59,6 @@ 
 #include "fwts_formatting.h"
 #include "fwts_summary.h"
 #include "fwts_mmap.h"
-#include "fwts_microcode.h"
 #include "fwts_interactive.h"
 #include "fwts_keymap.h"
 #include "fwts_cmos.h"
diff --git a/src/lib/include/fwts_microcode.h b/src/lib/include/fwts_microcode.h
deleted file mode 100644
index 886b4eb..0000000
--- a/src/lib/include/fwts_microcode.h
+++ /dev/null
@@ -1,28 +0,0 @@ 
-/*
- * Copyright (C) 2010-2013 Canonical
- *
- * 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; either version 2
- * of the License, or (at your option) any later version.
- *
- * 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef __FWTS_MICROCODE_H__
-#define __FWTS_MICROCODE_H__
-
-#define FWTS_MICROCODE_DEVICE	"/dev/cpu/microcode"
-#define FWTS_MICROCODE_FILE	"/usr/share/misc/intel-microcode.dat"
-
-int fwts_update_microcode(fwts_framework *fw, const char *device, const char *filename);
-
-#endif
diff --git a/src/lib/src/Makefile.am b/src/lib/src/Makefile.am
index 4d9ab38..662d27f 100644
--- a/src/lib/src/Makefile.am
+++ b/src/lib/src/Makefile.am
@@ -54,7 +54,6 @@  libfwts_la_SOURCES = 		\
 	fwts_log_plaintext.c 	\
 	fwts_log_xml.c 		\
 	fwts_memorymap.c 	\
-	fwts_microcode.c 	\
 	fwts_mmap.c 		\
 	fwts_multiproc.c 	\
 	fwts_oops.c 		\
diff --git a/src/lib/src/fwts_microcode.c b/src/lib/src/fwts_microcode.c
deleted file mode 100644
index 0bcbc4b..0000000
--- a/src/lib/src/fwts_microcode.c
+++ /dev/null
@@ -1,117 +0,0 @@ 
-/*
- * Copyright 2000 (c) Simon Trimmer, Tigran Aivazian.
- * Copyright (C) 2010-2013 Canonical
- *
- * Originally microcode_ctl.c
- * Manipulate /dev/cpu/microcode under Linux
- *
- * 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; either version 2
- * of the License, or (at your option) any later version.
- *
- * 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <unistd.h>
-#include <string.h>
-
-#include "fwts.h"
-
-#define BUFFER_SIZE	(4096)
-#define MICROCODE_SIZE 	(128*1024) 	/* initial size, expanded as needed */
-
-/*
- *  fwts_update_microcode()
- * 	load given microcode file into a processor
- */
-int fwts_update_microcode(fwts_framework *fw, const char *device, const char *filename)
-{
-	FILE *fp;
-	char line_buffer[BUFFER_SIZE];
-	size_t microcode_size = MICROCODE_SIZE/sizeof(unsigned);
-	unsigned *microcode;
-	size_t pos = 0;
-	int fd;
-	int wrote, length;
-
-	if ((microcode = calloc(1, microcode_size * sizeof(unsigned))) == NULL) {
-		fwts_log_error(fw, "Cannot allocate memory.");
-		return FWTS_ERROR;
-	}
-
-	if ((fp = fopen(filename, "r")) == NULL) {
-		fwts_log_error(fw, "Cannot open source '%s'.", filename);
-		free(microcode);
-		return FWTS_ERROR;
-	}
-
-	while (fgets(line_buffer, BUFFER_SIZE, fp) != NULL) {
-		/*
-		 * Expand microcode buffer if needed
-		 */
-		if (microcode_size < pos + 4) {
-                    microcode_size *= 2;
-                    microcode = realloc(microcode,
-                                       microcode_size * sizeof(unsigned int));
-			if (microcode == NULL) {
-				fwts_log_error(fw, "Cannot allocate memory.");
-				fclose(fp);
-				return FWTS_ERROR;
-			}
-		}
-		/*
-		 * Data lines will are of the form "%x, %x, %x, %x", therefore
-		 * lines start with a 0
-		 */
-		if (*line_buffer == '0') {
-			int scanned;
-			scanned = sscanf(line_buffer, "%x, %x, %x, %x",
-					microcode + pos,
-					microcode + pos + 1,
-					microcode + pos + 2,
-					microcode + pos + 3);
-			if (scanned != 4) {
-				fwts_log_error(fw, "%s: invalid file format", filename);
-				fclose(fp);
-				free(microcode);
-				return FWTS_ERROR;
-			}
-			pos += 4;
-		}
-	}
-	fclose(fp);
-
-	length = pos * sizeof(unsigned int);
-
-	if ((fd = open(device, O_WRONLY)) == -1) {
-		fwts_log_error(fw, "Cannot open %s for writing errno=%d (%s)\n",
-				device, errno, strerror(errno));
-		free(microcode);
-		return FWTS_ERROR;
-	}
-
-	if ((wrote = write(fd, microcode, length)) < 0) {
-		fwts_log_error(fw, "Error writing microcode.");
-		close(fd);
-		free(microcode);
-		return FWTS_ERROR;
-	}
-
-	close(fd);
-	free(microcode);
-
-	return FWTS_OK;
-}