All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v2 0/5] efi_convert_device_path_to_text
@ 2017-07-13 20:51 Heinrich Schuchardt
  2017-07-13 20:51 ` [U-Boot] [PATCH v2 1/5] efi_loader: do not duplicate constants for device path Heinrich Schuchardt
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Heinrich Schuchardt @ 2017-07-13 20:51 UTC (permalink / raw)
  To: u-boot

The patch series provides the DevicePathToText function for MAC
addresses and some error corrections.

The 1st patch removes duplicate constants that we already have 
defined in efi_api.h.

The 2nd patch implements the DevicePathToText function for MAC
addresses.

The 3rd patch adds a missing parameter check.

The 4th patch supplies additional debug output.

The 5th patch moves the declarations to the beginning of the
function efi_convert_device_path_to_text.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

---
v2
	Switch patch 3 and 4.
	Put debug statement after parameter check.
	Add patch 5.
---

Heinrich Schuchardt (5):
  efi_loader: do not duplicate constants for device path
  efi_loader: DevicePathToText for MAC address
  efi_loader: parameter check efi_convert_device_path_to_text
  efi_loader: debug info in efi_convert_device_path_to_text
  efi_loader: DevicePathToText put declarations first

 lib/efi_loader/efi_device_path_to_text.c | 44 +++++++++++++++++++++++++++-----
 1 file changed, 38 insertions(+), 6 deletions(-)

-- 
2.11.0

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [U-Boot] [PATCH v2 1/5] efi_loader: do not duplicate constants for device path
  2017-07-13 20:51 [U-Boot] [PATCH v2 0/5] efi_convert_device_path_to_text Heinrich Schuchardt
@ 2017-07-13 20:51 ` Heinrich Schuchardt
  2017-07-13 20:51 ` [U-Boot] [PATCH v2 2/5] efi_loader: DevicePathToText for MAC address Heinrich Schuchardt
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Heinrich Schuchardt @ 2017-07-13 20:51 UTC (permalink / raw)
  To: u-boot

We should not duplicate existing constants used by the
device path protocol.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
v2
	no change
---
 lib/efi_loader/efi_device_path_to_text.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/lib/efi_loader/efi_device_path_to_text.c b/lib/efi_loader/efi_device_path_to_text.c
index a7a513047f..3a92247f30 100644
--- a/lib/efi_loader/efi_device_path_to_text.c
+++ b/lib/efi_loader/efi_device_path_to_text.c
@@ -9,9 +9,6 @@
 #include <common.h>
 #include <efi_loader.h>
 
-#define MEDIA_DEVICE_PATH 4
-#define FILE_PATH_MEDIA_DEVICE_PATH 4
-
 const efi_guid_t efi_guid_device_path_to_text_protocol =
 		EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID;
 
@@ -38,9 +35,9 @@ uint16_t *efi_convert_device_path_to_text(
 	uint16_t *buffer = NULL;
 
 	switch (device_path->type) {
-	case MEDIA_DEVICE_PATH:
+	case DEVICE_PATH_TYPE_MEDIA_DEVICE:
 		switch (device_path->sub_type) {
-		case FILE_PATH_MEDIA_DEVICE_PATH:
+		case DEVICE_PATH_SUB_TYPE_FILE_PATH:
 			buffer_size = device_path->length - 4;
 			r = efi_allocate_pool(EFI_ALLOCATE_ANY_PAGES,
 					      buffer_size, (void **) &buffer);
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [U-Boot] [PATCH v2 2/5] efi_loader: DevicePathToText for MAC address
  2017-07-13 20:51 [U-Boot] [PATCH v2 0/5] efi_convert_device_path_to_text Heinrich Schuchardt
  2017-07-13 20:51 ` [U-Boot] [PATCH v2 1/5] efi_loader: do not duplicate constants for device path Heinrich Schuchardt
@ 2017-07-13 20:51 ` Heinrich Schuchardt
  2017-07-13 20:51 ` [U-Boot] [PATCH v2 3/5] efi_loader: parameter check efi_convert_device_path_to_text Heinrich Schuchardt
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Heinrich Schuchardt @ 2017-07-13 20:51 UTC (permalink / raw)
  To: u-boot

Implement DevicePathToText MAC address device path.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
v2
	no change
---
 lib/efi_loader/efi_device_path_to_text.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/lib/efi_loader/efi_device_path_to_text.c b/lib/efi_loader/efi_device_path_to_text.c
index 3a92247f30..c6ac5e52f3 100644
--- a/lib/efi_loader/efi_device_path_to_text.c
+++ b/lib/efi_loader/efi_device_path_to_text.c
@@ -9,6 +9,8 @@
 #include <common.h>
 #include <efi_loader.h>
 
+#define MAC_OUTPUT_LEN 22
+
 const efi_guid_t efi_guid_device_path_to_text_protocol =
 		EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID;
 
@@ -35,6 +37,31 @@ uint16_t *efi_convert_device_path_to_text(
 	uint16_t *buffer = NULL;
 
 	switch (device_path->type) {
+	case DEVICE_PATH_TYPE_MESSAGING_DEVICE:
+		switch (device_path->sub_type) {
+		case DEVICE_PATH_SUB_TYPE_MSG_MAC_ADDR: {
+			struct efi_device_path_mac_addr *dp =
+				(struct efi_device_path_mac_addr *)device_path;
+			int i;
+
+			if (dp->if_type != 0 && dp->if_type != 1)
+				break;
+			r = efi_allocate_pool(EFI_ALLOCATE_ANY_PAGES,
+					      2 * MAC_OUTPUT_LEN,
+					      (void **)&buffer);
+			if (r != EFI_SUCCESS)
+				break;
+			sprintf((char *)buffer,
+				"MAC(%02x%02x%02x%02x%02x%02x,0x%1x)",
+				dp->mac.addr[0], dp->mac.addr[1],
+				dp->mac.addr[2], dp->mac.addr[3],
+				dp->mac.addr[4], dp->mac.addr[5],
+				dp->if_type);
+			for (i = MAC_OUTPUT_LEN - 1; i >= 0; --i)
+				buffer[i] = ((uint8_t *)buffer)[i];
+			break;
+			}
+		}
 	case DEVICE_PATH_TYPE_MEDIA_DEVICE:
 		switch (device_path->sub_type) {
 		case DEVICE_PATH_SUB_TYPE_FILE_PATH:
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [U-Boot] [PATCH v2 3/5] efi_loader: parameter check efi_convert_device_path_to_text
  2017-07-13 20:51 [U-Boot] [PATCH v2 0/5] efi_convert_device_path_to_text Heinrich Schuchardt
  2017-07-13 20:51 ` [U-Boot] [PATCH v2 1/5] efi_loader: do not duplicate constants for device path Heinrich Schuchardt
  2017-07-13 20:51 ` [U-Boot] [PATCH v2 2/5] efi_loader: DevicePathToText for MAC address Heinrich Schuchardt
@ 2017-07-13 20:51 ` Heinrich Schuchardt
  2017-07-13 20:51 ` [U-Boot] [PATCH v2 4/5] efi_loader: debug info in efi_convert_device_path_to_text Heinrich Schuchardt
  2017-07-13 20:51 ` [U-Boot] [PATCH v2 5/5] efi_loader: DevicePathToText put declarations first Heinrich Schuchardt
  4 siblings, 0 replies; 6+ messages in thread
From: Heinrich Schuchardt @ 2017-07-13 20:51 UTC (permalink / raw)
  To: u-boot

Do not dereference NULL.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
v2
	no change
---
 lib/efi_loader/efi_device_path_to_text.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/lib/efi_loader/efi_device_path_to_text.c b/lib/efi_loader/efi_device_path_to_text.c
index c6ac5e52f3..a5ea63300b 100644
--- a/lib/efi_loader/efi_device_path_to_text.c
+++ b/lib/efi_loader/efi_device_path_to_text.c
@@ -36,6 +36,11 @@ uint16_t *efi_convert_device_path_to_text(
 	efi_status_t r;
 	uint16_t *buffer = NULL;
 
+	if (!device_path) {
+		EFI_EXIT(EFI_INVALID_PARAMETER);
+		return NULL;
+	}
+
 	switch (device_path->type) {
 	case DEVICE_PATH_TYPE_MESSAGING_DEVICE:
 		switch (device_path->sub_type) {
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [U-Boot] [PATCH v2 4/5] efi_loader: debug info in efi_convert_device_path_to_text
  2017-07-13 20:51 [U-Boot] [PATCH v2 0/5] efi_convert_device_path_to_text Heinrich Schuchardt
                   ` (2 preceding siblings ...)
  2017-07-13 20:51 ` [U-Boot] [PATCH v2 3/5] efi_loader: parameter check efi_convert_device_path_to_text Heinrich Schuchardt
@ 2017-07-13 20:51 ` Heinrich Schuchardt
  2017-07-13 20:51 ` [U-Boot] [PATCH v2 5/5] efi_loader: DevicePathToText put declarations first Heinrich Schuchardt
  4 siblings, 0 replies; 6+ messages in thread
From: Heinrich Schuchardt @ 2017-07-13 20:51 UTC (permalink / raw)
  To: u-boot

The debug information provided by efi_convert_device_path_to_text
is insufficient. The type and the subtype are needed to find
out why the function did not support a conversion.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
v2
	debug statement has to be after parameter check
	to avoid NULL dereference
---
 lib/efi_loader/efi_device_path_to_text.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/efi_loader/efi_device_path_to_text.c b/lib/efi_loader/efi_device_path_to_text.c
index a5ea63300b..56de328286 100644
--- a/lib/efi_loader/efi_device_path_to_text.c
+++ b/lib/efi_loader/efi_device_path_to_text.c
@@ -41,6 +41,9 @@ uint16_t *efi_convert_device_path_to_text(
 		return NULL;
 	}
 
+	debug("EFI: type %d, subtype %d\n",
+	      device_path->type, device_path->sub_type);
+
 	switch (device_path->type) {
 	case DEVICE_PATH_TYPE_MESSAGING_DEVICE:
 		switch (device_path->sub_type) {
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [U-Boot] [PATCH v2 5/5] efi_loader: DevicePathToText put declarations first
  2017-07-13 20:51 [U-Boot] [PATCH v2 0/5] efi_convert_device_path_to_text Heinrich Schuchardt
                   ` (3 preceding siblings ...)
  2017-07-13 20:51 ` [U-Boot] [PATCH v2 4/5] efi_loader: debug info in efi_convert_device_path_to_text Heinrich Schuchardt
@ 2017-07-13 20:51 ` Heinrich Schuchardt
  4 siblings, 0 replies; 6+ messages in thread
From: Heinrich Schuchardt @ 2017-07-13 20:51 UTC (permalink / raw)
  To: u-boot

Variables should be declared before the first executable statement.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
v2
	new patch
---
 lib/efi_loader/efi_device_path_to_text.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/efi_loader/efi_device_path_to_text.c b/lib/efi_loader/efi_device_path_to_text.c
index 56de328286..621bc4f528 100644
--- a/lib/efi_loader/efi_device_path_to_text.c
+++ b/lib/efi_loader/efi_device_path_to_text.c
@@ -30,12 +30,12 @@ uint16_t *efi_convert_device_path_to_text(
 		bool display_only,
 		bool allow_shortcuts)
 {
-	EFI_ENTRY("%p, %d, %d", device_path, display_only, allow_shortcuts);
-
 	unsigned long buffer_size;
 	efi_status_t r;
 	uint16_t *buffer = NULL;
 
+	EFI_ENTRY("%p, %d, %d", device_path, display_only, allow_shortcuts);
+
 	if (!device_path) {
 		EFI_EXIT(EFI_INVALID_PARAMETER);
 		return NULL;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-07-13 20:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-13 20:51 [U-Boot] [PATCH v2 0/5] efi_convert_device_path_to_text Heinrich Schuchardt
2017-07-13 20:51 ` [U-Boot] [PATCH v2 1/5] efi_loader: do not duplicate constants for device path Heinrich Schuchardt
2017-07-13 20:51 ` [U-Boot] [PATCH v2 2/5] efi_loader: DevicePathToText for MAC address Heinrich Schuchardt
2017-07-13 20:51 ` [U-Boot] [PATCH v2 3/5] efi_loader: parameter check efi_convert_device_path_to_text Heinrich Schuchardt
2017-07-13 20:51 ` [U-Boot] [PATCH v2 4/5] efi_loader: debug info in efi_convert_device_path_to_text Heinrich Schuchardt
2017-07-13 20:51 ` [U-Boot] [PATCH v2 5/5] efi_loader: DevicePathToText put declarations first Heinrich Schuchardt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.