[U-Boot] rsa_verify calls fdt_next_node with a node offset from different device tree blob
Hi Simon, I notice one thing that I am curious about. At v2016.11, in lib/rsa/rsa-verify.c:rsa_verify function: * The sig_node offset is computed from fdt_blob (at line 180): sig_node = fdt_subnode_offset(blob, 0, FIT_SIG_NODENAME); * At the end of the rsa_verify function, sig_node is applied to info->fit to compute next offset (at line 210): noffset = fdt_next_node(info->fit, sig_node, ); blob (which is an alias of info->fdt_blob) and info->fit are two different device tree blobs. And we probably should not call fdt_next_node with offset from a different blob? (I'm not so sure about fdt_next_node.) Regards, Che-Liang ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v6 1/5] tpm: add AUTH1 cmds for LoadKey2 and GetPubKey
Acked-by: Che-Liang Chiou clch...@chromium.org On Wed, Jun 12, 2013 at 1:08 AM, dirk.eib...@gdsys.cc wrote: From: Reinhard Pfau p...@gdsys.de Extend the tpm library with support for single authorized (AUTH1) commands as specified in the TCG Main Specification 1.2. (The internally used helper functions are implemented in a way that they could also be used for double authorized commands if someone needs it.) Provide enums with the return codes from the TCG Main specification. For now only a single OIAP session is supported. OIAP authorized version of the commands TPM_LoadKey2 and TPM_GetPubKey are provided. Both features are available using the 'tpm' command, too. Authorized commands are enabled with CONFIG_TPM_AUTH_SESSIONS. (Note that this also requires CONFIG_SHA1 to be enabled.) Signed-off-by: Reinhard Pfau reinhard.p...@gdsys.cc Signed-off-by: Dirk Eibach dirk.eib...@gdsys.cc --- Changes in v6: None Changes in v5: None Changes in v4: None Changes in v3: - fix email addresses Changes in v2: - replace some numeric constants with named constants - style fixes (as shown by checkpatch.pl) in common/cmd_tpm.c and lib/tpm.c README | 14 +++ common/cmd_tpm.c | 100 include/tpm.h| 174 +++ lib/tpm.c| 351 ++- 4 files changed, 638 insertions(+), 1 deletion(-) diff --git a/README b/README index 33bda8c..3d1fa08 100644 --- a/README +++ b/README @@ -1234,6 +1234,20 @@ The following options need to be configured: to. Contemporary x86 systems usually map it at 0xfed4. + CONFIG_CMD_TPM + Add tpm monitor functions. + Requires CONFIG_TPM. If CONFIG_TPM_AUTH_SESSIONS is set, also + provides monitor access to authorized functions. + + CONFIG_TPM + Define this to enable the TPM support library which provides + functional interfaces to some TPM commands. + Requires support for a TPM device. + + CONFIG_TPM_AUTH_SESSIONS + Define this to enable authorized functions in the TPM library. + Requires CONFIG_TPM and CONFIG_SHA1. + - USB Support: At the moment only the UHCI host controller is supported (PIP405, MIP405, MPC5200); define diff --git a/common/cmd_tpm.c b/common/cmd_tpm.c index 46fae18..c34000a 100644 --- a/common/cmd_tpm.c +++ b/common/cmd_tpm.c @@ -27,6 +27,13 @@ #include asm/unaligned.h #include linux/string.h +/* Useful constants */ +enum { + DIGEST_LENGTH = 20, + /* max lengths, valid for RSA keys = 2048 bits */ + TPM_PUBKEY_MAX_LENGTH = 288, +}; + /** * Print a byte string in hexdecimal format, 16-bytes per line. * @@ -546,6 +553,72 @@ static int do_tpm_nv_write(cmd_tbl_t *cmdtp, int flag, return convert_return_code(err); } +#ifdef CONFIG_TPM_AUTH_SESSIONS + +static int do_tpm_oiap(cmd_tbl_t *cmdtp, int flag, + int argc, char * const argv[]) +{ + uint32_t auth_handle, err; + + err = tpm_oiap(auth_handle); + + return convert_return_code(err); +} + +static int do_tpm_load_key2_oiap(cmd_tbl_t *cmdtp, int flag, + int argc, char * const argv[]) +{ + uint32_t parent_handle, key_len, key_handle, err; + uint8_t usage_auth[DIGEST_LENGTH]; + void *key; + + if (argc 5) + return CMD_RET_USAGE; + + parent_handle = simple_strtoul(argv[1], NULL, 0); + key = (void *)simple_strtoul(argv[2], NULL, 0); + key_len = simple_strtoul(argv[3], NULL, 0); + if (strlen(argv[4]) != 2 * DIGEST_LENGTH) + return CMD_RET_FAILURE; + parse_byte_string(argv[4], usage_auth, NULL); + + err = tpm_load_key2_oiap(parent_handle, key, key_len, usage_auth, + key_handle); + if (!err) + printf(Key handle is 0x%x\n, key_handle); + + return convert_return_code(err); +} + +static int do_tpm_get_pub_key_oiap(cmd_tbl_t *cmdtp, int flag, + int argc, char * const argv[]) +{ + uint32_t key_handle, err; + uint8_t usage_auth[DIGEST_LENGTH]; + uint8_t pub_key_buffer[TPM_PUBKEY_MAX_LENGTH]; + size_t pub_key_len = sizeof(pub_key_buffer); + + if (argc 3) + return CMD_RET_USAGE; + + key_handle = simple_strtoul(argv[1], NULL, 0); + if (strlen(argv[2]) != 2 * DIGEST_LENGTH) + return CMD_RET_FAILURE; + parse_byte_string(argv[2], usage_auth, NULL); + + err = tpm_get_pub_key_oiap(key_handle, usage_auth, + pub_key_buffer, pub_key_len); + if (!err) { + printf(dump of received pub key structure:\n
Re: [U-Boot] [PATCH 1/6] tpm: add AUTH1 cmds for LoadKey2 and GetPubKey
Acked-by: Che-Liang Chiou clch...@chromium.org On Mon, Apr 22, 2013 at 4:06 AM, Dirk Eibach eib...@gdsys.de wrote: From: Reinhard Pfau p...@gdsys.de Extend the tpm library with support for single authorized (AUTH1) commands as specified in the TCG Main Specification 1.2. (The internally used helper functions are implemented in a way that they could also be used for double authorized commands if someone needs it.) Provide enums with the return codes from the TCG Main specification. For now only a single OIAP session is supported. OIAP authorized version of the commands TPM_LoadKey2 and TPM_GetPubKey are provided. Both features are available using the 'tpm' command, too. Authorized commands are enabled with CONFIG_TPM_AUTH_SESSIONS. (Note that this also requires CONFIG_SHA1 to be enabled.) Signed-off-by: Reinhard Pfau p...@gdsys.de Signed-off-by: Dirk Eibach eib...@gdsys.de --- README | 14 +++ common/cmd_tpm.c | 93 +++ include/tpm.h| 174 +++ lib/tpm.c| 348 +- 4 files changed, 628 insertions(+), 1 deletion(-) diff --git a/README b/README index 0bc0af5..58b2ee5 100644 --- a/README +++ b/README @@ -1210,6 +1210,20 @@ The following options need to be configured: to. Contemporary x86 systems usually map it at 0xfed4. + CONFIG_CMD_TPM + Add tpm monitor functions. + Requires CONFIG_TPM. If CONFIG_TPM_AUTH_SESSIONS is set, also + provides monitor access to authorized functions. + + CONFIG_TPM + Define this to enable the TPM support library which provides + functional interfaces to some TPM commands. + Requires support for a TPM device. + + CONFIG_TPM_AUTH_SESSIONS + Define this to enable authorized functions in the TPM library. + Requires CONFIG_TPM and CONFIG_SHA1. + - USB Support: At the moment only the UHCI host controller is supported (PIP405, MIP405, MPC5200); define diff --git a/common/cmd_tpm.c b/common/cmd_tpm.c index 46fae18..c8767a4 100644 --- a/common/cmd_tpm.c +++ b/common/cmd_tpm.c @@ -546,6 +546,72 @@ static int do_tpm_nv_write(cmd_tbl_t *cmdtp, int flag, return convert_return_code(err); } +#ifdef CONFIG_TPM_AUTH_SESSIONS + +static int do_tpm_oiap(cmd_tbl_t *cmdtp, int flag, + int argc, char * const argv[]) +{ + uint32_t auth_handle, err; + + err = tpm_oiap(auth_handle); + + return convert_return_code(err); +} + +static int do_tpm_load_key2_oiap(cmd_tbl_t *cmdtp, int flag, + int argc, char * const argv[]) +{ + uint32_t parent_handle, key_len, key_handle, err; + uint8_t usage_auth[20]; + void *key; + + if (argc 5) + return CMD_RET_USAGE; + + parent_handle = simple_strtoul(argv[1], NULL, 0); + key = (void *)simple_strtoul(argv[2], NULL, 0); + key_len = simple_strtoul(argv[3], NULL, 0); + if (strlen(argv[4]) != 40) + return CMD_RET_FAILURE; + parse_byte_string(argv[4], usage_auth, NULL); + + err = tpm_load_key2_oiap(parent_handle, key, key_len, usage_auth, + key_handle); + if (!err) + printf(Key handle is 0x%x\n, key_handle); + + return convert_return_code(err); +} + +static int do_tpm_get_pub_key_oiap(cmd_tbl_t *cmdtp, int flag, + int argc, char * const argv[]) +{ + uint32_t key_handle, err; + uint8_t usage_auth[20]; + uint8_t pub_key_buffer[288]; + size_t pub_key_len = sizeof(pub_key_buffer); + + if (argc 3) + return CMD_RET_USAGE; + + key_handle = simple_strtoul(argv[1], NULL, 0); + if (strlen(argv[2]) != 40) + return CMD_RET_FAILURE; + parse_byte_string(argv[2], usage_auth, NULL); + + err = tpm_get_pub_key_oiap(key_handle, usage_auth, + pub_key_buffer, pub_key_len); + if (!err) { + printf(dump of received pub key structure:\n); + print_byte_string(pub_key_buffer, pub_key_len); + } + return convert_return_code(err); +} + +TPM_COMMAND_NO_ARG(tpm_end_oiap) + +#endif /* CONFIG_TPM_AUTH_SESSIONS */ + #define MAKE_TPM_CMD_ENTRY(cmd) \ U_BOOT_CMD_MKENT(cmd, 0, 1, do_tpm_ ## cmd, , ) @@ -590,6 +656,16 @@ static cmd_tbl_t tpm_commands[] = { do_tpm_nv_read, , ), U_BOOT_CMD_MKENT(nv_write, 0, 1, do_tpm_nv_write, , ), +#ifdef CONFIG_TPM_AUTH_SESSIONS + U_BOOT_CMD_MKENT(oiap, 0, 1, + do_tpm_oiap, , ), + U_BOOT_CMD_MKENT(end_oiap, 0, 1, + do_tpm_end_oiap
[U-Boot] [PATCH v3] tpm: Add TPM command library
TPM command library implements a subset of TPM commands defined in TCG Main Specification 1.2 that are useful for implementing secure boot. More TPM commands could be added out of necessity. You may exercise these commands through the 'tpm' command. However, the raw TPM commands are too primitive for writing secure boot in command interpreter scripts; so the 'tpm' command also provides helper functions to make scripting easier. For example, to define a counter in TPM non-volatile storage and initialize it to zero: $ tpm init $ tpm startup TPM_ST_CLEAR $ tpm nv_define d 0x1001 0x1 $ tpm nv_write d 0x1001 0 And then increment the counter by one: $ tpm nv_read d 0x1001 i $ setexpr.l i $i + 1 $ tpm nv_write d 0x1001 $i Signed-off-by: Che-Liang Chiou clch...@chromium.org --- Changes in v3: - Add check of TPM response code Changes in v2: - Merge tpm_util into tpm common/cmd_tpm.c | 709 +++ include/{tpm.h = tis.h} | 8 +- include/tpm.h| 197 ++--- lib/Makefile | 1 + lib/tpm.c| 581 ++ 5 files changed, 1351 insertions(+), 145 deletions(-) copy include/{tpm.h = tis.h} (95%) create mode 100644 lib/tpm.c diff --git a/common/cmd_tpm.c b/common/cmd_tpm.c index 0970a6f..46fae18 100644 --- a/common/cmd_tpm.c +++ b/common/cmd_tpm.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 The Chromium OS Authors. + * Copyright (c) 2013 The Chromium OS Authors. * * See file CREDITS for list of people who contributed to this * project. @@ -22,163 +22,652 @@ #include common.h #include command.h +#include malloc.h #include tpm.h +#include asm/unaligned.h +#include linux/string.h -#define MAX_TRANSACTION_SIZE 30 +/** + * Print a byte string in hexdecimal format, 16-bytes per line. + * + * @param data byte string to be printed + * @param countnumber of bytes to be printed + */ +static void print_byte_string(uint8_t *data, size_t count) +{ + int i, print_newline = 0; -/* - * tpm_write() expects a variable number of parameters: the internal address - * followed by data to write, byte by byte. + for (i = 0; i count; i++) { + printf( %02x, data[i]); + print_newline = (i % 16 == 15); + if (print_newline) + putc('\n'); + } + /* Avoid duplicated newline at the end */ + if (!print_newline) + putc('\n'); +} + +/** + * Convert a text string of hexdecimal values into a byte string. * - * Returns 0 on success or -1 on errors (wrong arguments or TPM failure). + * @param bytestext string of hexdecimal values with no space + * between them + * @param data output buffer for byte string. The caller has to make + * sure it is large enough for storing the output. If + * NULL is passed, a large enough buffer will be allocated, + * and the caller must free it. + * @param count_ptroutput variable for the length of byte string + * @return pointer to output buffer */ -static int tpm_process(int argc, char * const argv[], cmd_tbl_t *cmdtp) -{ - u8 tpm_buffer[MAX_TRANSACTION_SIZE]; - u32 write_size, read_size; - char *p; - int rv = -1; - - for (write_size = 0; write_size argc; write_size++) { - u32 datum = simple_strtoul(argv[write_size], p, 0); - if (*p || (datum 0xff)) { - printf(\n%s: bad data value\n\n, argv[write_size]); - cmd_usage(cmdtp); - return rv; - } - tpm_buffer[write_size] = (u8)datum; +static void *parse_byte_string(char *bytes, uint8_t *data, size_t *count_ptr) +{ + char byte[3]; + size_t count, length; + int i; + + length = strlen(bytes); + count = length / 2; + + if (!data) + data = malloc(count); + if (!data) + return NULL; + + byte[2] = '\0'; + for (i = 0; i length; i += 2) { + byte[0] = bytes[i]; + byte[1] = bytes[i + 1]; + data[i / 2] = (uint8_t)simple_strtoul(byte, NULL, 16); } - read_size = sizeof(tpm_buffer); - if (!tis_sendrecv(tpm_buffer, write_size, tpm_buffer, read_size)) { - int i; - puts(Got TPM response:\n); - for (i = 0; i read_size; i++) - printf( %2.2x, tpm_buffer[i]); - puts(\n); - rv = 0; - } else { - puts(tpm command failed\n); + if (count_ptr) + *count_ptr = count; + + return data; +} + +/** + * Convert TPM command return code to U-Boot command error codes. + * + * @param return_code TPM command return code + * @return value of enum command_ret_t + */ +static int convert_return_code
Re: [U-Boot] [PATCH v2] tpm: Add TPM command library
Hi Reinhard, Replied below. On Thu, Feb 28, 2013 at 6:50 AM, Pfau, Reinhard p...@gdsys.de wrote: Hi, While digging through the code, some question arises. So let me drop some notes about the patch: ( I apologize for some weird word wraps in the quoted text, but I have to use a well known UMA which seems to be too stupid to keep lines of text without additional word wraps...) -Original Message- From: u-boot-boun...@lists.denx.de [mailto:u-boot-boun...@lists.denx.de] On Behalf Of Che-Liang Chiou Sent: Friday, February 15, 2013 12:01 AM To: u-boot@lists.denx.de Subject: [U-Boot] [PATCH v2] tpm: Add TPM command library TPM command library implements a subset of TPM commands defined in TCG Main Specification 1.2 that are useful for implementing secure boot. More TPM commands could be added out of necessity. You may exercise these commands through the 'tpm' command. However, the raw TPM commands are too primitive for writing secure boot in command interpreter scripts; so the 'tpm' command also provides helper functions to make scripting easier. For example, to define a counter in TPM non-volatile storage and initialize it to zero: $ tpm init $ tpm startup TPM_ST_CLEAR $ tpm nv_define d 0x1001 0x1 $ tpm nv_write d 0x1001 0 And then increment the counter by one: $ tpm nv_read d 0x1001 i $ setexpr.l i $i + 1 $ tpm nv_write d 0x1001 $i Signed-off-by: Che-Liang Chiou clch...@chromium.org --- common/cmd_tpm.c | 709 +++ include/{tpm.h = tis.h} | 8 +- include/tpm.h| 197 ++--- lib/Makefile | 1 + lib/tpm.c| 569 + 5 files changed, 1339 insertions(+), 145 deletions(-) copy include/{tpm.h = tis.h} (95%) create mode 100644 lib/tpm.c [snip] diff --git a/lib/tpm.c b/lib/tpm.c new file mode 100644 index 000..7d13951 --- /dev/null +++ b/lib/tpm.c [snip] +/** + * Send a TPM command and return response's return code. + * + * @param commandbyte string of TPM command + * @return return code of the TPM response + */ +static uint32_t tpm_send_command(const void *command) +{ + uint8_t response[COMMAND_BUFFER_SIZE]; + size_t response_length = sizeof(response); + uint32_t err; + + err = tis_sendrecv(command, tpm_command_size(command), + response, response_length); + if (err) + return err; + + return tpm_return_code(response); +} Using the result of tis_sendrecv would be OK with the I2C-TPM patch posted on this ML about a year ago. The implementation of tis_sendrecv in generic_lpc_tpm.c returns the value (1) on error instead of -1 (as documented in the header file). Since 1 is a well defined TPM result code (TPM_AUTHFAIL) this could result in some problems. (But I think, this is a bug in the current generic_lpc_tpm driver...) [snip] I agree it is a bug in the current generic_lpc_tpm driver. And here tpm_send_command() should return TPM_LIB_ERROR (which is a distinguishable value from well-defined TPM result codes) in case of tis_sendrecv() returning non-zero value. + +uint32_t tpm_nv_read_value(uint32_t index, void *data, uint32_t count) +{ + const uint8_t command[22] = { + 0x0, 0xc1, 0x0, 0x0, 0x0, 0x16, 0x0, 0x0, 0x0, 0xcf, + }; + const size_t index_offset = 10; + const size_t length_offset = 18; + const size_t data_size_offset = 10; + const size_t data_offset = 14; + uint8_t buf[COMMAND_BUFFER_SIZE], response[COMMAND_BUFFER_SIZE]; + uint32_t response_length = sizeof(response), data_size; + uint32_t err; + + if (pack_byte_string(buf, sizeof(buf), sdd, + 0, command, sizeof(command), + index_offset, index, + length_offset, count)) + return TPM_LIB_ERROR; + err = tis_sendrecv(buf, tpm_command_size(buf), + response, response_length); + if (err) + return err; At this point we should add something like: err = tpm_return_code(response); if (err) return err; to return the real result code from the TPM in case of an error. Else the following code will map all TPM errors to TPM_LIB_ERROR (since unpack_byte_string will fail). Same in the other funcs which interpret the result of the command (tpm_extend, tpm_pcr_read, rtpm_read_pubek, tpm_get_capability). Done. + if (unpack_byte_string(response, response_length, d, + data_size_offset, data_size)) + return TPM_LIB_ERROR; + if (data_size count) + return TPM_LIB_ERROR; + if (unpack_byte_string(response, response_length, s, + data_offset, data, data_size)) + return TPM_LIB_ERROR; + + return 0; +} + +uint32_t
[U-Boot] [PATCH v2] tpm: Add TPM command library
TPM command library implements a subset of TPM commands defined in TCG Main Specification 1.2 that are useful for implementing secure boot. More TPM commands could be added out of necessity. You may exercise these commands through the 'tpm' command. However, the raw TPM commands are too primitive for writing secure boot in command interpreter scripts; so the 'tpm' command also provides helper functions to make scripting easier. For example, to define a counter in TPM non-volatile storage and initialize it to zero: $ tpm init $ tpm startup TPM_ST_CLEAR $ tpm nv_define d 0x1001 0x1 $ tpm nv_write d 0x1001 0 And then increment the counter by one: $ tpm nv_read d 0x1001 i $ setexpr.l i $i + 1 $ tpm nv_write d 0x1001 $i Signed-off-by: Che-Liang Chiou clch...@chromium.org --- common/cmd_tpm.c | 709 +++ include/{tpm.h = tis.h} | 8 +- include/tpm.h| 197 ++--- lib/Makefile | 1 + lib/tpm.c| 569 + 5 files changed, 1339 insertions(+), 145 deletions(-) copy include/{tpm.h = tis.h} (95%) create mode 100644 lib/tpm.c diff --git a/common/cmd_tpm.c b/common/cmd_tpm.c index 0970a6f..46fae18 100644 --- a/common/cmd_tpm.c +++ b/common/cmd_tpm.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 The Chromium OS Authors. + * Copyright (c) 2013 The Chromium OS Authors. * * See file CREDITS for list of people who contributed to this * project. @@ -22,163 +22,652 @@ #include common.h #include command.h +#include malloc.h #include tpm.h +#include asm/unaligned.h +#include linux/string.h -#define MAX_TRANSACTION_SIZE 30 +/** + * Print a byte string in hexdecimal format, 16-bytes per line. + * + * @param data byte string to be printed + * @param countnumber of bytes to be printed + */ +static void print_byte_string(uint8_t *data, size_t count) +{ + int i, print_newline = 0; -/* - * tpm_write() expects a variable number of parameters: the internal address - * followed by data to write, byte by byte. + for (i = 0; i count; i++) { + printf( %02x, data[i]); + print_newline = (i % 16 == 15); + if (print_newline) + putc('\n'); + } + /* Avoid duplicated newline at the end */ + if (!print_newline) + putc('\n'); +} + +/** + * Convert a text string of hexdecimal values into a byte string. * - * Returns 0 on success or -1 on errors (wrong arguments or TPM failure). + * @param bytestext string of hexdecimal values with no space + * between them + * @param data output buffer for byte string. The caller has to make + * sure it is large enough for storing the output. If + * NULL is passed, a large enough buffer will be allocated, + * and the caller must free it. + * @param count_ptroutput variable for the length of byte string + * @return pointer to output buffer */ -static int tpm_process(int argc, char * const argv[], cmd_tbl_t *cmdtp) -{ - u8 tpm_buffer[MAX_TRANSACTION_SIZE]; - u32 write_size, read_size; - char *p; - int rv = -1; - - for (write_size = 0; write_size argc; write_size++) { - u32 datum = simple_strtoul(argv[write_size], p, 0); - if (*p || (datum 0xff)) { - printf(\n%s: bad data value\n\n, argv[write_size]); - cmd_usage(cmdtp); - return rv; - } - tpm_buffer[write_size] = (u8)datum; +static void *parse_byte_string(char *bytes, uint8_t *data, size_t *count_ptr) +{ + char byte[3]; + size_t count, length; + int i; + + length = strlen(bytes); + count = length / 2; + + if (!data) + data = malloc(count); + if (!data) + return NULL; + + byte[2] = '\0'; + for (i = 0; i length; i += 2) { + byte[0] = bytes[i]; + byte[1] = bytes[i + 1]; + data[i / 2] = (uint8_t)simple_strtoul(byte, NULL, 16); } - read_size = sizeof(tpm_buffer); - if (!tis_sendrecv(tpm_buffer, write_size, tpm_buffer, read_size)) { - int i; - puts(Got TPM response:\n); - for (i = 0; i read_size; i++) - printf( %2.2x, tpm_buffer[i]); - puts(\n); - rv = 0; - } else { - puts(tpm command failed\n); + if (count_ptr) + *count_ptr = count; + + return data; +} + +/** + * Convert TPM command return code to U-Boot command error codes. + * + * @param return_code TPM command return code + * @return value of enum command_ret_t + */ +static int convert_return_code(uint32_t return_code) +{ + if (return_code) + return CMD_RET_FAILURE
[U-Boot] [PATCH] tpm: Add TPM command library and utility commands
TPM command library implements a subset of TPM commands defined in TCG Main Specification 1.2 that are useful for implementing secure boot. More TPM commands could be added out of necessity. You may exercise these commands through the 'tpm' command. However, the 'tpm' command is too primitive for writing secure boot in command interpreter scripts; so the utility commands 'tpmutil' is provided to make this task easier. For example, to define a counter in TPM non-volatile storage and initialize it to zero: $ tpm init $ tpm startup TPM_ST_CLEAR $ tpmutil nv_define d 0x1001 0x1 $ tpmutil nv_write d 0x1001 0 And then increment the counter by one: $ tpmutil nv_read d 0x1001 i $ setexpr.l i $i + 1 $ tpmutil nv_write d 0x1001 $i Signed-off-by: Che-Liang Chiou clch...@chromium.org --- common/cmd_tpm.c | 732 +++--- include/{tpm.h = tis.h} |8 +- include/tpm.h| 197 +++-- lib/Makefile |1 + lib/tpm.c| 569 +++ 5 files changed, 1362 insertions(+), 145 deletions(-) copy include/{tpm.h = tis.h} (95%) create mode 100644 lib/tpm.c diff --git a/common/cmd_tpm.c b/common/cmd_tpm.c index 0970a6f..cdf74e6 100644 --- a/common/cmd_tpm.c +++ b/common/cmd_tpm.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 The Chromium OS Authors. + * Copyright (c) 2013 The Chromium OS Authors. * * See file CREDITS for list of people who contributed to this * project. @@ -22,163 +22,675 @@ #include common.h #include command.h +#include malloc.h #include tpm.h +#include asm/unaligned.h +#include linux/string.h -#define MAX_TRANSACTION_SIZE 30 +/** + * Print a byte string in hexdecimal format, 16-bytes per line. + * + * @param data byte string to be printed + * @param countnumber of bytes to be printed + */ +static void print_byte_string(uint8_t *data, size_t count) +{ + int i, print_newline = 0; -/* - * tpm_write() expects a variable number of parameters: the internal address - * followed by data to write, byte by byte. + for (i = 0; i count; i++) { + printf( %02x, data[i]); + print_newline = (i % 16 == 15); + if (print_newline) + putc('\n'); + } + /* Avoid duplicated newline at the end */ + if (!print_newline) + putc('\n'); +} + +/** + * Convert a text string of hexdecimal values into a byte string. * - * Returns 0 on success or -1 on errors (wrong arguments or TPM failure). + * @param bytestext string of hexdecimal values with no space + * between them + * @param data output buffer for byte string. The caller has to make + * sure it is large enough for storing the output. If + * NULL is passed, a large enough buffer will be allocated, + * and the caller must free it. + * @param count_ptroutput variable for the length of byte string + * @return pointer to output buffer */ -static int tpm_process(int argc, char * const argv[], cmd_tbl_t *cmdtp) -{ - u8 tpm_buffer[MAX_TRANSACTION_SIZE]; - u32 write_size, read_size; - char *p; - int rv = -1; - - for (write_size = 0; write_size argc; write_size++) { - u32 datum = simple_strtoul(argv[write_size], p, 0); - if (*p || (datum 0xff)) { - printf(\n%s: bad data value\n\n, argv[write_size]); - cmd_usage(cmdtp); - return rv; - } - tpm_buffer[write_size] = (u8)datum; +static void *parse_byte_string(char *bytes, uint8_t *data, size_t *count_ptr) +{ + char byte[3]; + size_t count, length; + int i; + + length = strlen(bytes); + count = length / 2; + + if (!data) + data = malloc(count); + if (!data) + return NULL; + + byte[2] = '\0'; + for (i = 0; i length; i += 2) { + byte[0] = bytes[i]; + byte[1] = bytes[i + 1]; + data[i / 2] = (uint8_t)simple_strtoul(byte, NULL, 16); } - read_size = sizeof(tpm_buffer); - if (!tis_sendrecv(tpm_buffer, write_size, tpm_buffer, read_size)) { - int i; - puts(Got TPM response:\n); - for (i = 0; i read_size; i++) - printf( %2.2x, tpm_buffer[i]); - puts(\n); - rv = 0; - } else { - puts(tpm command failed\n); + if (count_ptr) + *count_ptr = count; + + return data; +} + +/** + * Convert TPM command return code to U-Boot command error codes. + * + * @param return_code TPM command return code + * @return value of enum command_ret_t + */ +static int convert_return_code(uint32_t return_code) +{ + if (return_code) + return CMD_RET_FAILURE
Re: [U-Boot] [PATCH 09/10] api/api_display: use the getters for console size info
Acked-by: Che-Liang Chiou clch...@chromium.org On Sat, Jan 12, 2013 at 2:07 PM, Jeroen Hofstee jer...@myspectrum.nl wrote: cc: Che-Liang Chiou clch...@chromium.org Signed-off-by: Jeroen Hofstee jer...@myspectrum.nl --- api/api_display.c |4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/api_display.c b/api/api_display.c index 6439170..c167db7 100644 --- a/api/api_display.c +++ b/api/api_display.c @@ -45,8 +45,8 @@ int display_get_info(int type, struct display_info *di) case DISPLAY_TYPE_LCD: di-pixel_width = panel_info.vl_col; di-pixel_height = panel_info.vl_row; - di-screen_rows = CONSOLE_ROWS; - di-screen_cols = CONSOLE_COLS; + di-screen_rows = lcd_get_screen_rows(); + di-screen_cols = lcd_get_screen_columns(); break; #endif } -- 1.7.9.5 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] Googlers please reply: commiters in U-Boot
I work for Google and my patches signed by clch...@chromium.org come from me while I work for Google. On Sat, Jan 12, 2013 at 9:20 AM, Simon Glass s...@chromium.org wrote: Hi, You are being copied because you have written U-Boot code which is now in mainline. The chromium.org domain does not automatically attribute U-Boot commits by company. Each author needs to be manually added to the list and this can only be done if you confirm your employer. So, if you are on the CC list and work at Google, please reply-all with a quick email stating this (without top posting). Regards, Simon ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] cmd_time: merge run_command_and_time_it with cmd_process
Acked-by: Che-Liang Chiou clch...@chromium.org On Mon, Dec 3, 2012 at 8:23 AM, Richard Genoud richard.gen...@gmail.com wrote: 2012/12/3 Stefan Roese s...@denx.de: @@ -543,7 +543,9 @@ enum command_ret_t cmd_process(int flag, int argc, char * const argv[], /* If OK so far, then do the command */ if (!rc) { + if (ticks) *ticks = get_timer(0); Newline please: if (ticks) *ticks = get_timer(0); rc = cmd_call(cmdtp, flag, argc, argv); + if (ticks) *ticks = get_timer(*ticks); Here as well. Thanks, Stefan Ok, I'll resend it with new lines (I thought it was a little bit more readable without new lines). Thanks ! Richard. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCHv2] cmd_time: merge run_command_and_time_it with cmd_process
Acked-By: Che-Liang Chiou clch...@chromium.org On Mon, Dec 3, 2012 at 8:28 AM, Richard Genoud richard.gen...@gmail.com wrote: As far as every arch has a get_timer function, run_command_and_time_it code can now disappear. Signed-off-by: Richard Genoud richard.gen...@gmail.com --- common/cmd_time.c | 33 ++--- common/command.c |6 +- common/hush.c |2 +- common/main.c |2 +- include/command.h |4 +++- 5 files changed, 12 insertions(+), 35 deletions(-) diff --git a/common/cmd_time.c b/common/cmd_time.c index 6dbdbbf..9808cd6 100644 --- a/common/cmd_time.c +++ b/common/cmd_time.c @@ -22,36 +22,6 @@ #include common.h #include command.h -/* - * TODO(clchiou): This function actually minics the bottom-half of the - * run_command() function. Since this function has ARM-dependent timer - * codes, we cannot merge it with the run_command() for now. - */ -static int run_command_and_time_it(int flag, int argc, char * const argv[], - ulong *cycles) -{ - cmd_tbl_t *cmdtp = find_cmd(argv[0]); - int retval = 0; - - if (!cmdtp) { - printf(%s: command not found\n, argv[0]); - return 1; - } - if (argc cmdtp-maxargs) - return CMD_RET_USAGE; - - /* -* TODO(clchiou): get_timer_masked() is only defined in certain ARM -* boards. We could use the new timer API that Graeme is proposing -* so that this piece of code would be arch-independent. -*/ - *cycles = get_timer_masked(); - retval = cmdtp-cmd(cmdtp, flag, argc, argv); - *cycles = get_timer_masked() - *cycles; - - return retval; -} - static void report_time(ulong cycles) { ulong minutes, seconds, milliseconds; @@ -75,11 +45,12 @@ static int do_time(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { ulong cycles = 0; int retval = 0; + int repeatable; if (argc == 1) return CMD_RET_USAGE; - retval = run_command_and_time_it(0, argc - 1, argv + 1, cycles); + retval = cmd_process(0, argc - 1, argv + 1, repeatable, cycles); report_time(cycles); return retval; diff --git a/common/command.c b/common/command.c index 50c8429..305a236 100644 --- a/common/command.c +++ b/common/command.c @@ -513,7 +513,7 @@ static int cmd_call(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } enum command_ret_t cmd_process(int flag, int argc, char * const argv[], - int *repeatable) + int *repeatable, ulong *ticks) { enum command_ret_t rc = CMD_RET_SUCCESS; cmd_tbl_t *cmdtp; @@ -543,7 +543,11 @@ enum command_ret_t cmd_process(int flag, int argc, char * const argv[], /* If OK so far, then do the command */ if (!rc) { + if (ticks) + *ticks = get_timer(0); rc = cmd_call(cmdtp, flag, argc, argv); + if (ticks) + *ticks = get_timer(*ticks); *repeatable = cmdtp-repeatable; } if (rc == CMD_RET_USAGE) diff --git a/common/hush.c b/common/hush.c index eb6c879..cc81c9c 100644 --- a/common/hush.c +++ b/common/hush.c @@ -1665,7 +1665,7 @@ static int run_pipe_real(struct pipe *pi) } /* Process the command */ return cmd_process(flag, child-argc, child-argv, - flag_repeat); + flag_repeat, NULL); #endif } #ifndef __U_BOOT__ diff --git a/common/main.c b/common/main.c index 5362781..7bdba3e 100644 --- a/common/main.c +++ b/common/main.c @@ -1442,7 +1442,7 @@ static int builtin_run_command(const char *cmd, int flag) continue; } - if (cmd_process(flag, argc, argv, repeatable)) + if (cmd_process(flag, argc, argv, repeatable, NULL)) rc = -1; /* Did the user stop this? */ diff --git a/include/command.h b/include/command.h index 10bc260..1344d71 100644 --- a/include/command.h +++ b/include/command.h @@ -139,10 +139,12 @@ enum command_ret_t { * @param repeatable This function sets this to 0 if the command is not * repeatable. If the command is repeatable, the value * is left unchanged. + * @param ticksIf ticks is not null, this function set it to the + * number of ticks the command took to complete. * @return 0 if the command succeeded, 1 if it failed */ int cmd_process(int flag, int argc, char * const argv[], - int *repeatable); + int *repeatable, ulong *ticks); #endif /* __ASSEMBLY__
Re: [U-Boot] [PATCH 6/7] lcd: Implement RLE8 bitmap decoding
Acked-by: Che-Liang Chiou clch...@chromium.org On Fri, Sep 28, 2012 at 6:11 PM, Simon Glass s...@chromium.org wrote: From: Tom Wai-Hong Tam waih...@google.com Add support for drawing compressed RLE8 bitmaps. Reference: http://www.digicamsoft.com/bmp/bmp.html Signed-off-by: Che-Liang Chiou clch...@chromium.org Signed-off-by: Tom Wai-Hong Tam waih...@chromium.org Signed-off-by: Simon Glass s...@chromium.org --- README |5 ++ common/lcd.c | 144 ++ 2 files changed, 149 insertions(+), 0 deletions(-) diff --git a/README b/README index 5793b0a..40899d9 100644 --- a/README +++ b/README @@ -1440,6 +1440,11 @@ The following options need to be configured: Normally display is black on white background; define CONFIG_SYS_WHITE_ON_BLACK to get it inverted. + CONFIG_LCD_BMP_RLE8 + + Support drawing of RLE8-compressed bitmaps on the LCD. + + - Splash Screen Support: CONFIG_SPLASH_SCREEN If this option is set, the environment is checked for diff --git a/common/lcd.c b/common/lcd.c index 004a6be..68df6d0 100644 --- a/common/lcd.c +++ b/common/lcd.c @@ -642,6 +642,136 @@ static void splash_align_axis(int *axis, unsigned long panel_size, } #endif + +#ifdef CONFIG_LCD_BMP_RLE8 + +#define BMP_RLE8_ESCAPE0 +#define BMP_RLE8_EOL 0 +#define BMP_RLE8_EOBMP 1 +#define BMP_RLE8_DELTA 2 + +static void draw_unencoded_bitmap(ushort **fbp, uchar *bmap, ushort *cmap, + int cnt) +{ + while (cnt 0) { + *(*fbp)++ = cmap[*bmap++]; + cnt--; + } +} + +static void draw_encoded_bitmap(ushort **fbp, ushort c, int cnt) +{ + ushort *fb = *fbp; + int cnt_8copy = cnt 3; + cnt -= cnt_8copy 3; + while (cnt_8copy 0) { + *fb++ = c; + *fb++ = c; + *fb++ = c; + *fb++ = c; + *fb++ = c; + *fb++ = c; + *fb++ = c; + *fb++ = c; + cnt_8copy--; + } + while (cnt 0) { + *fb++ = c; + cnt--; + } + (*fbp) = fb; +} + +/* Do not call this function directly, must be called from + * lcd_display_bitmap. + */ +static void lcd_display_rle8_bitmap(bmp_image_t *bmp, ushort *cmap, uchar *fb, + int x_off, int y_off) +{ + uchar *bmap; + ulong width, height; + ulong cnt, runlen; + int x, y; + int decode = 1; + + width = le32_to_cpu(bmp-header.width); + height = le32_to_cpu(bmp-header.height); + bmap = (uchar *)bmp + le32_to_cpu(bmp-header.data_offset); + + x = 0; + y = height - 1; + + while (decode) { + if (bmap[0] == BMP_RLE8_ESCAPE) { + switch (bmap[1]) { + case BMP_RLE8_EOL: + /* end of line */ + bmap += 2; + x = 0; + y--; + /* 16bpix, 2-byte per pixel, width should *2 */ + fb -= (width * 2 + lcd_line_length); + break; + case BMP_RLE8_EOBMP: + /* end of bitmap */ + decode = 0; + break; + case BMP_RLE8_DELTA: + /* delta run */ + x += bmap[2]; + y -= bmap[3]; + /* 16bpix, 2-byte per pixel, x should *2 */ + fb = (uchar *) (lcd_base + (y + y_off - 1) + * lcd_line_length + (x + x_off) * 2); + bmap += 4; + break; + default: + /* unencoded run */ + runlen = bmap[1]; + bmap += 2; + if (y height) { + if (x width) { + if (x + runlen width) + cnt = width - x; + else + cnt = runlen; + draw_unencoded_bitmap( + (ushort **)fb, + bmap, cmap, cnt); + } + x
Re: [U-Boot] [PATCH v2 0/2] Add i2c TPM driver
On Mon, Mar 19, 2012 at 5:00 AM, Wolfgang Denk w...@denx.de wrote: Dear Che-Liang Chiou, In message 20111219112511.1eddc135a...@gemini.denx.de I wrote: In message 1324288224-5075-1-git-send-email-clch...@chromium.org you wrote: This patchset adds an i2c bus based TPM driver. Are there any users of this driver? I see we are adding TPM code, but so far this is all dead code as there are no users for it. I think I never received any reply. I thought that we've discussed that I should wait until tegra2 i2c driver is merged into mainline, and then resubmit this patch series (cf. [PATCH v1 1/2] tpm: Rename generic_lpc_tpm to tpm_tis_lpc). Are there any plans of adding code that actually uses these drivers? If this is only dead code which is not used by any board, we may as well omit resp. remove it. Please comment. Thanks. Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de In the realm of scientific observation, luck is granted only to those who are prepared. - Louis Pasteur ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v1 1/2] tpm: Rename generic_lpc_tpm to tpm_tis_lpc
On Mon, Dec 19, 2011 at 7:38 PM, Wolfgang Denk w...@denx.de wrote: Dear Che-liang Chiou, In message canjuy2jq3nf2mjpxrs-8jgksiv1zg2sfcnqdmrksaqpifup...@mail.gmail.com you wrote: Should we not rather remove all this dead code again? Until today there are no users for this code in mainline, and no patches have been submitted that intend to use it. Chrome/Chromium OS uses TPM for its secure boot. So I would say it is quite a lot of usage on the critical path of booting. I do not see any such code in mainline. So for mainline, this is just dead code, i. e. it adds maintenance efforts without benefit for any mainline users. The code that uses TPM did not send to the mainline because the mainline did not have a TPM driver until very recently. Well, the patche shave been submitted long time ago, so I would have expected to see such code soon after. But so far, nothign happened. Now you are trying to add even more code, with still no users in sight. The board that I test the TPM driver is Seaboard (a tegra2-based board). The config settings enabling TPM are literally pasted as follows. However, I can't submit the confis settings (so that Seaboard would be the first mainline user of the TPM driver) as part of this patchset because the tegra i2c driver is not yet in the mainline and so enabling TPM will break mainline's Seaboard build. I am 100% certain that tegra i2c driver will be submitted. It just take a few time to polish before sending out for review. And after that I will submit a patch enabling TPM in Seaboard. Would this be sufficient for you? diff --git a/include/configs/seaboard.h b/include/configs/seaboard.h index 7d29144..7c96826 100644 --- a/include/configs/seaboard.h +++ b/include/configs/seaboard.h @@ -42,6 +42,13 @@ #define CONFIG_BOARD_EARLY_INIT_F +/* TPM */ +#define CONFIG_TPM +#define CONFIG_TPM_TIS_I2C +#define CONFIG_TPM_TIS_I2C_BUS_NUMBER 2 +#define CONFIG_TPM_TIS_I2C_SLAVE_ADDRESS 0x20 +#define CONFIG_TPM_TIS_I2C_BURST_LIMITATION3 + /* SD/MMC */ #define CONFIG_MMC #define CONFIG_GENERIC_MMC And, I am still figuring out how to submit the TPM user code. I guess it would be better to organize it in a command-line toolkit so that it can be interleaved in between other commands. What do you think? I don't understand what you mean. Didn't you just write there was code ready to be submitted? So that code is not ready and not intended for mainline? I thought you might be interested in Chrome/Chromium OS secure boot, which is implemented as a single monolithic command, and I guess it would be more interested to you if I break it into smaller sub-commands. Anyway, never mind. Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de Never ascribe to malice that which can adequately be explained by stupidity. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v1 1/2] tpm: Rename generic_lpc_tpm to tpm_tis_lpc
On Tue, Dec 20, 2011 at 7:43 PM, Wolfgang Denk w...@denx.de wrote: Dear Che-liang Chiou, In message canjuy2jzerkmuske4zes3u6oo0ms3wfjfa+awu0od2mvbf_...@mail.gmail.com you wrote: The board that I test the TPM driver is Seaboard (a tegra2-based board). The config settings enabling TPM are literally pasted as follows. However, I can't submit the confis settings (so that Seaboard would be the first mainline user of the TPM driver) as part of this patchset because the tegra i2c driver is not yet in the mainline and so enabling TPM will break mainline's Seaboard build. I am 100% certain that tegra i2c driver will be submitted. It just take a few time to polish before sending out for review. And after that I will submit a patch enabling TPM in Seaboard. Would this be sufficient for you? I suggest you submit this all on a single patch series together, then. Okay. Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de Parkinson's Law: Work expands to fill the time alloted it. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 0/2] Add i2c TPM driver
This patchset adds an i2c bus based TPM driver. Changes in v1: - Update s-o-b Peter Huewe's email address - Squash patch #3 into patch #2 Changes in v2: - Style improvements Che-Liang Chiou (2): tpm: Rename generic_lpc_tpm to tpm_tis_lpc tpm: Add i2c TPM driver Makefile |2 +- README | 18 +- drivers/tpm/Makefile |5 +- drivers/tpm/tpm.c| 466 + drivers/tpm/tpm_private.h| 134 + drivers/tpm/tpm_tis_i2c.c| 587 ++ drivers/tpm/{generic_lpc_tpm.c = tpm_tis_lpc.c} |0 7 files changed, 1209 insertions(+), 3 deletions(-) create mode 100644 drivers/tpm/tpm.c create mode 100644 drivers/tpm/tpm_private.h create mode 100644 drivers/tpm/tpm_tis_i2c.c rename drivers/tpm/{generic_lpc_tpm.c = tpm_tis_lpc.c} (100%) -- 1.7.3.1 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 1/2] tpm: Rename generic_lpc_tpm to tpm_tis_lpc
The new name is more aligned with Linux kernel's naming of TPM driver. Signed-off-by: Peter Huewe peter.hu...@infineon.com Signed-off-by: Che-Liang Chiou clch...@chromium.org Acked-by: Mike Frysinger vap...@gentoo.org --- Changes in v1: - Update s-o-b Peter Huewe's email address Makefile |2 +- README |5 - drivers/tpm/Makefile |2 +- drivers/tpm/{generic_lpc_tpm.c = tpm_tis_lpc.c} |0 4 files changed, 6 insertions(+), 3 deletions(-) rename drivers/tpm/{generic_lpc_tpm.c = tpm_tis_lpc.c} (100%) diff --git a/Makefile b/Makefile index de65a17..abeafd7 100644 --- a/Makefile +++ b/Makefile @@ -277,7 +277,7 @@ LIBS += arch/powerpc/cpu/mpc8xxx/lib8xxx.o endif LIBS += drivers/rtc/librtc.o LIBS += drivers/serial/libserial.o -ifeq ($(CONFIG_GENERIC_LPC_TPM),y) +ifeq ($(CONFIG_TPM),y) LIBS += drivers/tpm/libtpm.o endif LIBS += drivers/twserial/libtws.o diff --git a/README b/README index e9d1891..434384c 100644 --- a/README +++ b/README @@ -1073,7 +1073,10 @@ The following options need to be configured: If this option is set, the driver enables cache flush. - TPM Support: - CONFIG_GENERIC_LPC_TPM + CONFIG_TPM + Support TPM devices. + + CONFIG_TPM_TIS_LPC Support for generic parallel port TPM devices. Only one device per system is supported at this time. diff --git a/drivers/tpm/Makefile b/drivers/tpm/Makefile index be11c8b..47d09de 100644 --- a/drivers/tpm/Makefile +++ b/drivers/tpm/Makefile @@ -23,7 +23,7 @@ include $(TOPDIR)/config.mk LIB := $(obj)libtpm.o -COBJS-$(CONFIG_GENERIC_LPC_TPM) = generic_lpc_tpm.o +COBJS-$(CONFIG_TPM_TIS_LPC) = tpm_tis_lpc.o COBJS := $(COBJS-y) SRCS := $(COBJS:.o=.c) diff --git a/drivers/tpm/generic_lpc_tpm.c b/drivers/tpm/tpm_tis_lpc.c similarity index 100% rename from drivers/tpm/generic_lpc_tpm.c rename to drivers/tpm/tpm_tis_lpc.c -- 1.7.3.1 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 2/2] tpm: Add i2c TPM driver
Peter Huewe implemented the original driver; this patch only reorganizes the code structure of the driver, and does not make logical changes. tpm.c implements the interface defined in tpm.h based on underlying LPC or i2C TPM driver. tpm.c and the underlying driver communicate throught tpm_private.h. This patch is tested on a tegra2-based machine, where the i2c driver is not upstreamed yet. Note: Merging the LPC driver with tpm.c is left to future patches. Signed-off-by: Peter Huewe peter.hu...@infineon.com Signed-off-by: Che-Liang Chiou clch...@chromium.org --- Changes in v1: - Squash patch #3 into patch #2 Changes in v2: - Style improvements README| 13 + drivers/tpm/Makefile |5 +- drivers/tpm/tpm.c | 466 +++ drivers/tpm/tpm_private.h | 134 ++ drivers/tpm/tpm_tis_i2c.c | 587 + 5 files changed, 1204 insertions(+), 1 deletions(-) create mode 100644 drivers/tpm/tpm.c create mode 100644 drivers/tpm/tpm_private.h create mode 100644 drivers/tpm/tpm_tis_i2c.c diff --git a/README b/README index 434384c..badb834 100644 --- a/README +++ b/README @@ -1076,6 +1076,19 @@ The following options need to be configured: CONFIG_TPM Support TPM devices. + CONFIG_TPM_TIS_I2C + Support for i2c bus TPM devices. Only one device + per system is supported at this time. + + CONFIG_TPM_TIS_I2C_BUS_NUMBER + Define the the i2c bus number for the TPM device + + CONFIG_TPM_TIS_I2C_SLAVE_ADDRESS + Define the TPM's address on the i2c bus + + CONFIG_TPM_TIS_I2C_BURST_LIMITATION + Define the burst count bytes upper limit + CONFIG_TPM_TIS_LPC Support for generic parallel port TPM devices. Only one device per system is supported at this time. diff --git a/drivers/tpm/Makefile b/drivers/tpm/Makefile index 47d09de..cb29bab 100644 --- a/drivers/tpm/Makefile +++ b/drivers/tpm/Makefile @@ -23,7 +23,10 @@ include $(TOPDIR)/config.mk LIB := $(obj)libtpm.o -COBJS-$(CONFIG_TPM_TIS_LPC) = tpm_tis_lpc.o +# TODO(clchiou): Merge tpm_tis_lpc.c with tpm.c +COBJS-$(CONFIG_TPM_TIS_I2C) += tpm.o +COBJS-$(CONFIG_TPM_TIS_I2C) += tpm_tis_i2c.o +COBJS-$(CONFIG_TPM_TIS_LPC) += tpm_tis_lpc.o COBJS := $(COBJS-y) SRCS := $(COBJS:.o=.c) diff --git a/drivers/tpm/tpm.c b/drivers/tpm/tpm.c new file mode 100644 index 000..785ed01 --- /dev/null +++ b/drivers/tpm/tpm.c @@ -0,0 +1,466 @@ +/* + * Copyright (C) 2011 Infineon Technologies + * + * Authors: + * Peter Huewe huewe.exter...@infineon.com + * + * Description: + * Device driver for TCG/TCPA TPM (trusted platform module). + * Specifications at www.trustedcomputinggroup.org + * + * It is based on the Linux kernel driver tpm.c from Leendert van + * Dorn, Dave Safford, Reiner Sailer, and Kyleen Hall. + * + * Version: 2.1.1 + * + * See file CREDITS for list of people who contributed to this + * project. + * + * 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, version 2 of the + * License. + * + * 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., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include common.h +#include compiler.h +#include i2c.h +#include tpm.h +#include asm-generic/errno.h +#include linux/types.h +#include linux/unaligned/be_byteshift.h + +#include tpm_private.h + +/* Global structure for tpm chip data */ +static struct tpm_chip tpm_chip; + +enum tpm_duration { + TPM_SHORT = 0, + TPM_MEDIUM = 1, + TPM_LONG = 2, + TPM_UNDEFINED, +}; + +/* Extended error numbers from linux (see errno.h) */ +#defineECANCELED 125 /* Operation Canceled */ + +/* Timer frequency. Corresponds to msec timer resolution*/ +#define HZ 1000 + +#define TPM_MAX_ORDINAL243 +#define TPM_MAX_PROTECTED_ORDINAL 12 +#define TPM_PROTECTED_ORDINAL_MASK 0xFF + +#define TPM_CMD_COUNT_BYTE 2 +#define TPM_CMD_ORDINAL_BYTE 6 + +/* + * Array with one entry per ordinal defining the maximum amount + * of time the chip could take to return the result. The ordinal + * designation of short, medium or long is defined in a table in + * TCG Specification TPM Main Part 2 TPM Structures Section 17. The + * values of the SHORT, MEDIUM, and LONG durations are retrieved + * from
Re: [U-Boot] [PATCH v1 2/2] tpm: Add i2c TPM driver
On Sat, Dec 17, 2011 at 1:21 AM, Mike Frysinger vap...@gentoo.org wrote: On Wednesday 14 December 2011 03:48:24 Che-Liang Chiou wrote: --- /dev/null +++ b/drivers/tpm/tpm.c +int tis_sendrecv(const uint8_t *sendbuf, size_t send_size, uint8_t *recvbuf, + size_t *recv_len) +{ + error(%s: invalid send_size %zx\n, __func__, send_size); using __func__ with error() makes no sense as error() already includes that Done. --- /dev/null +++ b/drivers/tpm/tpm_private.h this should probably include linux/types.h and linux/compiler.h since it uses __be32 and __packed Done. --- /dev/null +++ b/drivers/tpm/tpm_tis_i2c.c + if (burstcnt (len-1-count)) + burstcnt = len-1-count; add some spaces around those - Done. -mike ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v1 2/2] tpm: Add i2c TPM driver
On Sun, Dec 18, 2011 at 4:33 AM, Wolfgang Denk w...@denx.de wrote: Dear Che-Liang Chiou, In message 1323852504-19954-3-git-send-email-clch...@chromium.org you wrote: Peter Huewe implemented the original driver; this patch only reorganizes the code structure of the driver, and does not make logical changes. tpm.c implements the interface defined in tpm.h based on underlying LPC or i2C TPM driver. tpm.c and the underlying driver communicate throught tpm_private.h. This patch is tested on a tegra2-based machine, where the i2c driver is not upstreamed yet. Note: Merging the LPC driver with tpm.c is left to future patches. Signed-off-by: Peter Huewe peter.hu...@infineon.com Signed-off-by: Che-Liang Chiou clch...@chromium.org ... + if (ordinal TPM_MAX_ORDINAL) + duration_idx = tpm_ordinal_duration[ordinal]; + else if ((ordinal TPM_PROTECTED_ORDINAL_MASK) + TPM_MAX_PROTECTED_ORDINAL) + duration_idx = tpm_protected_ordinal_duration[ordinal + TPM_PROTECTED_ORDINAL_MASK]; Braces needed around multiline statement. Done. + if (duration_idx != TPM_UNDEFINED) + duration = chip-vendor.duration[duration_idx]; + if (duration = 0) Readability could be improved by inserting a blank line before this one. Done. ... + debug(%s: waiting for status...\n, __func__); + u8 status = tpm_chip.vendor.status(tpm_chip); + if ((status tpm_chip.vendor.req_complete_mask) == Please always seaprate declarations and code by one blank line. Please fix globally. Done. I found as many cases as possible, and inserted a few more blank lines. I hope that would increase readability. Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de Yes, it's a technical challenge, and you have to kind of admire people who go to the lengths of actually implementing it, but at the same time you wonder about their IQ... -- Linus Torvalds in 5phda5$ml6$1...@palladium.transmeta.com ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v1 1/2] tpm: Rename generic_lpc_tpm to tpm_tis_lpc
On Sun, Dec 18, 2011 at 4:35 AM, Wolfgang Denk w...@denx.de wrote: Dear Che-Liang Chiou, In message 1323852504-19954-2-git-send-email-clch...@chromium.org you wrote: The new name is more aligned with Linux kernel's naming of TPM driver. Signed-off-by: Peter Huewe peter.hu...@infineon.com Signed-off-by: Che-Liang Chiou clch...@chromium.org Acked-by: Mike Frysinger vap...@gentoo.org --- Changes in v1: - Update s-o-b Peter Huewe's email address Makefile | 2 +- README | 5 - drivers/tpm/Makefile | 2 +- drivers/tpm/{generic_lpc_tpm.c = tpm_tis_lpc.c} | 0 4 files changed, 6 insertions(+), 3 deletions(-) rename drivers/tpm/{generic_lpc_tpm.c = tpm_tis_lpc.c} (100%) Does such a change actually make sense? Should we not rather remove all this dead code again? Until today there are no users for this code in mainline, and no patches have been submitted that intend to use it. Chrome/Chromium OS uses TPM for its secure boot. So I would say it is quite a lot of usage on the critical path of booting. The code that uses TPM did not send to the mainline because the mainline did not have a TPM driver until very recently. And, I am still figuring out how to submit the TPM user code. I guess it would be better to organize it in a command-line toolkit so that it can be interleaved in between other commands. What do you think? I think we should scrap this in the next release. Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de Drawing on my fine command of language, I said nothing. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v1 0/2] Add i2c TPM driver
This patchset adds an i2c bus based TPM driver. Changes in v1: - Update s-o-b Peter Huewe's email address - Squash patch #3 into patch #2 Che-Liang Chiou (2): tpm: Rename generic_lpc_tpm to tpm_tis_lpc tpm: Add i2c TPM driver Makefile |2 +- README | 18 +- drivers/tpm/Makefile |5 +- drivers/tpm/tpm.c| 457 + drivers/tpm/tpm_private.h| 131 + drivers/tpm/tpm_tis_i2c.c| 584 ++ drivers/tpm/{generic_lpc_tpm.c = tpm_tis_lpc.c} |0 7 files changed, 1194 insertions(+), 3 deletions(-) create mode 100644 drivers/tpm/tpm.c create mode 100644 drivers/tpm/tpm_private.h create mode 100644 drivers/tpm/tpm_tis_i2c.c rename drivers/tpm/{generic_lpc_tpm.c = tpm_tis_lpc.c} (100%) -- 1.7.3.1 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v1 1/2] tpm: Rename generic_lpc_tpm to tpm_tis_lpc
The new name is more aligned with Linux kernel's naming of TPM driver. Signed-off-by: Peter Huewe peter.hu...@infineon.com Signed-off-by: Che-Liang Chiou clch...@chromium.org Acked-by: Mike Frysinger vap...@gentoo.org --- Changes in v1: - Update s-o-b Peter Huewe's email address Makefile |2 +- README |5 - drivers/tpm/Makefile |2 +- drivers/tpm/{generic_lpc_tpm.c = tpm_tis_lpc.c} |0 4 files changed, 6 insertions(+), 3 deletions(-) rename drivers/tpm/{generic_lpc_tpm.c = tpm_tis_lpc.c} (100%) diff --git a/Makefile b/Makefile index de65a17..abeafd7 100644 --- a/Makefile +++ b/Makefile @@ -277,7 +277,7 @@ LIBS += arch/powerpc/cpu/mpc8xxx/lib8xxx.o endif LIBS += drivers/rtc/librtc.o LIBS += drivers/serial/libserial.o -ifeq ($(CONFIG_GENERIC_LPC_TPM),y) +ifeq ($(CONFIG_TPM),y) LIBS += drivers/tpm/libtpm.o endif LIBS += drivers/twserial/libtws.o diff --git a/README b/README index e9d1891..434384c 100644 --- a/README +++ b/README @@ -1073,7 +1073,10 @@ The following options need to be configured: If this option is set, the driver enables cache flush. - TPM Support: - CONFIG_GENERIC_LPC_TPM + CONFIG_TPM + Support TPM devices. + + CONFIG_TPM_TIS_LPC Support for generic parallel port TPM devices. Only one device per system is supported at this time. diff --git a/drivers/tpm/Makefile b/drivers/tpm/Makefile index be11c8b..47d09de 100644 --- a/drivers/tpm/Makefile +++ b/drivers/tpm/Makefile @@ -23,7 +23,7 @@ include $(TOPDIR)/config.mk LIB := $(obj)libtpm.o -COBJS-$(CONFIG_GENERIC_LPC_TPM) = generic_lpc_tpm.o +COBJS-$(CONFIG_TPM_TIS_LPC) = tpm_tis_lpc.o COBJS := $(COBJS-y) SRCS := $(COBJS:.o=.c) diff --git a/drivers/tpm/generic_lpc_tpm.c b/drivers/tpm/tpm_tis_lpc.c similarity index 100% rename from drivers/tpm/generic_lpc_tpm.c rename to drivers/tpm/tpm_tis_lpc.c -- 1.7.3.1 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v1 2/2] tpm: Add i2c TPM driver
Peter Huewe implemented the original driver; this patch only reorganizes the code structure of the driver, and does not make logical changes. tpm.c implements the interface defined in tpm.h based on underlying LPC or i2C TPM driver. tpm.c and the underlying driver communicate throught tpm_private.h. This patch is tested on a tegra2-based machine, where the i2c driver is not upstreamed yet. Note: Merging the LPC driver with tpm.c is left to future patches. Signed-off-by: Peter Huewe peter.hu...@infineon.com Signed-off-by: Che-Liang Chiou clch...@chromium.org --- Changes in v1: - Squash patch #3 into patch #2 README| 13 + drivers/tpm/Makefile |5 +- drivers/tpm/tpm.c | 457 +++ drivers/tpm/tpm_private.h | 131 ++ drivers/tpm/tpm_tis_i2c.c | 584 + 5 files changed, 1189 insertions(+), 1 deletions(-) create mode 100644 drivers/tpm/tpm.c create mode 100644 drivers/tpm/tpm_private.h create mode 100644 drivers/tpm/tpm_tis_i2c.c diff --git a/README b/README index 434384c..badb834 100644 --- a/README +++ b/README @@ -1076,6 +1076,19 @@ The following options need to be configured: CONFIG_TPM Support TPM devices. + CONFIG_TPM_TIS_I2C + Support for i2c bus TPM devices. Only one device + per system is supported at this time. + + CONFIG_TPM_TIS_I2C_BUS_NUMBER + Define the the i2c bus number for the TPM device + + CONFIG_TPM_TIS_I2C_SLAVE_ADDRESS + Define the TPM's address on the i2c bus + + CONFIG_TPM_TIS_I2C_BURST_LIMITATION + Define the burst count bytes upper limit + CONFIG_TPM_TIS_LPC Support for generic parallel port TPM devices. Only one device per system is supported at this time. diff --git a/drivers/tpm/Makefile b/drivers/tpm/Makefile index 47d09de..cb29bab 100644 --- a/drivers/tpm/Makefile +++ b/drivers/tpm/Makefile @@ -23,7 +23,10 @@ include $(TOPDIR)/config.mk LIB := $(obj)libtpm.o -COBJS-$(CONFIG_TPM_TIS_LPC) = tpm_tis_lpc.o +# TODO(clchiou): Merge tpm_tis_lpc.c with tpm.c +COBJS-$(CONFIG_TPM_TIS_I2C) += tpm.o +COBJS-$(CONFIG_TPM_TIS_I2C) += tpm_tis_i2c.o +COBJS-$(CONFIG_TPM_TIS_LPC) += tpm_tis_lpc.o COBJS := $(COBJS-y) SRCS := $(COBJS:.o=.c) diff --git a/drivers/tpm/tpm.c b/drivers/tpm/tpm.c new file mode 100644 index 000..457deaa --- /dev/null +++ b/drivers/tpm/tpm.c @@ -0,0 +1,457 @@ +/* + * Copyright (C) 2011 Infineon Technologies + * + * Authors: + * Peter Huewe huewe.exter...@infineon.com + * + * Description: + * Device driver for TCG/TCPA TPM (trusted platform module). + * Specifications at www.trustedcomputinggroup.org + * + * It is based on the Linux kernel driver tpm.c from Leendert van + * Dorn, Dave Safford, Reiner Sailer, and Kyleen Hall. + * + * Version: 2.1.1 + * + * See file CREDITS for list of people who contributed to this + * project. + * + * 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, version 2 of the + * License. + * + * 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., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include common.h +#include compiler.h +#include i2c.h +#include tpm.h +#include asm-generic/errno.h +#include linux/types.h +#include linux/unaligned/be_byteshift.h + +#include tpm_private.h + +/* Global structure for tpm chip data */ +static struct tpm_chip tpm_chip; + +enum tpm_duration { + TPM_SHORT = 0, + TPM_MEDIUM = 1, + TPM_LONG = 2, + TPM_UNDEFINED, +}; + +/* Extended error numbers from linux (see errno.h) */ +#defineECANCELED 125 /* Operation Canceled */ + +/* Timer frequency. Corresponds to msec timer resolution*/ +#define HZ 1000 + +#define TPM_MAX_ORDINAL243 +#define TPM_MAX_PROTECTED_ORDINAL 12 +#define TPM_PROTECTED_ORDINAL_MASK 0xFF + +#define TPM_CMD_COUNT_BYTE 2 +#define TPM_CMD_ORDINAL_BYTE 6 + +/* + * Array with one entry per ordinal defining the maximum amount + * of time the chip could take to return the result. The ordinal + * designation of short, medium or long is defined in a table in + * TCG Specification TPM Main Part 2 TPM Structures Section 17. The + * values of the SHORT, MEDIUM, and LONG durations are retrieved + * from the chip during initialization with a call
[U-Boot] [PATCH 3/3] tpm: Update README
Document TPM_TIS_I2C-related config options in README. Signed-off-by: Che-Liang Chiou clch...@chromium.org --- README | 13 + 1 files changed, 13 insertions(+), 0 deletions(-) diff --git a/README b/README index 434384c..badb834 100644 --- a/README +++ b/README @@ -1076,6 +1076,19 @@ The following options need to be configured: CONFIG_TPM Support TPM devices. + CONFIG_TPM_TIS_I2C + Support for i2c bus TPM devices. Only one device + per system is supported at this time. + + CONFIG_TPM_TIS_I2C_BUS_NUMBER + Define the the i2c bus number for the TPM device + + CONFIG_TPM_TIS_I2C_SLAVE_ADDRESS + Define the TPM's address on the i2c bus + + CONFIG_TPM_TIS_I2C_BURST_LIMITATION + Define the burst count bytes upper limit + CONFIG_TPM_TIS_LPC Support for generic parallel port TPM devices. Only one device per system is supported at this time. -- 1.7.3.1 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 2/3] tpm: Add i2c TPM driver
Peter Huewe implemented the original driver; this patch only reorganizes the code structure of the driver, and does not make logical changes. tpm.c implements the interface defined in tpm.h based on underlying LPC or i2C TPM driver. tpm.c and the underlying driver communicate throught tpm_private.h. This patch is tested on a tegra2-based machine, where the i2c driver is not upstreamed yet. Note: Merging the LPC driver with tpm.c is left to future patches. Signed-off-by: Peter Huewe huewe.exter...@infineon.com --- drivers/tpm/Makefile |5 +- drivers/tpm/tpm.c | 457 +++ drivers/tpm/tpm_private.h | 131 ++ drivers/tpm/tpm_tis_i2c.c | 584 + 4 files changed, 1176 insertions(+), 1 deletions(-) create mode 100644 drivers/tpm/tpm.c create mode 100644 drivers/tpm/tpm_private.h create mode 100644 drivers/tpm/tpm_tis_i2c.c diff --git a/drivers/tpm/Makefile b/drivers/tpm/Makefile index 47d09de..cb29bab 100644 --- a/drivers/tpm/Makefile +++ b/drivers/tpm/Makefile @@ -23,7 +23,10 @@ include $(TOPDIR)/config.mk LIB := $(obj)libtpm.o -COBJS-$(CONFIG_TPM_TIS_LPC) = tpm_tis_lpc.o +# TODO(clchiou): Merge tpm_tis_lpc.c with tpm.c +COBJS-$(CONFIG_TPM_TIS_I2C) += tpm.o +COBJS-$(CONFIG_TPM_TIS_I2C) += tpm_tis_i2c.o +COBJS-$(CONFIG_TPM_TIS_LPC) += tpm_tis_lpc.o COBJS := $(COBJS-y) SRCS := $(COBJS:.o=.c) diff --git a/drivers/tpm/tpm.c b/drivers/tpm/tpm.c new file mode 100644 index 000..457deaa --- /dev/null +++ b/drivers/tpm/tpm.c @@ -0,0 +1,457 @@ +/* + * Copyright (C) 2011 Infineon Technologies + * + * Authors: + * Peter Huewe huewe.exter...@infineon.com + * + * Description: + * Device driver for TCG/TCPA TPM (trusted platform module). + * Specifications at www.trustedcomputinggroup.org + * + * It is based on the Linux kernel driver tpm.c from Leendert van + * Dorn, Dave Safford, Reiner Sailer, and Kyleen Hall. + * + * Version: 2.1.1 + * + * See file CREDITS for list of people who contributed to this + * project. + * + * 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, version 2 of the + * License. + * + * 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., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include common.h +#include compiler.h +#include i2c.h +#include tpm.h +#include asm-generic/errno.h +#include linux/types.h +#include linux/unaligned/be_byteshift.h + +#include tpm_private.h + +/* Global structure for tpm chip data */ +static struct tpm_chip tpm_chip; + +enum tpm_duration { + TPM_SHORT = 0, + TPM_MEDIUM = 1, + TPM_LONG = 2, + TPM_UNDEFINED, +}; + +/* Extended error numbers from linux (see errno.h) */ +#defineECANCELED 125 /* Operation Canceled */ + +/* Timer frequency. Corresponds to msec timer resolution*/ +#define HZ 1000 + +#define TPM_MAX_ORDINAL243 +#define TPM_MAX_PROTECTED_ORDINAL 12 +#define TPM_PROTECTED_ORDINAL_MASK 0xFF + +#define TPM_CMD_COUNT_BYTE 2 +#define TPM_CMD_ORDINAL_BYTE 6 + +/* + * Array with one entry per ordinal defining the maximum amount + * of time the chip could take to return the result. The ordinal + * designation of short, medium or long is defined in a table in + * TCG Specification TPM Main Part 2 TPM Structures Section 17. The + * values of the SHORT, MEDIUM, and LONG durations are retrieved + * from the chip during initialization with a call to tpm_get_timeouts. + */ +static const u8 tpm_protected_ordinal_duration[TPM_MAX_PROTECTED_ORDINAL] = { + TPM_UNDEFINED, /* 0 */ + TPM_UNDEFINED, + TPM_UNDEFINED, + TPM_UNDEFINED, + TPM_UNDEFINED, + TPM_UNDEFINED, /* 5 */ + TPM_UNDEFINED, + TPM_UNDEFINED, + TPM_UNDEFINED, + TPM_UNDEFINED, + TPM_SHORT, /* 10 */ + TPM_SHORT, +}; + +static const u8 tpm_ordinal_duration[TPM_MAX_ORDINAL] = { + TPM_UNDEFINED, /* 0 */ + TPM_UNDEFINED, + TPM_UNDEFINED, + TPM_UNDEFINED, + TPM_UNDEFINED, + TPM_UNDEFINED, /* 5 */ + TPM_UNDEFINED, + TPM_UNDEFINED, + TPM_UNDEFINED, + TPM_UNDEFINED, + TPM_SHORT, /* 10 */ + TPM_SHORT, + TPM_MEDIUM, + TPM_LONG, + TPM_LONG, + TPM_MEDIUM, /* 15 */ + TPM_SHORT, + TPM_SHORT, + TPM_MEDIUM, + TPM_LONG, + TPM_SHORT, /* 20 */ + TPM_SHORT, +
Re: [U-Boot] [PATCH V5 3/4] font: split font data from video_font.h
Hi, On Mon, Oct 31, 2011 at 2:33 AM, Anatolij Gustschin ag...@denx.de wrote: Please next time additionally use '-C' Option for 'git format-patch ...' Thanks for the advice. I will add -C option. Regards, Che-Liang ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 1/2] Flatten and solidify block_dev_desc layout
Dear Wolfgang Denk, I guess I have to put this patchset on hold. I will get you back if we could proceed with this patchset. Regards, Che-Liang On Sat, Oct 22, 2011 at 3:09 AM, Wolfgang Denk w...@denx.de wrote: Dear Che-Liang Chiou, In message 1319178708-10881-2-git-send-email-clch...@chromium.org you wrote: The block_dev_desc struct has #ifdef on lba48 and variable-size on lba and so its layout varies from config to config. At least part_efi.c has partially complained about this. This patch makes lba48 be always defined and lba be fixed to largest size that an LBA would need so that the block_dev_desc layout would be an invariant with respect to configurations. Doing so would waste a few extra bytes per struct block_dev_desc, which I believe is not critical. How much exactly is a few bytes? Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de As long as we're going to reinvent the wheel again, we might as well try making it round this time. - Mike Dennison ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 0/2] api: extend accessible set of block device attributes
Hi Detlev, Oops, I did not know it is intentionally to keep the external apps API as it is now. I am working on an open source secure bootloader based on U-Boot. Mostly I wrote boot logic (by boot logic I mean prompting user and listing available devices sort of things). If you see U-Boot as a platform, you can think of my project as an application running on top of U-Boot, except that my application is statically linked with U-Boot. The boot logic is running on ARM and x86. Through the project I have learned that certain APIs would be helpful, such as enumerating all available block device and drawing bitmaps on screen regardless of which driver (video or LCD) you are using. It was probably a misleading finding when I searched the code base: I saw only the external apps API implemented an API for enumerating available block device. So I thought improving the external apps API was the right place to go. Alternatively (if not go the external apps API), we could have like common/cmd_enum_block_dev.c that does what I am planning to do, and I am happy to do this. What do you think? Regards, Che-Liang On Sat, Oct 22, 2011 at 12:06 AM, Detlev Zundel d...@denx.de wrote: Hi, struct device_info in api_public.h defined its own subset of attributes of block_dev_desc, which limits the capability of external apps. This patch set let external apps access the same set of block device attributes as U-Boot. Generally speaking, we are intentionally limiting our API to external applications. It should be easier to extend U-Boot itself (and everybody will profit from the new code under a free license) rather than writing proprietary applications. Can you pleas tell us what the intention of the extension is? We surely will not accept patches gradually exposing all of the U-Boot internals through the API and paving the way for proprietary applications. So every extension has to be balanced and discussed. Thanks Detlev -- Insider comment on Microsoft releasing Linux Hyper-V driver code under GPLv2: It looks like hell just froze over. -- DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-40 Fax: (+49)-8142-66989-80 Email: d...@denx.de ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 0/2] api: extend accessible set of block device attributes
struct device_info in api_public.h defined its own subset of attributes of block_dev_desc, which limits the capability of external apps. This patch set let external apps access the same set of block device attributes as U-Boot. Che-Liang Chiou (2): Flatten and solidify block_dev_desc layout api: storage: Share attributes with block_dev_desc api/api_storage.c| 17 +++-- disk/part_dos.c |2 +- disk/part_efi.c |4 +--- drivers/mmc/mmc.c|4 ++-- drivers/mmc/pxa_mmc.c|2 +- examples/api/demo.c | 15 +-- include/api_public.h |8 +--- include/block_dev_attr.h | 39 +++ include/part.h | 18 +++--- 9 files changed, 76 insertions(+), 33 deletions(-) create mode 100644 include/block_dev_attr.h -- 1.7.3.1 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 1/2] Flatten and solidify block_dev_desc layout
The block_dev_desc struct has #ifdef on lba48 and variable-size on lba and so its layout varies from config to config. At least part_efi.c has partially complained about this. This patch makes lba48 be always defined and lba be fixed to largest size that an LBA would need so that the block_dev_desc layout would be an invariant with respect to configurations. Doing so would waste a few extra bytes per struct block_dev_desc, which I believe is not critical. Signed-off-by: Che-Liang Chiou clch...@chromium.org --- disk/part_dos.c |2 +- disk/part_efi.c |4 +--- drivers/mmc/mmc.c |4 ++-- drivers/mmc/pxa_mmc.c |2 +- include/part.h|4 +--- 5 files changed, 6 insertions(+), 10 deletions(-) diff --git a/disk/part_dos.c b/disk/part_dos.c index b5bcb37..a0938db 100644 --- a/disk/part_dos.c +++ b/disk/part_dos.c @@ -119,7 +119,7 @@ static void print_partition_extended (block_dev_desc_t *dev_desc, int ext_part_s return; } if(i==DOS_PBR) { - printf (1\t\t 0\t%10ld\t%2x\n, + printf (1\t\t 0\t%10lld\t%2x\n, dev_desc-lba, buffer[DOS_PBR_MEDIA_TYPE_OFFSET]); return; } diff --git a/disk/part_efi.c b/disk/part_efi.c index 0a513c6..e779dc1 100644 --- a/disk/part_efi.c +++ b/disk/part_efi.c @@ -22,10 +22,8 @@ */ /* - * Problems with CONFIG_SYS_64BIT_LBA: - * * struct disk_partition.start in include/part.h is sized as ulong. - * When CONFIG_SYS_64BIT_LBA is activated, lbaint_t changes from ulong to uint64_t. + * struct block_dev_desc.lba in the same header is sized as uint64_t. * For now, it is cast back to ulong at assignment. * * This limits the maximum size of addressable storage to 2 Terra Bytes diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 391bc2b..c17e495 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -265,7 +265,7 @@ mmc_write_blocks(struct mmc *mmc, ulong start, lbaint_t blkcnt, const void*src) int timeout = 1000; if ((start + blkcnt) mmc-block_dev.lba) { - printf(MMC: block number 0x%lx exceeds max(0x%lx)\n, + printf(MMC: block number 0x%lx exceeds max(0x%llx)\n, start + blkcnt, mmc-block_dev.lba); return 0; } @@ -393,7 +393,7 @@ static ulong mmc_bread(int dev_num, ulong start, lbaint_t blkcnt, void *dst) return 0; if ((start + blkcnt) mmc-block_dev.lba) { - printf(MMC: block number 0x%lx exceeds max(0x%lx)\n, + printf(MMC: block number 0x%lx exceeds max(0x%llx)\n, start + blkcnt, mmc-block_dev.lba); return 0; } diff --git a/drivers/mmc/pxa_mmc.c b/drivers/mmc/pxa_mmc.c index 48e21ef..67c33d4 100644 --- a/drivers/mmc/pxa_mmc.c +++ b/drivers/mmc/pxa_mmc.c @@ -541,7 +541,7 @@ static void mmc_decode_csd(uint32_t * resp) mmc_dev.removable = 0; mmc_dev.block_read = mmc_bread; - printf(Detected: %lu blocks of %lu bytes (%luMB) , + printf(Detected: %llu blocks of %lu bytes (%lluMB) , mmc_dev.lba, mmc_dev.blksz, mmc_dev.lba * mmc_dev.blksz / (1024 * 1024)); diff --git a/include/part.h b/include/part.h index 1827767..be0a22e 100644 --- a/include/part.h +++ b/include/part.h @@ -33,10 +33,8 @@ typedef struct block_dev_desc { unsigned char lun;/* target LUN */ unsigned char type; /* device type */ unsigned char removable; /* removable device */ -#ifdef CONFIG_LBA48 unsigned char lba48; /* device can use 48bit addr (ATA/ATAPI v7) */ -#endif - lbaint_tlba;/* number of blocks */ + uint64_tlba;/* number of blocks */ unsigned long blksz; /* block size */ charvendor [40+1]; /* IDE model, SCSI Vendor */ charproduct[20+1]; /* IDE Serial no, SCSI product */ -- 1.7.3.1 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 2/2] api: storage: Share attributes with block_dev_desc
struct device_info in api_public.h defined its own subset of attributes of block_dev_desc, which limits the capability of external apps. This patch let struct device_info and block_dev_desc share the same set of attributes so that an external app has equal amount of information of block device compared to U-Boot. The export.h and _export.h have somewhat addressed the same issue. That is, sharing declarations between U-Boot and external apps. Signed-off-by: Che-Liang Chiou clch...@chromium.org --- api/api_storage.c| 17 +++-- examples/api/demo.c | 15 +-- include/api_public.h |8 +--- include/block_dev_attr.h | 39 +++ include/part.h | 16 +++- 5 files changed, 71 insertions(+), 24 deletions(-) create mode 100644 include/block_dev_attr.h diff --git a/api/api_storage.c b/api/api_storage.c index c535712..ab4cad5 100644 --- a/api/api_storage.c +++ b/api/api_storage.c @@ -165,8 +165,21 @@ static int dev_stor_get(int type, int first, int *more, struct device_info *di) debugf(device instance exists, but is not active..); found = 0; } else { - di-di_stor.block_count = dd-lba; - di-di_stor.block_size = dd-blksz; +#define COPY_ATTR(a) di-di_stor.a = dd-a + COPY_ATTR(if_type); + COPY_ATTR(dev); + COPY_ATTR(part_type); + COPY_ATTR(target); + COPY_ATTR(lun); + COPY_ATTR(type); + COPY_ATTR(removable); + COPY_ATTR(lba48); + COPY_ATTR(lba); + COPY_ATTR(blksz); +#undef COPY_ATTR + strcpy(di-di_stor.vendor, dd-vendor); + strcpy(di-di_stor.product, dd-product); + strcpy(di-di_stor.revision, dd-revision); } } diff --git a/examples/api/demo.c b/examples/api/demo.c index 65e7491..0c65ae9 100644 --- a/examples/api/demo.c +++ b/examples/api/demo.c @@ -294,7 +294,18 @@ void test_dump_di(int handle) } else if (di-type DEV_TYP_STOR) { printf( type\t\t= %s\n, test_stor_typ(di-type)); - printf( blk size\t\t= %d\n, (unsigned int)di-di_stor.block_size); - printf( blk count\t\t= %d\n, (unsigned int)di-di_stor.block_count); + printf( if_type\t\t= %d\n, di-di_stor.if_type); + printf( dev\t\t= %d\n, di-di_stor.dev); + printf( part_type\t\t= %d\n, di-di_stor.part_type); + printf( target\t\t= %d\n, di-di_stor.target); + printf( lun\t\t= %d\n, di-di_stor.lun); + printf( device type\t\t= %d\n, di-di_stor.type); + printf( removable\t\t= %d\n, di-di_stor.removable); + printf( lba48\t\t= %d\n, di-di_stor.lba48); + printf( blk size\t\t= %d\n, (unsigned int)di-di_stor.blksz); + printf( blk count\t\t= %d\n, (unsigned int)di-di_stor.lba); + printf( vendor\t\t= %s\n, di-di_stor.vendor); + printf( product\t\t= %s\n, di-di_stor.product); + printf( revision\t\t= %s\n, di-di_stor.revision); } } diff --git a/include/api_public.h b/include/api_public.h index 5940d81..245904f 100644 --- a/include/api_public.h +++ b/include/api_public.h @@ -111,12 +111,7 @@ struct sys_info { int mr_no; /* number of memory regions */ }; -#undef CONFIG_SYS_64BIT_LBA -#ifdef CONFIG_SYS_64BIT_LBA -typedefu_int64_t lbasize_t; -#else typedef unsigned long lbasize_t; -#endif typedef unsigned long lbastart_t; #define DEV_TYP_NONE 0x @@ -138,8 +133,7 @@ struct device_info { union { struct { - lbasize_t block_count;/* no of blocks */ - unsigned long block_size; /* size of one block */ + #include block_dev_attr.h } storage; struct { diff --git a/include/block_dev_attr.h b/include/block_dev_attr.h new file mode 100644 index 000..07a76d8 --- /dev/null +++ b/include/block_dev_attr.h @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2011 The Chromium OS Authors. + * See file CREDITS for list of people who contributed to this + * project. + * + * 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
[U-Boot] [PATCH 1/2] Flatten and solidify block_dev_desc layout
The block_dev_desc struct has #ifdef on lba48 and variable-size on lba and so its layout varies from config to config. At least part_efi.c has partially complained about this. This patch makes lba48 be always defined and lba be fixed to largest size that an LBA would need so that the block_dev_desc layout would be an invariant with respect to configurations. Doing so would waste a few extra bytes per struct block_dev_desc, which I believe is not critical. Signed-off-by: Che-Liang Chiou clch...@chromium.org --- Fix a minor checkpatch violation. disk/part_dos.c |2 +- disk/part_efi.c |4 +--- drivers/mmc/mmc.c |4 ++-- drivers/mmc/pxa_mmc.c |2 +- include/part.h|4 +--- 5 files changed, 6 insertions(+), 10 deletions(-) diff --git a/disk/part_dos.c b/disk/part_dos.c index b5bcb37..a0938db 100644 --- a/disk/part_dos.c +++ b/disk/part_dos.c @@ -119,7 +119,7 @@ static void print_partition_extended (block_dev_desc_t *dev_desc, int ext_part_s return; } if(i==DOS_PBR) { - printf (1\t\t 0\t%10ld\t%2x\n, + printf(1\t\t 0\t%10lld\t%2x\n, dev_desc-lba, buffer[DOS_PBR_MEDIA_TYPE_OFFSET]); return; } diff --git a/disk/part_efi.c b/disk/part_efi.c index 0a513c6..e779dc1 100644 --- a/disk/part_efi.c +++ b/disk/part_efi.c @@ -22,10 +22,8 @@ */ /* - * Problems with CONFIG_SYS_64BIT_LBA: - * * struct disk_partition.start in include/part.h is sized as ulong. - * When CONFIG_SYS_64BIT_LBA is activated, lbaint_t changes from ulong to uint64_t. + * struct block_dev_desc.lba in the same header is sized as uint64_t. * For now, it is cast back to ulong at assignment. * * This limits the maximum size of addressable storage to 2 Terra Bytes diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 391bc2b..c17e495 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -265,7 +265,7 @@ mmc_write_blocks(struct mmc *mmc, ulong start, lbaint_t blkcnt, const void*src) int timeout = 1000; if ((start + blkcnt) mmc-block_dev.lba) { - printf(MMC: block number 0x%lx exceeds max(0x%lx)\n, + printf(MMC: block number 0x%lx exceeds max(0x%llx)\n, start + blkcnt, mmc-block_dev.lba); return 0; } @@ -393,7 +393,7 @@ static ulong mmc_bread(int dev_num, ulong start, lbaint_t blkcnt, void *dst) return 0; if ((start + blkcnt) mmc-block_dev.lba) { - printf(MMC: block number 0x%lx exceeds max(0x%lx)\n, + printf(MMC: block number 0x%lx exceeds max(0x%llx)\n, start + blkcnt, mmc-block_dev.lba); return 0; } diff --git a/drivers/mmc/pxa_mmc.c b/drivers/mmc/pxa_mmc.c index 48e21ef..67c33d4 100644 --- a/drivers/mmc/pxa_mmc.c +++ b/drivers/mmc/pxa_mmc.c @@ -541,7 +541,7 @@ static void mmc_decode_csd(uint32_t * resp) mmc_dev.removable = 0; mmc_dev.block_read = mmc_bread; - printf(Detected: %lu blocks of %lu bytes (%luMB) , + printf(Detected: %llu blocks of %lu bytes (%lluMB) , mmc_dev.lba, mmc_dev.blksz, mmc_dev.lba * mmc_dev.blksz / (1024 * 1024)); diff --git a/include/part.h b/include/part.h index 1827767..be0a22e 100644 --- a/include/part.h +++ b/include/part.h @@ -33,10 +33,8 @@ typedef struct block_dev_desc { unsigned char lun;/* target LUN */ unsigned char type; /* device type */ unsigned char removable; /* removable device */ -#ifdef CONFIG_LBA48 unsigned char lba48; /* device can use 48bit addr (ATA/ATAPI v7) */ -#endif - lbaint_tlba;/* number of blocks */ + uint64_tlba;/* number of blocks */ unsigned long blksz; /* block size */ charvendor [40+1]; /* IDE model, SCSI Vendor */ charproduct[20+1]; /* IDE Serial no, SCSI product */ -- 1.7.3.1 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH V5 0/4] export LCD device to external apps
This patch set exports LCD clearing and bitmap-rendering on screen functions to external apps, and provides a unified interface of accessing them. Che-Liang Chiou (4): lcd: add clear and draw bitmap declaration tools: logo: split bmp arrays from bmp_logo.h font: split font data from video_font.h api: export LCD device to external apps Makefile|1 + api/Makefile|3 +- api/api.c | 47 + api/api_display.c | 74 + api/api_private.h |4 + arch/powerpc/cpu/mpc8xx/video.c |1 + board/mcc200/lcd.c |4 +- common/cmd_bmp.c|4 +- common/lcd.c| 16 +- drivers/video/cfb_console.c |2 + drivers/video/sed156x.c |1 + examples/api/demo.c | 31 + examples/api/glue.c | 31 + examples/api/glue.h |5 + include/api_public.h| 16 + include/lcd.h |2 + include/video_font.h| 4614 +-- include/video_font_data.h | 4639 +++ tools/Makefile |8 +- tools/bmp_logo.c| 80 +- 20 files changed, 4940 insertions(+), 4643 deletions(-) create mode 100644 api/api_display.c create mode 100644 include/video_font_data.h -- 1.7.3.1 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH V5 2/4] tools: logo: split bmp arrays from bmp_logo.h
The generated header bmp_logo.h is useful even outside common/lcd.c for the logo dimension. However, the problem is, the generated bmp_logo.h cannot be included multiple times because bmp_logo_palette[] and bmp_logo_bitmap[] are defined in the bmp_logo.h. This patch fixes this by defining these arrays in another header bmp_logo_data.h and in bmp_logo.h only declaring these arrays. Signed-off-by: Che-Liang Chiou clch...@chromium.org --- Changes in V5 Split bmp arrays from bmp_logo.h to bmp_logo_data.h Changes in V4 None Changes in V3 Add to the patch set Makefile|1 + common/lcd.c|1 + drivers/video/cfb_console.c |1 + tools/Makefile |8 - tools/bmp_logo.c| 80 --- 5 files changed, 70 insertions(+), 21 deletions(-) diff --git a/Makefile b/Makefile index e9a153c..d35f2b5 100644 --- a/Makefile +++ b/Makefile @@ -947,6 +947,7 @@ clean: $(obj)arch/blackfin/cpu/bootrom-asm-offsets.[chs] \ $(obj)arch/blackfin/cpu/init.{lds,elf} @rm -f $(obj)include/bmp_logo.h + @rm -f $(obj)include/bmp_logo_data.h @rm -f $(obj)lib/asm-offsets.s @rm -f $(obj)include/generated/asm-offsets.h @rm -f $(obj)$(CPUDIR)/$(SOC)/asm-offsets.s diff --git a/common/lcd.c b/common/lcd.c index 6d91310..dd4d37b 100644 --- a/common/lcd.c +++ b/common/lcd.c @@ -63,6 +63,7 @@ // #ifdef CONFIG_LCD_LOGO # include bmp_logo.h /* Get logo data, width and height */ +# include bmp_logo_data.h # if (CONSOLE_COLOR_WHITE = BMP_LOGO_OFFSET) (LCD_BPP != LCD_COLOR16) # error Default Color Map overlaps with Logo Color Map # endif diff --git a/drivers/video/cfb_console.c b/drivers/video/cfb_console.c index 4e653b8..8d0c496 100644 --- a/drivers/video/cfb_console.c +++ b/drivers/video/cfb_console.c @@ -285,6 +285,7 @@ void console_cursor(int state); #ifdef CONFIG_VIDEO_LOGO #ifdef CONFIG_VIDEO_BMP_LOGO #include bmp_logo.h +#include bmp_logo_data.h #define VIDEO_LOGO_WIDTH BMP_LOGO_WIDTH #define VIDEO_LOGO_HEIGHT BMP_LOGO_HEIGHT #define VIDEO_LOGO_LUT_OFFSET BMP_LOGO_OFFSET diff --git a/tools/Makefile b/tools/Makefile index fc741d3..f750ad2 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -110,8 +110,11 @@ LIBFDT_OBJ_FILES-y += fdt_wip.o # Generated LCD/video logo LOGO_H = $(OBJTREE)/include/bmp_logo.h +LOGO_DATA_H = $(OBJTREE)/include/bmp_logo_data.h LOGO-$(CONFIG_LCD_LOGO) += $(LOGO_H) +LOGO-$(CONFIG_LCD_LOGO) += $(LOGO_DATA_H) LOGO-$(CONFIG_VIDEO_LOGO) += $(LOGO_H) +LOGO-$(CONFIG_VIDEO_LOGO) += $(LOGO_DATA_H) ifeq ($(LOGO_BMP),) LOGO_BMP= logos/denx.bmp @@ -234,7 +237,10 @@ else endif $(LOGO_H): $(obj)bmp_logo $(LOGO_BMP) - $(obj)./bmp_logo $(LOGO_BMP) $@ + $(obj)./bmp_logo --gen-info $(LOGO_BMP) $@ + +$(LOGO_DATA_H):$(obj)bmp_logo $(LOGO_BMP) + $(obj)./bmp_logo --gen-data $(LOGO_BMP) $@ # diff --git a/tools/bmp_logo.c b/tools/bmp_logo.c index 47228d2..b2ad3d5 100644 --- a/tools/bmp_logo.c +++ b/tools/bmp_logo.c @@ -1,5 +1,10 @@ #include compiler.h +enum { + MODE_GEN_INFO, + MODE_GEN_DATA +}; + typedef struct bitmap_s { /* bitmap description */ uint16_t width; uint16_t height; @@ -9,6 +14,11 @@ typedef struct bitmap_s { /* bitmap description */ #define DEFAULT_CMAP_SIZE 16 /* size of default color map*/ +void usage(const char *prog) +{ + fprintf(stderr, Usage: %s [--gen-info|--gen-data] file\n, prog); +} + /* * Neutralize little endians. */ @@ -39,21 +49,52 @@ int error (char * msg, FILE *fp) exit (EXIT_FAILURE); } +void gen_info(bitmap_t *b, uint16_t n_colors) +{ + printf(/*\n +* Automatically generated by \tools/bmp_logo\\n +*\n +* DO NOT EDIT\n +*\n +*/\n\n\n + #ifndef __BMP_LOGO_H__\n + #define __BMP_LOGO_H__\n\n + #define BMP_LOGO_WIDTH\t\t%d\n + #define BMP_LOGO_HEIGHT\t\t%d\n + #define BMP_LOGO_COLORS\t\t%d\n + #define BMP_LOGO_OFFSET\t\t%d\n\n + extern unsigned short bmp_logo_palette[];\n + extern unsigned char bmp_logo_bitmap[];\n\n + #endif /* __BMP_LOGO_H__ */\n, + b-width, b-height, n_colors, + DEFAULT_CMAP_SIZE); +} + int main (int argc, char *argv[]) { - int i, x; + int mode, i, x; FILE*fp; bitmap_t bmp; bitmap_t *b = bmp; uint16_t data_offset, n_colors; - if (argc 2) { - fprintf (stderr, Usage: %s file\n, argv[0]); + if (argc 3) { + usage(argv[0]); exit
[U-Boot] [PATCH V5 1/4] lcd: add clear and draw bitmap declaration
The functions for clearing and drawing bitmaps on the screen were not exposed publicly and are made public in this patch in preparation for implementing the display interface of api_public.h. Signed-off-by: Che-Liang Chiou clch...@chromium.org --- Changes in V5 Remove inline extern declaration from cmd_bmp.c Changes in V4 Remove support of video device, which is untested and will leave to future work Changes in V3 Rebase to ToT Changes in V2 Fix style errors common/cmd_bmp.c |4 +--- common/lcd.c | 14 ++ include/lcd.h|2 ++ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/common/cmd_bmp.c b/common/cmd_bmp.c index 23fc82f..682f395 100644 --- a/common/cmd_bmp.c +++ b/common/cmd_bmp.c @@ -237,9 +237,7 @@ static int bmp_display(ulong addr, int x, int y) } #if defined(CONFIG_LCD) - extern int lcd_display_bitmap (ulong, int, int); - - ret = lcd_display_bitmap ((unsigned long)bmp, x, y); + ret = lcd_display_bitmap((ulong)bmp, x, y); #elif defined(CONFIG_VIDEO) extern int video_display_bitmap (ulong, int, int); diff --git a/common/lcd.c b/common/lcd.c index d9cb8ca..6d91310 100644 --- a/common/lcd.c +++ b/common/lcd.c @@ -353,7 +353,14 @@ int drv_lcd_init (void) } /*--*/ -static int lcd_clear (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) +static +int do_lcd_clear(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) +{ + lcd_clear(); + return 0; +} + +void lcd_clear(void) { #if LCD_BPP == LCD_MONOCHROME /* Setting the palette */ @@ -394,8 +401,7 @@ static int lcd_clear (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[] console_col = 0; console_row = 0; - - return (0); + lcd_sync(); } U_BOOT_CMD( @@ -413,7 +419,7 @@ static int lcd_init (void *lcdbase) lcd_ctrl_init (lcdbase); lcd_is_enabled = 1; - lcd_clear (NULL, 1, 1, NULL); /* dummy args */ + lcd_clear(); lcd_enable (); /* Initialize the console */ diff --git a/include/lcd.h b/include/lcd.h index 0e098d9..39af14a 100644 --- a/include/lcd.h +++ b/include/lcd.h @@ -210,6 +210,8 @@ voidlcd_disable (void); void lcd_putc(const char c); void lcd_puts(const char *s); void lcd_printf (const char *fmt, ...); +void lcd_clear(void); +intlcd_display_bitmap(ulong bmp_image, int x, int y); /* Allow boards to customize the information displayed */ void lcd_show_board_info(void); -- 1.7.3.1 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH V5 4/4] api: export LCD device to external apps
This patch exports LCD info-query and bitmap-rendering functions to external apps. This patch is tested on a Seaboard. Because the LCD driver is not yet upstreamed, the test was done in a local downstream repo. Signed-off-by: Che-Liang Chiou clch...@chromium.org --- Changes in V5 Clean up logic Changes in V4 Remove support of video device, which is untested and will leave to future work Changes in V3 Rebase to ToT Changes in V2 Fix style errors api/Makefile |3 +- api/api.c| 47 +++ api/api_display.c| 74 ++ api/api_private.h|4 +++ examples/api/demo.c | 31 + examples/api/glue.c | 31 + examples/api/glue.h |5 +++ include/api_public.h | 16 +++ 8 files changed, 210 insertions(+), 1 deletions(-) create mode 100644 api/api_display.c diff --git a/api/Makefile b/api/Makefile index 2a64c4d..0e99f74 100644 --- a/api/Makefile +++ b/api/Makefile @@ -24,7 +24,8 @@ include $(TOPDIR)/config.mk LIB= $(obj)libapi.o -COBJS-$(CONFIG_API) += api.o api_net.o api_storage.o api_platform-$(ARCH).o +COBJS-$(CONFIG_API) += api.o api_display.o api_net.o api_storage.o \ + api_platform-$(ARCH).o COBJS := $(COBJS-y) SRCS := $(COBJS:.o=.c) diff --git a/api/api.c b/api/api.c index 853f010..a3bf60a 100644 --- a/api/api.c +++ b/api/api.c @@ -553,6 +553,50 @@ static int API_env_enum(va_list ap) return 0; } +/* + * pseudo signature: + * + * int API_display_get_info(int type, struct display_info *di) + */ +static int API_display_get_info(va_list ap) +{ + int type; + struct display_info *di; + + type = va_arg(ap, int); + di = va_arg(ap, struct display_info *); + + return display_get_info(type, di); +} + +/* + * pseudo signature: + * + * int API_display_draw_bitmap(ulong bitmap, int x, int y) + */ +static int API_display_draw_bitmap(va_list ap) +{ + ulong bitmap; + int x, y; + + bitmap = va_arg(ap, ulong); + x = va_arg(ap, int); + y = va_arg(ap, int); + + return display_draw_bitmap(bitmap, x, y); +} + +/* + * pseudo signature: + * + * void API_display_clear(void) + */ +static int API_display_clear(va_list ap) +{ + display_clear(); + return 0; +} + static cfp_t calls_table[API_MAXCALL] = { NULL, }; /* @@ -616,6 +660,9 @@ void api_init(void) calls_table[API_ENV_GET] = API_env_get; calls_table[API_ENV_SET] = API_env_set; calls_table[API_ENV_ENUM] = API_env_enum; + calls_table[API_DISPLAY_GET_INFO] = API_display_get_info; + calls_table[API_DISPLAY_DRAW_BITMAP] = API_display_draw_bitmap; + calls_table[API_DISPLAY_CLEAR] = API_display_clear; calls_no = API_MAXCALL; debugf(API initialized with %d calls\n, calls_no); diff --git a/api/api_display.c b/api/api_display.c new file mode 100644 index 000..6439170 --- /dev/null +++ b/api/api_display.c @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2011 The Chromium OS Authors. + * See file CREDITS for list of people who contributed to this + * project. + * + * 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., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include common.h +#include api_public.h +#include lcd.h +#include video_font.h /* Get font width and height */ + +/* lcd.h needs BMP_LOGO_HEIGHT to calculate CONSOLE_ROWS */ +#if defined(CONFIG_LCD_LOGO) !defined(CONFIG_LCD_INFO_BELOW_LOGO) +#include bmp_logo.h +#endif + +/* TODO(clchiou): add support of video device */ + +int display_get_info(int type, struct display_info *di) +{ + if (!di) + return API_EINVAL; + + switch (type) { + default: + debug(%s: unsupport display device type: %d\n, + __FILE__, type); + return API_ENODEV; +#ifdef CONFIG_LCD + case DISPLAY_TYPE_LCD: + di-pixel_width = panel_info.vl_col; + di-pixel_height = panel_info.vl_row; + di-screen_rows = CONSOLE_ROWS; + di-screen_cols = CONSOLE_COLS; + break; +#endif + } + + di-type = type; + return 0; +} + +int display_draw_bitmap(ulong bitmap, int x, int y) +{ + if (!bitmap) + return
[U-Boot] [PATCH V5 1/4] lcd: add clear and draw bitmap declaration
The functions for clearing and drawing bitmaps on the screen were not exposed publicly and are made public in this patch in preparation for implementing the display interface of api_public.h. Signed-off-by: Che-Liang Chiou clch...@chromium.org --- Changes in V5 Remove inline extern declaration from cmd_bmp.c Changes in V4 Remove support of video device, which is untested and will leave to future work Changes in V3 Rebase to ToT Changes in V2 Fix style errors common/cmd_bmp.c |4 +--- common/lcd.c | 14 ++ include/lcd.h|2 ++ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/common/cmd_bmp.c b/common/cmd_bmp.c index 23fc82f..682f395 100644 --- a/common/cmd_bmp.c +++ b/common/cmd_bmp.c @@ -237,9 +237,7 @@ static int bmp_display(ulong addr, int x, int y) } #if defined(CONFIG_LCD) - extern int lcd_display_bitmap (ulong, int, int); - - ret = lcd_display_bitmap ((unsigned long)bmp, x, y); + ret = lcd_display_bitmap((ulong)bmp, x, y); #elif defined(CONFIG_VIDEO) extern int video_display_bitmap (ulong, int, int); diff --git a/common/lcd.c b/common/lcd.c index d9cb8ca..6d91310 100644 --- a/common/lcd.c +++ b/common/lcd.c @@ -353,7 +353,14 @@ int drv_lcd_init (void) } /*--*/ -static int lcd_clear (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) +static +int do_lcd_clear(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) +{ + lcd_clear(); + return 0; +} + +void lcd_clear(void) { #if LCD_BPP == LCD_MONOCHROME /* Setting the palette */ @@ -413,7 +419,7 @@ static int lcd_init (void *lcdbase) lcd_ctrl_init (lcdbase); lcd_is_enabled = 1; - lcd_clear (NULL, 1, 1, NULL); /* dummy args */ + lcd_clear(); lcd_enable (); /* Initialize the console */ diff --git a/include/lcd.h b/include/lcd.h index 0e098d9..39af14a 100644 --- a/include/lcd.h +++ b/include/lcd.h @@ -210,6 +210,8 @@ voidlcd_disable (void); void lcd_putc(const char c); void lcd_puts(const char *s); void lcd_printf (const char *fmt, ...); +void lcd_clear(void); +intlcd_display_bitmap(ulong bmp_image, int x, int y); /* Allow boards to customize the information displayed */ void lcd_show_board_info(void); -- 1.7.3.1 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH V4 0/3] api: export LCD and video to external apps
This patch set exports LCD clearing and bitmap-rendering on screen functions to external apps, and provides a unified interface of accessing them. Che-Liang Chiou (3): lcd: add clear and draw bitmap declaration tools: logo: add static and unused to bmp arrays api: export LCD device to external apps api/Makefile |3 +- api/api.c| 51 + api/api_display.c| 69 ++ api/api_private.h|4 +++ common/lcd.c | 16 +++ examples/api/demo.c | 31 ++ examples/api/glue.c | 31 ++ examples/api/glue.h |5 +++ include/api_public.h | 16 +++ include/lcd.h|2 + include/video_font.h |6 tools/bmp_logo.c |6 +++- 12 files changed, 231 insertions(+), 9 deletions(-) create mode 100644 api/api_display.c -- 1.7.3.1 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH V4 1/3] lcd: add clear and draw bitmap declaration
The functions for clearing and drawing bitmaps on the screen were not exposed publicly and are made public in this patch in preparation for implementing the display interface of api_public.h. Signed-off-by: Che-Liang Chiou clch...@chromium.org --- Changes in V4 Remove support of video device, which is untested and will leave to future work Changes in V3 Rebase to ToT Changes in V2 Fix style errors common/lcd.c | 16 ++-- include/lcd.h |2 ++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/common/lcd.c b/common/lcd.c index d9cb8ca..20e97b9 100644 --- a/common/lcd.c +++ b/common/lcd.c @@ -78,7 +78,6 @@ static inline void lcd_putc_xy (ushort x, ushort y, uchar c); static int lcd_init (void *lcdbase); -static int lcd_clear (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]); static void *lcd_logo (void); static int lcd_getbgcolor (void); @@ -353,7 +352,14 @@ int drv_lcd_init (void) } /*--*/ -static int lcd_clear (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) +static +int do_lcd_clear(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) +{ + lcd_clear(); + return 0; +} + +void lcd_clear(void) { #if LCD_BPP == LCD_MONOCHROME /* Setting the palette */ @@ -394,12 +400,10 @@ static int lcd_clear (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[] console_col = 0; console_row = 0; - - return (0); } U_BOOT_CMD( - cls,1, 1, lcd_clear, + cls,1, 1, do_lcd_clear, clear screen, ); @@ -413,7 +417,7 @@ static int lcd_init (void *lcdbase) lcd_ctrl_init (lcdbase); lcd_is_enabled = 1; - lcd_clear (NULL, 1, 1, NULL); /* dummy args */ + lcd_clear(); lcd_enable (); /* Initialize the console */ diff --git a/include/lcd.h b/include/lcd.h index 0e098d9..39af14a 100644 --- a/include/lcd.h +++ b/include/lcd.h @@ -210,6 +210,8 @@ voidlcd_disable (void); void lcd_putc(const char c); void lcd_puts(const char *s); void lcd_printf (const char *fmt, ...); +void lcd_clear(void); +intlcd_display_bitmap(ulong bmp_image, int x, int y); /* Allow boards to customize the information displayed */ void lcd_show_board_info(void); -- 1.7.3.1 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH V4 2/3] tools: logo: add static and unused to bmp arrays
The generated header bmp_logo.h is useful even outside common/lcd.c for the logo dimension. However, the problem is, the generated bmp_logo.h cannot be included multiple times because bmp_logo_palette[] and bmp_logo_bitmap[] are defined in the bmp_logo.h. We may remedy this by adding static __attribute__((unused)) to the array definitions so that bmp_logo.h can be included multiple times, and these arrays is used in only one inclusion (lcd.c). Signed-off-by: Che-Liang Chiou clch...@chromium.org --- Changes in V4 None Changes in V3 Add to the patch set tools/bmp_logo.c |6 -- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/bmp_logo.c b/tools/bmp_logo.c index 47228d2..3d11284 100644 --- a/tools/bmp_logo.c +++ b/tools/bmp_logo.c @@ -113,7 +113,8 @@ int main (int argc, char *argv[]) error (Error allocating memory for file, fp); /* read and print the palette information */ - printf (unsigned short bmp_logo_palette[] = {\n); + printf(static __attribute__((unused)) + unsigned short bmp_logo_palette[] = {\n); for (i=0; in_colors; ++i) { b-palette[(int)(i*3+2)] = fgetc(fp); @@ -137,7 +138,8 @@ int main (int argc, char *argv[]) printf (\n); printf (};\n); printf (\n); - printf (unsigned char bmp_logo_bitmap[] = {\n); + printf(static __attribute__((unused)) + unsigned char bmp_logo_bitmap[] = {\n); for (i=(b-height-1)*b-width; i=0; i-=b-width) { for (x = 0; x b-width; x++) { b-data[(uint16_t) i + x] = (uint8_t) fgetc (fp) \ -- 1.7.3.1 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH V4 3/3] api: export LCD device to external apps
This patch exports LCD info-query and bitmap-rendering functions to external apps. This patch is tested on a Seaboard. Because the LCD driver is not yet upstreamed, the test was done in a local downstream repo. Signed-off-by: Che-Liang Chiou clch...@chromium.org --- Changes in V4 Remove support of video device, which is untested and will leave to future work Changes in V3 Rebase to ToT Changes in V2 Fix style errors api/Makefile |3 +- api/api.c| 51 + api/api_display.c| 69 ++ api/api_private.h|4 +++ examples/api/demo.c | 31 ++ examples/api/glue.c | 31 ++ examples/api/glue.h |5 +++ include/api_public.h | 16 +++ include/video_font.h |6 9 files changed, 215 insertions(+), 1 deletions(-) create mode 100644 api/api_display.c diff --git a/api/Makefile b/api/Makefile index 2a64c4d..0e99f74 100644 --- a/api/Makefile +++ b/api/Makefile @@ -24,7 +24,8 @@ include $(TOPDIR)/config.mk LIB= $(obj)libapi.o -COBJS-$(CONFIG_API) += api.o api_net.o api_storage.o api_platform-$(ARCH).o +COBJS-$(CONFIG_API) += api.o api_display.o api_net.o api_storage.o \ + api_platform-$(ARCH).o COBJS := $(COBJS-y) SRCS := $(COBJS:.o=.c) diff --git a/api/api.c b/api/api.c index 853f010..ddf2edd 100644 --- a/api/api.c +++ b/api/api.c @@ -553,6 +553,54 @@ static int API_env_enum(va_list ap) return 0; } +/* + * pseudo signature: + * + * int API_display_get_info(int type, struct display_info *di) + */ +static int API_display_get_info(va_list ap) +{ + int type; + struct display_info *di; + + type = (int)va_arg(ap, u_int32_t); + di = (struct display_info *)va_arg(ap, u_int32_t); + if (!di) + return API_EINVAL; + + return display_get_info(type, di); +} + +/* + * pseudo signature: + * + * int API_display_draw_bitmap(void *bitmap, int x, int y) + */ +static int API_display_draw_bitmap(va_list ap) +{ + ulong bitmap; + int x, y; + + bitmap = (ulong)va_arg(ap, ulong); + if (!bitmap) + return API_EINVAL; + x = (int)va_arg(ap, u_int32_t); + y = (int)va_arg(ap, u_int32_t); + + return display_draw_bitmap(bitmap, x, y); +} + +/* + * pseudo signature: + * + * void API_display_clear(void) + */ +static int API_display_clear(va_list ap) +{ + display_clear(); + return 0; +} + static cfp_t calls_table[API_MAXCALL] = { NULL, }; /* @@ -616,6 +664,9 @@ void api_init(void) calls_table[API_ENV_GET] = API_env_get; calls_table[API_ENV_SET] = API_env_set; calls_table[API_ENV_ENUM] = API_env_enum; + calls_table[API_DISPLAY_GET_INFO] = API_display_get_info; + calls_table[API_DISPLAY_DRAW_BITMAP] = API_display_draw_bitmap; + calls_table[API_DISPLAY_CLEAR] = API_display_clear; calls_no = API_MAXCALL; debugf(API initialized with %d calls\n, calls_no); diff --git a/api/api_display.c b/api/api_display.c new file mode 100644 index 000..b18a4a5 --- /dev/null +++ b/api/api_display.c @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2011 The Chromium OS Authors. + * See file CREDITS for list of people who contributed to this + * project. + * + * 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., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include common.h +#include api_public.h +#include lcd.h +#include video_font.h /* Get font width and height */ + +/* lcd.h needs BMP_LOGO_HEIGHT to calculate CONSOLE_ROWS */ +#if defined(CONFIG_LCD_LOGO) !defined(CONFIG_LCD_INFO_BELOW_LOGO) +#include bmp_logo.h +#endif + +/* TODO(clchiou): add support of video device */ + +int display_get_info(int type, struct display_info *di) +{ + switch (type) { + default: + debug(%s: unsupport display device type: %d\n, + __FILE__, type); + return API_ENODEV; +#ifdef CONFIG_LCD + case DISPLAY_TYPE_LCD: + di-pixel_width = panel_info.vl_col; + di-pixel_height = panel_info.vl_row; + di-screen_rows = CONSOLE_ROWS; + di-screen_cols = CONSOLE_COLS; + break; +#endif + } + + di-type = type
Re: [U-Boot] [PATCH V3 4/4] api: export LCD and video to external apps
Hi Anatolij, I remove the support of video device from the patch set since I don't have a board with video output at hand for now. I will leave this to future work. Regards, Che-Liang On Wed, Oct 19, 2011 at 4:56 PM, Anatolij Gustschin ag...@denx.de wrote: Hi, On Tue, 18 Oct 2011 17:15:38 +0800 Che-Liang Chiou clch...@chromium.org wrote: ... +int display_get_info(int type, struct display_info *di) +{ +#if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE) + GraphicDevice *gdev; +#endif + + switch (type) { + default: + debug(%s: unsupport display device type: %d\n, + __FILE__, type); + return API_ENODEV; + +#ifdef CONFIG_LCD + case DISPLAY_TYPE_LCD: + di-pixel_width = panel_info.vl_col; + di-pixel_height = panel_info.vl_row; + di-screen_rows = CONSOLE_ROWS; + di-screen_cols = CONSOLE_COLS; + break; +#endif + +#if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE) + case DISPLAY_TYPE_VIDEO: + gdev = video_devinfo(); + di-pixel_width = gdev-winSizeX; + di-pixel_height = gdev-winSizeY; + di-screen_rows = CONSOLE_ROWS; + di-screen_cols = CONSOLE_COLS; the return value of video_devinfo() should be checked before dereferencing gdev pointer (it could be NULL). Another issue is that CONSOLE_ROWS and CONSOLE_COLS macros expand to 'panel_info' structure usage here which is only okay for CONFIG_LCD case. For CONFIG_VIDEO case these macros are defined in cfb_console.c file and thus can not be used here as you currently do (compile breakage again). ... + +void display_clear(void) +{ +#ifdef CONFIG_LCD + lcd_clear(); +#endif +#if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE) + video_clear(); video_clear() is used here but it is not defined. Below is a small patch included. It shows how video_clear() could look like (but this was not tested yet). Anatolij diff --git a/drivers/video/cfb_console.c b/drivers/video/cfb_console.c index 4e653b8..5336937 100644 --- a/drivers/video/cfb_console.c +++ b/drivers/video/cfb_console.c @@ -1753,6 +1753,23 @@ static int video_init(void) return 0; } +void video_clear(void) +{ +#ifdef VIDEO_HW_RECTFILL + video_hw_rectfill(VIDEO_PIXEL_SIZE, /* bytes per pixel */ + 0, /* dest pos x */ + 0, /* dest pos y */ + VIDEO_VISIBLE_COLS, /* frame width */ + VIDEO_VISIBLE_ROWS, /* frame height */ + CONSOLE_BG_COL /* fill color */ + ); +#else + memsetl(CONSOLE_ROW_FIRST, CONSOLE_SIZE 2, CONSOLE_BG_COL); +#endif + console_col = 0; + console_row = 0; +} + /* * Implement a weak default function for boards that optionally * need to skip the video initialization. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH V2 2/2] api: export LCD and video to external apps
Hi Anatolij, Thanks for testing this patch. Please see below. On Tue, Oct 18, 2011 at 5:13 AM, Anatolij Gustschin ag...@denx.de wrote: Hi, thanks for the patch and style fixes! I've some comments on it. Please see below. On Fri, 7 Oct 2011 16:28:12 +0800 Che-Liang Chiou clch...@chromium.org wrote: This patch exports LCD and video information and bitmap-rendering functions to external apps. This patch is tested on a Seaboard, which does not have a video output. So I only tested LCD code paths. NOTE: The Seaboard LCD driver is not yet upstreamed; the test was done in a local downstream repo. Many boards defining CONFIG_LCD also define CONFIG_LCD_LOGO. Enabling CONFIG_API for such board configurations will break compiling, e.g.: $ ./MAKEALL TQM823L_LCD Configuring for TQM823L_LCD - Board: TQM823L, Options: LCD,NEC_NL6448BC20 api_display.c: In function 'display_get_info': api_display.c:40: error: 'BMP_LOGO_HEIGHT' undeclared (first use in this function) api_display.c:40: error: (Each undeclared identifier is reported only once api_display.c:40: error: for each function it appears in.) make[1]: *** [api_display.o] Error 1 make: *** [api/libapi.o] Error 2 Any idea how to fix this issue? BMP_LOGO_HEIGHT is defined bmp_logo.h, which is automatically generated by tools/bmp_logo.c when CONFIG_LCD_LOGO or CONFIG_VIDEO_LOGO is set. So I guess this is quite easy to fix. We could include bmp_logo.h in api_display.c. Similar problem exists for boards using cfb_console driver, e.g. enabling CONFIG_API breaks compiling for tqm5200 board: $ ./MAKEALL TQM5200 Configuring for TQM5200 board... api_display.c: In function 'display_get_info': api_display.c:47: error: 'VIDEO_VISIBLE_COLS' undeclared (first use in this function) api_display.c:47: error: (Each undeclared identifier is reported only once api_display.c:47: error: for each function it appears in.) api_display.c:48: error: 'VIDEO_VISIBLE_ROWS' undeclared (first use in this function) make[1]: *** [api_display.o] Error 1 make: *** [api/libapi.o] Error 2 We need to resolve these issues before committing this patch, i think. VIDEO_VISIBLE_{COLS,ROLS} are just macros defined in cfb_console.c, this is my mistake. I should use GraphicDevice-{winSizeX,winSizeY} that are VIDEO_VISIBLE_{COLS,ROLS} defined upon. Thanks, Anatolij Signed-off-by: Che-Liang Chiou clch...@chromium.org --- Changes since V1 Fix style errors api/Makefile | 3 +- api/api.c | 51 + api/api_display.c | 86 ++ api/api_private.h | 4 ++ examples/api/demo.c | 31 ++ examples/api/glue.c | 31 ++ examples/api/glue.h | 5 +++ include/api_public.h | 16 + include/video_font.h | 6 +++ 9 files changed, 232 insertions(+), 1 deletions(-) create mode 100644 api/api_display.c Regards, Che-Liang ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH V2] examples: api: allow build with private libgcc
The examples/api is not configured with USE_PRIVATE_LIBGCC. This makes building examples/api break on certain boards that do not/cannot use the public libgcc. Nevertheless, this patch has to also touch the top-level Makefile to fix this problem because the current top-level Makefile does not specify libgcc as a prerequisite of examples/api, and explicitly builds examples/api _before_ libgcc. For testing this patch, I added the following to configs/seaboard.h and ran demo.bin on a Seaboard. +#define CONFIG_API +#define CONFIG_SYS_MMC_MAX_DEVICE 2 +#define CONFIG_CMD_NET +#define CONFIG_NET_MULTI Signed-off-by: Che-Liang Chiou clch...@chromium.org Acked-by: Mike Frysinger vap...@gentoo.org --- Changes in V2 Rebase to ToT Makefile | 18 +- examples/api/Makefile |4 +--- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index e9d75f8..26956ae 100644 --- a/Makefile +++ b/Makefile @@ -141,7 +141,10 @@ unexport CDPATH # is yes), so compile examples after U-Boot is compiled. SUBDIR_TOOLS = tools SUBDIR_EXAMPLES = examples/standalone examples/api -SUBDIRS = $(SUBDIR_TOOLS) $(SUBDIR_EXAMPLES) +SUBDIRS = $(SUBDIR_TOOLS) +ifndef CONFIG_SANDBOX +SUBDIRS += $(SUBDIR_EXAMPLES) +endif .PHONY : $(SUBDIRS) $(VERSION_FILE) $(TIMESTAMP_FILE) @@ -158,11 +161,6 @@ sinclude $(obj)include/autoconf.mk include $(obj)include/config.mk export ARCH CPU BOARD VENDOR SOC -ifndef CONFIG_SANDBOX -SUBDIRS += examples/standalone \ - examples/api -endif - # set default to nothing for native builds ifeq ($(HOSTARCH),$(ARCH)) CROSS_COMPILE ?= @@ -359,7 +357,7 @@ ONENAND_BIN ?= $(obj)onenand_ipl/onenand-ipl-2k.bin ALL-$(CONFIG_MMC_U_BOOT) += $(obj)mmc_spl/u-boot-mmc-spl.bin ALL-$(CONFIG_SPL) += $(obj)spl/u-boot-spl.bin -all: $(ALL-y) +all: $(ALL-y) $(SUBDIR_EXAMPLES) $(obj)u-boot.hex: $(obj)u-boot $(OBJCOPY) ${OBJCFLAGS} -O ihex $ $@ @@ -422,7 +420,7 @@ GEN_UBOOT = \ endif $(obj)u-boot: depend \ - $(SUBDIRS) $(OBJS) $(LIBBOARD) $(LIBS) $(LDSCRIPT) $(obj)u-boot.lds + $(SUBDIR_TOOLS) $(OBJS) $(LIBBOARD) $(LIBS) $(LDSCRIPT) $(obj)u-boot.lds $(GEN_UBOOT) ifeq ($(CONFIG_KALLSYMS),y) smap=`$(call SYSTEM_MAP,u-boot) | \ @@ -435,7 +433,7 @@ endif $(OBJS): depend $(MAKE) -C $(CPUDIR) $(if $(REMOTE_BUILD),$@,$(notdir $@)) -$(LIBS): depend $(SUBDIRS) +$(LIBS): depend $(SUBDIR_TOOLS) $(MAKE) -C $(dir $(subst $(obj),,$@)) $(LIBBOARD): depend $(LIBS) @@ -444,6 +442,8 @@ $(LIBBOARD):depend $(LIBS) $(SUBDIRS):depend $(MAKE) -C $@ all +$(SUBDIR_EXAMPLES): $(obj)u-boot + $(LDSCRIPT): depend $(MAKE) -C $(dir $@) $(notdir $@) diff --git a/examples/api/Makefile b/examples/api/Makefile index 5b5f7a6..bad05af 100644 --- a/examples/api/Makefile +++ b/examples/api/Makefile @@ -62,8 +62,6 @@ OBJS += $(addprefix $(obj),$(COBJ_FILES-y)) OBJS += $(addprefix $(obj),$(notdir $(EXT_COBJ_FILES-y))) OBJS += $(addprefix $(obj),$(notdir $(EXT_SOBJ_FILES-y))) -gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`) - CPPFLAGS += -I.. all: $(obj).depend $(OUTPUT) @@ -71,7 +69,7 @@ all: $(obj).depend $(OUTPUT) # $(OUTPUT): $(OBJS) - $(LD) -Ttext $(LOAD_ADDR) -o $@ $^ -L$(gcclibdir) -lgcc + $(LD) -Ttext $(LOAD_ADDR) -o $@ $^ $(PLATFORM_LIBS) $(OBJCOPY) -O binary $@ $(OUTPUT).bin 2/dev/null # Rule to build generic library C files -- 1.7.3.1 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH V2] examples: api: allow build with private libgcc
The examples/api is not configured with USE_PRIVATE_LIBGCC. This makes building examples/api break on certain boards that do not/cannot use the public libgcc. Nevertheless, this patch has to also touch the top-level Makefile to fix this problem because the current top-level Makefile does not specify libgcc as a prerequisite of examples/api, and explicitly builds examples/api _before_ libgcc. For testing this patch, I added the following to configs/seaboard.h and ran demo.bin on a Seaboard. +#define CONFIG_API +#define CONFIG_SYS_MMC_MAX_DEVICE 2 +#define CONFIG_CMD_NET +#define CONFIG_NET_MULTI Signed-off-by: Che-Liang Chiou clch...@chromium.org Acked-by: Mike Frysinger vap...@gentoo.org --- Sorry, please ignore the previous V2 patch. I missed to git-add a couple of lines to that patch. Changes in V2 Rebase to ToT Makefile | 22 +- examples/api/Makefile |4 +--- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index e9a153c..26956ae 100644 --- a/Makefile +++ b/Makefile @@ -137,7 +137,14 @@ unexport CDPATH # The tools are needed early, so put this first # Don't include stuff already done in $(LIBS) -SUBDIRS= tools +# The examples conditionally depend on U-Boot (say, when USE_PRIVATE_LIBGCC +# is yes), so compile examples after U-Boot is compiled. +SUBDIR_TOOLS = tools +SUBDIR_EXAMPLES = examples/standalone examples/api +SUBDIRS = $(SUBDIR_TOOLS) +ifndef CONFIG_SANDBOX +SUBDIRS += $(SUBDIR_EXAMPLES) +endif .PHONY : $(SUBDIRS) $(VERSION_FILE) $(TIMESTAMP_FILE) @@ -154,11 +161,6 @@ sinclude $(obj)include/autoconf.mk include $(obj)include/config.mk export ARCH CPU BOARD VENDOR SOC -ifndef CONFIG_SANDBOX -SUBDIRS += examples/standalone \ - examples/api -endif - # set default to nothing for native builds ifeq ($(HOSTARCH),$(ARCH)) CROSS_COMPILE ?= @@ -355,7 +357,7 @@ ONENAND_BIN ?= $(obj)onenand_ipl/onenand-ipl-2k.bin ALL-$(CONFIG_MMC_U_BOOT) += $(obj)mmc_spl/u-boot-mmc-spl.bin ALL-$(CONFIG_SPL) += $(obj)spl/u-boot-spl.bin -all: $(ALL-y) +all: $(ALL-y) $(SUBDIR_EXAMPLES) $(obj)u-boot.hex: $(obj)u-boot $(OBJCOPY) ${OBJCFLAGS} -O ihex $ $@ @@ -418,7 +420,7 @@ GEN_UBOOT = \ endif $(obj)u-boot: depend \ - $(SUBDIRS) $(OBJS) $(LIBBOARD) $(LIBS) $(LDSCRIPT) $(obj)u-boot.lds + $(SUBDIR_TOOLS) $(OBJS) $(LIBBOARD) $(LIBS) $(LDSCRIPT) $(obj)u-boot.lds $(GEN_UBOOT) ifeq ($(CONFIG_KALLSYMS),y) smap=`$(call SYSTEM_MAP,u-boot) | \ @@ -431,7 +433,7 @@ endif $(OBJS): depend $(MAKE) -C $(CPUDIR) $(if $(REMOTE_BUILD),$@,$(notdir $@)) -$(LIBS): depend $(SUBDIRS) +$(LIBS): depend $(SUBDIR_TOOLS) $(MAKE) -C $(dir $(subst $(obj),,$@)) $(LIBBOARD): depend $(LIBS) @@ -440,6 +442,8 @@ $(LIBBOARD):depend $(LIBS) $(SUBDIRS):depend $(MAKE) -C $@ all +$(SUBDIR_EXAMPLES): $(obj)u-boot + $(LDSCRIPT): depend $(MAKE) -C $(dir $@) $(notdir $@) diff --git a/examples/api/Makefile b/examples/api/Makefile index 5b5f7a6..bad05af 100644 --- a/examples/api/Makefile +++ b/examples/api/Makefile @@ -62,8 +62,6 @@ OBJS += $(addprefix $(obj),$(COBJ_FILES-y)) OBJS += $(addprefix $(obj),$(notdir $(EXT_COBJ_FILES-y))) OBJS += $(addprefix $(obj),$(notdir $(EXT_SOBJ_FILES-y))) -gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`) - CPPFLAGS += -I.. all: $(obj).depend $(OUTPUT) @@ -71,7 +69,7 @@ all: $(obj).depend $(OUTPUT) # $(OUTPUT): $(OBJS) - $(LD) -Ttext $(LOAD_ADDR) -o $@ $^ -L$(gcclibdir) -lgcc + $(LD) -Ttext $(LOAD_ADDR) -o $@ $^ $(PLATFORM_LIBS) $(OBJCOPY) -O binary $@ $(OUTPUT).bin 2/dev/null # Rule to build generic library C files -- 1.7.3.1 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH V2 2/2] api: export LCD and video to external apps
Hi Anatolij, On Tue, Oct 18, 2011 at 3:17 PM, Anatolij Gustschin ag...@denx.de wrote: Hi, On Tue, 18 Oct 2011 14:12:59 +0800 Che-liang Chiou clch...@chromium.org wrote: ... Many boards defining CONFIG_LCD also define CONFIG_LCD_LOGO. Enabling CONFIG_API for such board configurations will break compiling, e.g.: $ ./MAKEALL TQM823L_LCD Configuring for TQM823L_LCD - Board: TQM823L, Options: LCD,NEC_NL6448BC20 api_display.c: In function 'display_get_info': api_display.c:40: error: 'BMP_LOGO_HEIGHT' undeclared (first use in this function) api_display.c:40: error: (Each undeclared identifier is reported only once api_display.c:40: error: for each function it appears in.) make[1]: *** [api_display.o] Error 1 make: *** [api/libapi.o] Error 2 Any idea how to fix this issue? BMP_LOGO_HEIGHT is defined bmp_logo.h, which is automatically generated by tools/bmp_logo.c when CONFIG_LCD_LOGO or CONFIG_VIDEO_LOGO is set. So I guess this is quite easy to fix. We could include bmp_logo.h in api_display.c. This won't work I'm afraid. bmp_logo.h is included elsewhere an including it in libapi will cause multiple definition of `bmp_logo_bitmap' and `bmp_logo_palette' compile errors. Thanks, Anatolij I was planning to add a 'static __attribute__((unused))' to it to avoid this problem. What do you think? Regards, Che-Liang ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH V3 0/4] api: export LCD and video to external apps
This patch set exports LCD and video clearing and bitmap-rendering on screen functions to external apps, and provides a unified interface of accessing them. Che-Liang Chiou (4): lcd: video: add clear and draw bitmap declaration tools: logo: add static and unused to bmp arrays video: add access to GraphicDevice struct api: export LCD and video to external apps api/Makefile |3 +- api/api.c | 51 + api/api_display.c | 97 + api/api_private.h |4 ++ board/eltec/mhpc/mhpc.c |7 +++ common/lcd.c | 16 --- drivers/video/ati_radeon_fb.c |5 ++ drivers/video/ct69000.c |5 ++ drivers/video/fsl_diu_fb.c|8 +++- drivers/video/mb862xx.c |5 ++ drivers/video/mb86r0xgdc.c|5 ++ drivers/video/mx3fb.c |5 ++ drivers/video/mxc_ipuv3_fb.c |5 ++ drivers/video/sed13806.c |6 +++ drivers/video/sm501.c |5 ++ drivers/video/smiLynxEM.c |5 ++ examples/api/demo.c | 31 + examples/api/glue.c | 31 + examples/api/glue.h |5 ++ include/api_public.h | 16 +++ include/lcd.h |2 + include/video.h |2 + include/video_fb.h|6 ++- include/video_font.h |6 +++ tools/bmp_logo.c |6 ++- 25 files changed, 326 insertions(+), 11 deletions(-) create mode 100644 api/api_display.c -- 1.7.3.1 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH V3 1/4] lcd: video: add clear and draw bitmap declaration
The functions for clearing and drawing bitmaps on the screen were not exposed publicly and are made public in this patch in preparation for implementing the display interface of api_public.h. Signed-off-by: Che-Liang Chiou clch...@chromium.org --- Changes in V3 Rebase to ToT Changes in V2 Fix style errors common/lcd.c| 16 ++-- include/lcd.h |2 ++ include/video.h |2 ++ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/common/lcd.c b/common/lcd.c index d9cb8ca..20e97b9 100644 --- a/common/lcd.c +++ b/common/lcd.c @@ -78,7 +78,6 @@ static inline void lcd_putc_xy (ushort x, ushort y, uchar c); static int lcd_init (void *lcdbase); -static int lcd_clear (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]); static void *lcd_logo (void); static int lcd_getbgcolor (void); @@ -353,7 +352,14 @@ int drv_lcd_init (void) } /*--*/ -static int lcd_clear (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) +static +int do_lcd_clear(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) +{ + lcd_clear(); + return 0; +} + +void lcd_clear(void) { #if LCD_BPP == LCD_MONOCHROME /* Setting the palette */ @@ -394,12 +400,10 @@ static int lcd_clear (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[] console_col = 0; console_row = 0; - - return (0); } U_BOOT_CMD( - cls,1, 1, lcd_clear, + cls,1, 1, do_lcd_clear, clear screen, ); @@ -413,7 +417,7 @@ static int lcd_init (void *lcdbase) lcd_ctrl_init (lcdbase); lcd_is_enabled = 1; - lcd_clear (NULL, 1, 1, NULL); /* dummy args */ + lcd_clear(); lcd_enable (); /* Initialize the console */ diff --git a/include/lcd.h b/include/lcd.h index 0e098d9..39af14a 100644 --- a/include/lcd.h +++ b/include/lcd.h @@ -210,6 +210,8 @@ voidlcd_disable (void); void lcd_putc(const char c); void lcd_puts(const char *s); void lcd_printf (const char *fmt, ...); +void lcd_clear(void); +intlcd_display_bitmap(ulong bmp_image, int x, int y); /* Allow boards to customize the information displayed */ void lcd_show_board_info(void); diff --git a/include/video.h b/include/video.h index efcc682..280bb76 100644 --- a/include/video.h +++ b/include/video.h @@ -15,5 +15,7 @@ int video_init (void *videobase); void video_putc (const char c); void video_puts (const char *s); void video_printf(const char *fmt, ...); +void video_clear(void); +intvideo_display_bitmap(ulong bmp_image, int x, int y); #endif -- 1.7.3.1 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH V3 2/4] tools: logo: add static and unused to bmp arrays
The generated header bmp_logo.h is useful even outside common/lcd.c for the logo dimension. However, the problem is, the generated bmp_logo.h cannot be included multiple times because bmp_logo_palette[] and bmp_logo_bitmap[] are defined in the bmp_logo.h. We may remedy this by adding static __attribute__((unused)) to the array definitions so that bmp_logo.h can be included multiple times, and these arrays is used in only one inclusion (lcd.c). Signed-off-by: Che-Liang Chiou clch...@chromium.org --- Changes in V3 Add to the patch set tools/bmp_logo.c |6 -- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/bmp_logo.c b/tools/bmp_logo.c index 47228d2..3d11284 100644 --- a/tools/bmp_logo.c +++ b/tools/bmp_logo.c @@ -113,7 +113,8 @@ int main (int argc, char *argv[]) error (Error allocating memory for file, fp); /* read and print the palette information */ - printf (unsigned short bmp_logo_palette[] = {\n); + printf(static __attribute__((unused)) + unsigned short bmp_logo_palette[] = {\n); for (i=0; in_colors; ++i) { b-palette[(int)(i*3+2)] = fgetc(fp); @@ -137,7 +138,8 @@ int main (int argc, char *argv[]) printf (\n); printf (};\n); printf (\n); - printf (unsigned char bmp_logo_bitmap[] = {\n); + printf(static __attribute__((unused)) + unsigned char bmp_logo_bitmap[] = {\n); for (i=(b-height-1)*b-width; i=0; i-=b-width) { for (x = 0; x b-width; x++) { b-data[(uint16_t) i + x] = (uint8_t) fgetc (fp) \ -- 1.7.3.1 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH V3 3/4] video: add access to GraphicDevice struct
video_hw_init() returns this struct, which is quite useful, but it is probably not okay to call this function multiple times. So this patch adds video_devinfo() that does nothing but return this struct. video_devinfo() does not guarantee that this struct is initialized. It is user's responsibility to make sure that the video device is properly initialized. Signed-off-by: Che-Liang Chiou clch...@chromium.org --- Changes in V3 Add to the patch set board/eltec/mhpc/mhpc.c |7 +++ drivers/video/ati_radeon_fb.c |5 + drivers/video/ct69000.c |5 + drivers/video/fsl_diu_fb.c|8 +++- drivers/video/mb862xx.c |5 + drivers/video/mb86r0xgdc.c|5 + drivers/video/mx3fb.c |5 + drivers/video/mxc_ipuv3_fb.c |5 + drivers/video/sed13806.c |6 ++ drivers/video/sm501.c |5 + drivers/video/smiLynxEM.c |5 + include/video_fb.h|6 +- 12 files changed, 65 insertions(+), 2 deletions(-) diff --git a/board/eltec/mhpc/mhpc.c b/board/eltec/mhpc/mhpc.c index 7cca6b2..0d2c8c9 100644 --- a/board/eltec/mhpc/mhpc.c +++ b/board/eltec/mhpc/mhpc.c @@ -466,6 +466,13 @@ void *video_hw_init (void) /* - */ +void *video_devinfo(void) +{ + return (void *)gdev; +} + +/* - */ + void video_set_lut (unsigned int index, unsigned char r, unsigned char g, unsigned char b) { diff --git a/drivers/video/ati_radeon_fb.c b/drivers/video/ati_radeon_fb.c index 4a9bd07..77509e1 100644 --- a/drivers/video/ati_radeon_fb.c +++ b/drivers/video/ati_radeon_fb.c @@ -770,6 +770,11 @@ void *video_hw_init(void) return ((void *) pGD); } +void *video_devinfo(void) +{ + return (void *)ctfb; +} + void video_set_lut (unsigned int index,/* color number */ unsigned char r, /* red */ unsigned char g, /* green */ diff --git a/drivers/video/ct69000.c b/drivers/video/ct69000.c index 3db614d..660a64c 100644 --- a/drivers/video/ct69000.c +++ b/drivers/video/ct69000.c @@ -1176,6 +1176,11 @@ video_hw_init (void) return ((void *) ctfb); } +void *video_devinfo(void) +{ + return (void *)ctfb; +} + /*** * * Set a RGB color in the LUT (8 bit index) diff --git a/drivers/video/fsl_diu_fb.c b/drivers/video/fsl_diu_fb.c index cb43904..6ed6c32 100644 --- a/drivers/video/fsl_diu_fb.c +++ b/drivers/video/fsl_diu_fb.c @@ -367,9 +367,10 @@ int fsl_diu_init(u16 xres, u16 yres, u32 pixel_format, int gamma_fix) return 0; } +static GraphicDevice ctfb; + void *video_hw_init(void) { - static GraphicDevice ctfb; const char *options; unsigned int depth = 0, freq = 0; @@ -408,3 +409,8 @@ void *video_hw_init(void) return ctfb; } + +void *video_devinfo(void) +{ + return (void *)ctfb; +} diff --git a/drivers/video/mb862xx.c b/drivers/video/mb862xx.c index 1a4ba82..36dbdc1 100644 --- a/drivers/video/mb862xx.c +++ b/drivers/video/mb862xx.c @@ -444,6 +444,11 @@ void *video_hw_init (void) return dev; } +void *video_devinfo(void) +{ + return (void *)mb862xx; +} + /* * Set a RGB color in the LUT */ diff --git a/drivers/video/mb86r0xgdc.c b/drivers/video/mb86r0xgdc.c index 345a73b..455aea3 100644 --- a/drivers/video/mb86r0xgdc.c +++ b/drivers/video/mb86r0xgdc.c @@ -182,3 +182,8 @@ void *video_hw_init(void) return pGD; } + +void *video_devinfo(void) +{ + return (void *)mb86r0x; +} diff --git a/drivers/video/mx3fb.c b/drivers/video/mx3fb.c index f30deb3..4ff84c8 100644 --- a/drivers/video/mx3fb.c +++ b/drivers/video/mx3fb.c @@ -922,6 +922,11 @@ void *video_hw_init(void) return (void *) panel; } +void *video_devinfo(void) +{ + return (void *)panel; +} + void video_set_lut(unsigned int index, /* color number */ unsigned char r,/* red */ unsigned char g,/* green */ diff --git a/drivers/video/mxc_ipuv3_fb.c b/drivers/video/mxc_ipuv3_fb.c index 1bee54c..fd27828 100644 --- a/drivers/video/mxc_ipuv3_fb.c +++ b/drivers/video/mxc_ipuv3_fb.c @@ -590,6 +590,11 @@ void *video_hw_init(void) return (void *)panel; } +void *video_devinfo(void) +{ + return (void *)panel; +} + void video_set_lut(unsigned int index, /* color number */ unsigned char r,/* red */ unsigned char g,/* green */ diff --git a/drivers/video/sed13806.c b/drivers/video/sed13806.c index 0bf9ba6..ee7b9b9 100644 --- a/drivers/video/sed13806.c +++ b/drivers/video/sed13806.c @@ -108,6 +108,12 @@ void *video_hw_init (void) return (sed13806); } + +void *video_devinfo(void) +{ + return (void *)sed13806
[U-Boot] [PATCH V3 4/4] api: export LCD and video to external apps
This patch exports LCD and video information and bitmap-rendering functions to external apps. This patch is tested on a Seaboard, which does not have a video output. So I only tested LCD code paths. NOTE: The Seaboard LCD driver is not yet upstreamed; the test was done in a local downstream repo. Signed-off-by: Che-Liang Chiou clch...@chromium.org --- Changes in V3 Rebase to ToT Changes in V2 Fix style errors api/Makefile |3 +- api/api.c| 51 ++ api/api_display.c| 97 ++ api/api_private.h|4 ++ examples/api/demo.c | 31 examples/api/glue.c | 31 examples/api/glue.h |5 +++ include/api_public.h | 16 include/video_font.h |6 +++ 9 files changed, 243 insertions(+), 1 deletions(-) create mode 100644 api/api_display.c diff --git a/api/Makefile b/api/Makefile index 2a64c4d..0e99f74 100644 --- a/api/Makefile +++ b/api/Makefile @@ -24,7 +24,8 @@ include $(TOPDIR)/config.mk LIB= $(obj)libapi.o -COBJS-$(CONFIG_API) += api.o api_net.o api_storage.o api_platform-$(ARCH).o +COBJS-$(CONFIG_API) += api.o api_display.o api_net.o api_storage.o \ + api_platform-$(ARCH).o COBJS := $(COBJS-y) SRCS := $(COBJS:.o=.c) diff --git a/api/api.c b/api/api.c index 853f010..ddf2edd 100644 --- a/api/api.c +++ b/api/api.c @@ -553,6 +553,54 @@ static int API_env_enum(va_list ap) return 0; } +/* + * pseudo signature: + * + * int API_display_get_info(int type, struct display_info *di) + */ +static int API_display_get_info(va_list ap) +{ + int type; + struct display_info *di; + + type = (int)va_arg(ap, u_int32_t); + di = (struct display_info *)va_arg(ap, u_int32_t); + if (!di) + return API_EINVAL; + + return display_get_info(type, di); +} + +/* + * pseudo signature: + * + * int API_display_draw_bitmap(void *bitmap, int x, int y) + */ +static int API_display_draw_bitmap(va_list ap) +{ + ulong bitmap; + int x, y; + + bitmap = (ulong)va_arg(ap, ulong); + if (!bitmap) + return API_EINVAL; + x = (int)va_arg(ap, u_int32_t); + y = (int)va_arg(ap, u_int32_t); + + return display_draw_bitmap(bitmap, x, y); +} + +/* + * pseudo signature: + * + * void API_display_clear(void) + */ +static int API_display_clear(va_list ap) +{ + display_clear(); + return 0; +} + static cfp_t calls_table[API_MAXCALL] = { NULL, }; /* @@ -616,6 +664,9 @@ void api_init(void) calls_table[API_ENV_GET] = API_env_get; calls_table[API_ENV_SET] = API_env_set; calls_table[API_ENV_ENUM] = API_env_enum; + calls_table[API_DISPLAY_GET_INFO] = API_display_get_info; + calls_table[API_DISPLAY_DRAW_BITMAP] = API_display_draw_bitmap; + calls_table[API_DISPLAY_CLEAR] = API_display_clear; calls_no = API_MAXCALL; debugf(API initialized with %d calls\n, calls_no); diff --git a/api/api_display.c b/api/api_display.c new file mode 100644 index 000..b162f7f --- /dev/null +++ b/api/api_display.c @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2011 The Chromium OS Authors. + * See file CREDITS for list of people who contributed to this + * project. + * + * 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., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include common.h +#include lcd.h +#include video.h +#include video_fb.h +#include video_font.h /* Get font width and height */ +#include api_public.h + +/* lcd.h needs BMP_LOGO_HEIGHT to calculate CONSOLE_ROWS */ +#if defined(CONFIG_LCD_LOGO) !defined(CONFIG_LCD_INFO_BELOW_LOGO) +#include bmp_logo.h +#endif + +int display_get_info(int type, struct display_info *di) +{ +#if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE) + GraphicDevice *gdev; +#endif + + switch (type) { + default: + debug(%s: unsupport display device type: %d\n, + __FILE__, type); + return API_ENODEV; + +#ifdef CONFIG_LCD + case DISPLAY_TYPE_LCD: + di-pixel_width = panel_info.vl_col; + di-pixel_height = panel_info.vl_row; + di-screen_rows = CONSOLE_ROWS; + di-screen_cols = CONSOLE_COLS; + break; +#endif
[U-Boot] [PATCH V2 0/2] api: export LCD and video to external apps
This patch set exports LCD and video clearing and bitmap-rendering on screen functions to external apps, and provides a unified interface of accessing them. Che-Liang Chiou (2): lcd: video: add clear and draw bitmap declaration api: export LCD and video to external apps api/Makefile |3 +- api/api.c| 51 + api/api_display.c| 86 ++ api/api_private.h|4 ++ common/lcd.c | 16 ++--- examples/api/demo.c | 31 ++ examples/api/glue.c | 31 ++ examples/api/glue.h |5 +++ include/api_public.h | 16 + include/lcd.h|2 + include/video.h |2 + include/video_font.h |6 +++ 12 files changed, 246 insertions(+), 7 deletions(-) create mode 100644 api/api_display.c -- 1.7.3.1 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH V2 1/2] lcd: video: add clear and draw bitmap declaration
The functions for clearing and drawing bitmaps on the screen were not exposed publicly and are made public in this patch in preparation for implementing the display interface of api_public.h. Signed-off-by: Che-Liang Chiou clch...@chromium.org --- Changes since V1 Fix style errors common/lcd.c| 16 ++-- include/lcd.h |2 ++ include/video.h |2 ++ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/common/lcd.c b/common/lcd.c index d9cb8ca..20e97b9 100644 --- a/common/lcd.c +++ b/common/lcd.c @@ -78,7 +78,6 @@ static inline void lcd_putc_xy (ushort x, ushort y, uchar c); static int lcd_init (void *lcdbase); -static int lcd_clear (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]); static void *lcd_logo (void); static int lcd_getbgcolor (void); @@ -353,7 +352,14 @@ int drv_lcd_init (void) } /*--*/ -static int lcd_clear (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) +static +int do_lcd_clear(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) +{ + lcd_clear(); + return 0; +} + +void lcd_clear(void) { #if LCD_BPP == LCD_MONOCHROME /* Setting the palette */ @@ -394,12 +400,10 @@ static int lcd_clear (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[] console_col = 0; console_row = 0; - - return (0); } U_BOOT_CMD( - cls,1, 1, lcd_clear, + cls,1, 1, do_lcd_clear, clear screen, ); @@ -413,7 +417,7 @@ static int lcd_init (void *lcdbase) lcd_ctrl_init (lcdbase); lcd_is_enabled = 1; - lcd_clear (NULL, 1, 1, NULL); /* dummy args */ + lcd_clear(); lcd_enable (); /* Initialize the console */ diff --git a/include/lcd.h b/include/lcd.h index 0e098d9..39af14a 100644 --- a/include/lcd.h +++ b/include/lcd.h @@ -210,6 +210,8 @@ voidlcd_disable (void); void lcd_putc(const char c); void lcd_puts(const char *s); void lcd_printf (const char *fmt, ...); +void lcd_clear(void); +intlcd_display_bitmap(ulong bmp_image, int x, int y); /* Allow boards to customize the information displayed */ void lcd_show_board_info(void); diff --git a/include/video.h b/include/video.h index efcc682..280bb76 100644 --- a/include/video.h +++ b/include/video.h @@ -15,5 +15,7 @@ int video_init (void *videobase); void video_putc (const char c); void video_puts (const char *s); void video_printf(const char *fmt, ...); +void video_clear(void); +intvideo_display_bitmap(ulong bmp_image, int x, int y); #endif -- 1.7.3.1 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH V2 2/2] api: export LCD and video to external apps
This patch exports LCD and video information and bitmap-rendering functions to external apps. This patch is tested on a Seaboard, which does not have a video output. So I only tested LCD code paths. NOTE: The Seaboard LCD driver is not yet upstreamed; the test was done in a local downstream repo. Signed-off-by: Che-Liang Chiou clch...@chromium.org --- Changes since V1 Fix style errors api/Makefile |3 +- api/api.c| 51 + api/api_display.c| 86 ++ api/api_private.h|4 ++ examples/api/demo.c | 31 ++ examples/api/glue.c | 31 ++ examples/api/glue.h |5 +++ include/api_public.h | 16 + include/video_font.h |6 +++ 9 files changed, 232 insertions(+), 1 deletions(-) create mode 100644 api/api_display.c diff --git a/api/Makefile b/api/Makefile index 2a64c4d..0e99f74 100644 --- a/api/Makefile +++ b/api/Makefile @@ -24,7 +24,8 @@ include $(TOPDIR)/config.mk LIB= $(obj)libapi.o -COBJS-$(CONFIG_API) += api.o api_net.o api_storage.o api_platform-$(ARCH).o +COBJS-$(CONFIG_API) += api.o api_display.o api_net.o api_storage.o \ + api_platform-$(ARCH).o COBJS := $(COBJS-y) SRCS := $(COBJS:.o=.c) diff --git a/api/api.c b/api/api.c index 853f010..ddf2edd 100644 --- a/api/api.c +++ b/api/api.c @@ -553,6 +553,54 @@ static int API_env_enum(va_list ap) return 0; } +/* + * pseudo signature: + * + * int API_display_get_info(int type, struct display_info *di) + */ +static int API_display_get_info(va_list ap) +{ + int type; + struct display_info *di; + + type = (int)va_arg(ap, u_int32_t); + di = (struct display_info *)va_arg(ap, u_int32_t); + if (!di) + return API_EINVAL; + + return display_get_info(type, di); +} + +/* + * pseudo signature: + * + * int API_display_draw_bitmap(void *bitmap, int x, int y) + */ +static int API_display_draw_bitmap(va_list ap) +{ + ulong bitmap; + int x, y; + + bitmap = (ulong)va_arg(ap, ulong); + if (!bitmap) + return API_EINVAL; + x = (int)va_arg(ap, u_int32_t); + y = (int)va_arg(ap, u_int32_t); + + return display_draw_bitmap(bitmap, x, y); +} + +/* + * pseudo signature: + * + * void API_display_clear(void) + */ +static int API_display_clear(va_list ap) +{ + display_clear(); + return 0; +} + static cfp_t calls_table[API_MAXCALL] = { NULL, }; /* @@ -616,6 +664,9 @@ void api_init(void) calls_table[API_ENV_GET] = API_env_get; calls_table[API_ENV_SET] = API_env_set; calls_table[API_ENV_ENUM] = API_env_enum; + calls_table[API_DISPLAY_GET_INFO] = API_display_get_info; + calls_table[API_DISPLAY_DRAW_BITMAP] = API_display_draw_bitmap; + calls_table[API_DISPLAY_CLEAR] = API_display_clear; calls_no = API_MAXCALL; debugf(API initialized with %d calls\n, calls_no); diff --git a/api/api_display.c b/api/api_display.c new file mode 100644 index 000..4746d20 --- /dev/null +++ b/api/api_display.c @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2011 The Chromium OS Authors. + * See file CREDITS for list of people who contributed to this + * project. + * + * 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., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include common.h +#include lcd.h +#include video.h +#include video_font.h /* Get font width and height */ +#include api_public.h + +int display_get_info(int type, struct display_info *di) +{ + switch (type) { + default: + debug(%s: unsupport display device type: %d\n, + __FILE__, type); + return API_ENODEV; + +#ifdef CONFIG_LCD + case DISPLAY_TYPE_LCD: + di-pixel_width = panel_info.vl_col; + di-pixel_height = panel_info.vl_row; + di-screen_rows = CONSOLE_ROWS; + di-screen_cols = CONSOLE_COLS; + break; +#endif + +#if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE) + case DISPLAY_TYPE_VIDEO: + di-pixel_width = VIDEO_VISIBLE_COLS; + di-pixel_height = VIDEO_VISIBLE_ROWS; + di-screen_rows = CONSOLE_ROWS; + di-screen_cols = CONSOLE_COLS
Re: [U-Boot] [PATCH 2/2] api: export LCD and video to external apps
Dear Wolfgang Denk, On Fri, Oct 7, 2011 at 2:33 AM, Wolfgang Denk w...@denx.de wrote: Dear Che-Liang Chiou, In message ce61e361e4b8456b9e0584a72f37d2e278ff2ab1.1317715598.git.clch...@chromium.org you wrote: This patch exports LCD and video information and bitmap-rendering functions to external apps. This patch is tested on a Seaboard, which does not have a video output. So I only tested LCD code paths. NOTE: The Seaboard LCD driver is not yet upstreamed; the test was done in a local downstream repo. ... + switch (type) { + default: + debug(%s: unsupport display device type: %d\n, __FILE__, type); Line too long. + +#ifdef CONFIG_LCD + case DISPLAY_TYPE_LCD: + di-pixel_width = panel_info.vl_col; + di-pixel_height = panel_info.vl_row; + di-screen_rows = CONSOLE_ROWS; + di-screen_cols = CONSOLE_COLS; + break; +#endif + +#if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE) + case DISPLAY_TYPE_VIDEO: + di-pixel_width = VIDEO_VISIBLE_COLS; + di-pixel_height = VIDEO_VISIBLE_ROWS; + di-screen_rows = CONSOLE_ROWS; + di-screen_cols = CONSOLE_COLS; + break; +#endif + } + + di-type = type; + return 0; +} + +int display_draw_bitmap(ulong bitmap, int x, int y) +{ + int err = 0; + + /* + * Although CONFIG_LCD and CONFIG_VIDEO or CONFIG_CFB_CONSOLE + * generally should not be both set, if this does happen, I think + * drawing on both of them makes more sense. + */ +#ifdef CONFIG_LCD + err |= lcd_display_bitmap(bitmap, x, y); +#endif +#if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE) + err |= video_display_bitmap(bitmap, x, y); +#endif + + return err; +} + +void display_clear(void) +{ +#ifdef CONFIG_LCD + lcd_clear(); +#endif +#if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE) + video_clear(); +#endif +} diff --git a/api/api_private.h b/api/api_private.h index 94a7fc5..988f702 100644 --- a/api/api_private.h +++ b/api/api_private.h @@ -45,4 +45,8 @@ int dev_write_net(void *, void *, int); void dev_stor_init(void); +int display_get_info(int type, struct display_info *di); +int display_draw_bitmap(ulong bitmap, int x, int y); +void display_clear(void); + #endif /* _API_PRIVATE_H_ */ diff --git a/examples/api/demo.c b/examples/api/demo.c index 65e7491..191bd79 100644 --- a/examples/api/demo.c +++ b/examples/api/demo.c @@ -176,6 +176,34 @@ int main(int argc, char * const argv[]) while ((env = ub_env_enum(env)) != NULL) printf(%s = %s\n, env, ub_env_get(env)); + printf(\n*** Display ***\n); + + struct display_info disinfo; Please don't mix declarations and code. + if (ub_display_get_info(DISPLAY_TYPE_LCD, disinfo)) + printf(LCD info: failed\n); + else { Use braces in both branches. Please fix globally. + /* this only clears messages on screen, not on serial port */ + ub_display_clear(); What happens here if no display is available? It is equivalent to a no-op. Or do you think we should print a warning message if no display is available? Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de Randal said it would be tough to do in sed. He didn't say he didn't understand sed. Randal understands sed quite well. Which is why he uses Perl. :-) - Larry Wall in 7...@jpl-devvax.jpl.nasa.gov Regards, Che-Liang ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH V3] cmd_time: add time command
The 'time' command runs and reports execution time of commands. Sample usage: u-boot# time crc 0x1000 1000 CRC32 for 1000 ... 1fff == ae94dc4b time: 0.004 seconds, 4 ticks Signed-off-by: Che-Liang Chiou clch...@chromium.org --- Changes since V2 - Remove CONFIG_CMD_TIME from config_cmd_all.h Changes Since V1 - Switch unsigned long int to ulong to match function prototype - Remove unnecessary 'ifdef CONFIG_SYS_HZ' guard - Factor out codes into the run_command_and_time_it() function README|1 + common/Makefile |1 + common/cmd_time.c | 90 + 3 files changed, 92 insertions(+), 0 deletions(-) create mode 100644 common/cmd_time.c diff --git a/README b/README index 0868531..246e76f 100644 --- a/README +++ b/README @@ -783,6 +783,7 @@ The following options need to be configured: CONFIG_CMD_SOURCE source command Support CONFIG_CMD_SPI * SPI serial bus support CONFIG_CMD_TFTPSRV * TFTP transfer in server mode + CONFIG_CMD_TIME * run command and report execution time CONFIG_CMD_USB * USB support CONFIG_CMD_CDP * Cisco Discover Protocol support CONFIG_CMD_FSL * Microblaze FSL support diff --git a/common/Makefile b/common/Makefile index 371a0d9..fdc4206 100644 --- a/common/Makefile +++ b/common/Makefile @@ -147,6 +147,7 @@ COBJS-$(CONFIG_CMD_SPI) += cmd_spi.o COBJS-$(CONFIG_CMD_SPIBOOTLDR) += cmd_spibootldr.o COBJS-$(CONFIG_CMD_STRINGS) += cmd_strings.o COBJS-$(CONFIG_CMD_TERMINAL) += cmd_terminal.o +COBJS-$(CONFIG_CMD_TIME) += cmd_time.o COBJS-$(CONFIG_SYS_HUSH_PARSER) += cmd_test.o COBJS-$(CONFIG_CMD_TSI148) += cmd_tsi148.o COBJS-$(CONFIG_CMD_UBI) += cmd_ubi.o diff --git a/common/cmd_time.c b/common/cmd_time.c new file mode 100644 index 000..c937ae4 --- /dev/null +++ b/common/cmd_time.c @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2011 The Chromium OS Authors. + * See file CREDITS for list of people who contributed to this + * project. + * + * 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., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include common.h +#include command.h + +/* + * TODO(clchiou): This function actually minics the bottom-half of the + * run_command() function. Since this function has ARM-dependent timer + * codes, we cannot merge it with the run_command() for now. + */ +static int run_command_and_time_it(int flag, int argc, char * const argv[], + ulong *cycles) +{ + cmd_tbl_t *cmdtp = find_cmd(argv[0]); + int retval = 0; + + if (!cmdtp) { + printf(%s: command not found\n, argv[0]); + return 1; + } + if (argc cmdtp-maxargs) + return cmd_usage(cmdtp); + + /* +* TODO(clchiou): get_timer_masked() is only defined in certain ARM +* boards. We could use the new timer API that Graeme is proposing +* so that this piece of code would be arch-independent. +*/ + *cycles = get_timer_masked(); + retval = cmdtp-cmd(cmdtp, flag, argc, argv); + *cycles = get_timer_masked() - *cycles; + + return retval; +} + +static void report_time(ulong cycles) +{ + ulong minutes, seconds, milliseconds; + ulong total_seconds, remainder; + + total_seconds = cycles / CONFIG_SYS_HZ; + remainder = cycles % CONFIG_SYS_HZ; + minutes = total_seconds / 60; + seconds = total_seconds % 60; + /* approximate millisecond value */ + milliseconds = (remainder * 1000 + CONFIG_SYS_HZ / 2) / CONFIG_SYS_HZ; + + printf(\ntime:); + if (minutes) + printf( %lu minutes,, minutes); + printf( %lu.%03lu seconds, %lu ticks\n, + seconds, milliseconds, cycles); +} + +static int do_time(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +{ + ulong cycles = 0; + int retval = 0; + + if (argc == 1) + return cmd_usage(cmdtp); + + retval = run_command_and_time_it(0, argc - 1, argv + 1, cycles); + report_time(cycles); + + return retval; +} + +U_BOOT_CMD(time, CONFIG_SYS_MAXARGS, 0, do_time, + run commands and summarize
Re: [U-Boot] [PATCH 2/2] api: export LCD and video to external apps
Hi Wolfgang Denk, I have added following comments to this call in patch V2. + /*+ * This only clears messages on screen, not on serial port. It is+ * equivalent to a no-op if no display is available.+ */Do you think it is sufficient? Regards, Che-Liang On Fri, Oct 7, 2011 at 5:05 PM, Wolfgang Denk w...@denx.de wrote: Dear Che-liang Chiou, In message canjuy2kuhg+4kueeupj0pbefkjdhajjnt_8-vulxyuxh9oc...@mail.gmail.com you wrote: + ub_display_clear(); What happens here if no display is available? It is equivalent to a no-op. Or do you think we should print a warning message if no display is available? Please either add an if() and don;t run the function at all, or add a comment that explains that this callis harmless if no display is present. Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de He was so narrow minded he could see through a keyhole with both eyes ... ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH V2] cmd_time: add time command
The 'time' command runs and reports execution time of commands. Sample usage: u-boot# time crc 0x1000 1000 CRC32 for 1000 ... 1fff == ae94dc4b time: 0.004 seconds, 4 ticks Signed-off-by: Che-Liang Chiou clch...@chromium.org --- Changes Since V1 - Switch unsigned long int to ulong to match function prototype - Remove unnecessary 'ifdef CONFIG_SYS_HZ' guard - Factor out codes into the run_command_and_time_it() function README |1 + common/Makefile |1 + common/cmd_time.c| 90 ++ include/config_cmd_all.h |1 + 4 files changed, 93 insertions(+), 0 deletions(-) create mode 100644 common/cmd_time.c diff --git a/README b/README index 91b6695..d6017e5 100644 --- a/README +++ b/README @@ -769,6 +769,7 @@ The following options need to be configured: CONFIG_CMD_SOURCE source command Support CONFIG_CMD_SPI * SPI serial bus support CONFIG_CMD_TFTPSRV * TFTP transfer in server mode + CONFIG_CMD_TIME * run command and report execution time CONFIG_CMD_USB * USB support CONFIG_CMD_CDP * Cisco Discover Protocol support CONFIG_CMD_FSL * Microblaze FSL support diff --git a/common/Makefile b/common/Makefile index 371a0d9..fdc4206 100644 --- a/common/Makefile +++ b/common/Makefile @@ -147,6 +147,7 @@ COBJS-$(CONFIG_CMD_SPI) += cmd_spi.o COBJS-$(CONFIG_CMD_SPIBOOTLDR) += cmd_spibootldr.o COBJS-$(CONFIG_CMD_STRINGS) += cmd_strings.o COBJS-$(CONFIG_CMD_TERMINAL) += cmd_terminal.o +COBJS-$(CONFIG_CMD_TIME) += cmd_time.o COBJS-$(CONFIG_SYS_HUSH_PARSER) += cmd_test.o COBJS-$(CONFIG_CMD_TSI148) += cmd_tsi148.o COBJS-$(CONFIG_CMD_UBI) += cmd_ubi.o diff --git a/common/cmd_time.c b/common/cmd_time.c new file mode 100644 index 000..c937ae4 --- /dev/null +++ b/common/cmd_time.c @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2011 The Chromium OS Authors. + * See file CREDITS for list of people who contributed to this + * project. + * + * 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., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include common.h +#include command.h + +/* + * TODO(clchiou): This function actually minics the bottom-half of the + * run_command() function. Since this function has ARM-dependent timer + * codes, we cannot merge it with the run_command() for now. + */ +static int run_command_and_time_it(int flag, int argc, char * const argv[], + ulong *cycles) +{ + cmd_tbl_t *cmdtp = find_cmd(argv[0]); + int retval = 0; + + if (!cmdtp) { + printf(%s: command not found\n, argv[0]); + return 1; + } + if (argc cmdtp-maxargs) + return cmd_usage(cmdtp); + + /* +* TODO(clchiou): get_timer_masked() is only defined in certain ARM +* boards. We could use the new timer API that Graeme is proposing +* so that this piece of code would be arch-independent. +*/ + *cycles = get_timer_masked(); + retval = cmdtp-cmd(cmdtp, flag, argc, argv); + *cycles = get_timer_masked() - *cycles; + + return retval; +} + +static void report_time(ulong cycles) +{ + ulong minutes, seconds, milliseconds; + ulong total_seconds, remainder; + + total_seconds = cycles / CONFIG_SYS_HZ; + remainder = cycles % CONFIG_SYS_HZ; + minutes = total_seconds / 60; + seconds = total_seconds % 60; + /* approximate millisecond value */ + milliseconds = (remainder * 1000 + CONFIG_SYS_HZ / 2) / CONFIG_SYS_HZ; + + printf(\ntime:); + if (minutes) + printf( %lu minutes,, minutes); + printf( %lu.%03lu seconds, %lu ticks\n, + seconds, milliseconds, cycles); +} + +static int do_time(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +{ + ulong cycles = 0; + int retval = 0; + + if (argc == 1) + return cmd_usage(cmdtp); + + retval = run_command_and_time_it(0, argc - 1, argv + 1, cycles); + report_time(cycles); + + return retval; +} + +U_BOOT_CMD(time, CONFIG_SYS_MAXARGS, 0, do_time, + run commands and summarize execution time
Re: [U-Boot] [PATCH] cmd_time: add time command
Hi Mike, Thanks for comments. Reply inlined. On Thu, Oct 6, 2011 at 1:24 AM, Mike Frysinger vap...@gentoo.org wrote: On Wednesday 05 October 2011 03:09:15 Che-Liang Chiou wrote: The 'time' command runs and reports execution time of commands. cool Sameple usage: typo: Sample Done. --- /dev/null +++ b/common/cmd_time.c +static void report_time(unsigned long int cycles) +{ +#ifdef CONFIG_SYS_HZ CONFIG_SYS_HZ is required to be defined, so please drop this ifdef check Done. + unsigned long int minutes, seconds, milliseconds; + unsigned long int total_seconds, remainder; + + total_seconds = cycles / CONFIG_SYS_HZ; + remainder = cycles % CONFIG_SYS_HZ; + minutes = total_seconds / 60; + seconds = total_seconds % 60; + /* approximate millisecond value */ + milliseconds = (remainder * 1000 + CONFIG_SYS_HZ / 2) / CONFIG_SYS_HZ; + + printf(time:); + if (minutes) + printf( %lu minutes,, minutes); + printf( %lu.%03lu seconds, %lu ticks\n, + seconds, milliseconds, cycles); looks like this could use the new timer api that Graeme is throwing around Exactly. Add TODO comments. +int do_time(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) static Done. + cmd_tbl_t *target_cmdtp = NULL; const I guess I cannot change it to a const pointer. cmdtp-cmd() signature requires a non-const pointer to cmdtp. + if (argc == 1) { + printf(no command provided\n); + return 1; + } return cmd_usage(cmdtp); Done. + if (!target_cmdtp) { + printf(command not found: %s\n, argv[1]); + return 1; + } shells typically display: %s: command not found Done. + if (target_argc target_cmdtp-maxargs) { + printf(maxarags exceeded: %d %d\n, target_argc, + target_cmdtp-maxargs); + return 1; + } ... + retval = target_cmdtp-cmd(target_cmdtp, 0, target_argc, argv + 1); hmm, this looks like we should add a helper like run_command() and put this logic there ... I agree. I moved these codes to a separate function. It can be merged with run_command() if necessary after the timer API is landed. + putc('\n'); + report_time(cycles); why not just integrate that \n into the report_time() code ? Done. -mike Regards, Che-Liang ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH] cmd_time: add time command
The 'time' command runs and reports execution time of commands. Sameple usage: u-boot# time crc 0x1000 1000 CRC32 for 1000 ... 1fff == ae94dc4b time: 0.004 seconds, 4 ticks Signed-off-by: Che-Liang Chiou clch...@chromium.org --- README |1 + common/Makefile |1 + common/cmd_time.c| 84 ++ include/config_cmd_all.h |1 + 4 files changed, 87 insertions(+), 0 deletions(-) create mode 100644 common/cmd_time.c diff --git a/README b/README index 91b6695..d6017e5 100644 --- a/README +++ b/README @@ -769,6 +769,7 @@ The following options need to be configured: CONFIG_CMD_SOURCE source command Support CONFIG_CMD_SPI * SPI serial bus support CONFIG_CMD_TFTPSRV * TFTP transfer in server mode + CONFIG_CMD_TIME * run command and report execution time CONFIG_CMD_USB * USB support CONFIG_CMD_CDP * Cisco Discover Protocol support CONFIG_CMD_FSL * Microblaze FSL support diff --git a/common/Makefile b/common/Makefile index 371a0d9..fdc4206 100644 --- a/common/Makefile +++ b/common/Makefile @@ -147,6 +147,7 @@ COBJS-$(CONFIG_CMD_SPI) += cmd_spi.o COBJS-$(CONFIG_CMD_SPIBOOTLDR) += cmd_spibootldr.o COBJS-$(CONFIG_CMD_STRINGS) += cmd_strings.o COBJS-$(CONFIG_CMD_TERMINAL) += cmd_terminal.o +COBJS-$(CONFIG_CMD_TIME) += cmd_time.o COBJS-$(CONFIG_SYS_HUSH_PARSER) += cmd_test.o COBJS-$(CONFIG_CMD_TSI148) += cmd_tsi148.o COBJS-$(CONFIG_CMD_UBI) += cmd_ubi.o diff --git a/common/cmd_time.c b/common/cmd_time.c new file mode 100644 index 000..3c49615 --- /dev/null +++ b/common/cmd_time.c @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2011 The Chromium OS Authors. + * See file CREDITS for list of people who contributed to this + * project. + * + * 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., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include common.h +#include command.h + +static void report_time(unsigned long int cycles) +{ +#ifdef CONFIG_SYS_HZ + unsigned long int minutes, seconds, milliseconds; + unsigned long int total_seconds, remainder; + + total_seconds = cycles / CONFIG_SYS_HZ; + remainder = cycles % CONFIG_SYS_HZ; + minutes = total_seconds / 60; + seconds = total_seconds % 60; + /* approximate millisecond value */ + milliseconds = (remainder * 1000 + CONFIG_SYS_HZ / 2) / CONFIG_SYS_HZ; + + printf(time:); + if (minutes) + printf( %lu minutes,, minutes); + printf( %lu.%03lu seconds, %lu ticks\n, + seconds, milliseconds, cycles); +#else + printf(CONFIG_SYS_HZ not defined\n); + printf(time: %lu ticks\n, cycles); +#endif +} + +int do_time(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +{ + const int target_argc = argc - 1; + int retval = 0; + unsigned long int cycles = 0; + cmd_tbl_t *target_cmdtp = NULL; + + if (argc == 1) { + printf(no command provided\n); + return 1; + } + + target_cmdtp = find_cmd(argv[1]); + if (!target_cmdtp) { + printf(command not found: %s\n, argv[1]); + return 1; + } + if (target_argc target_cmdtp-maxargs) { + printf(maxarags exceeded: %d %d\n, target_argc, + target_cmdtp-maxargs); + return 1; + } + + cycles = get_timer_masked(); + retval = target_cmdtp-cmd(target_cmdtp, 0, target_argc, argv + 1); + cycles = get_timer_masked() - cycles; + + putc('\n'); + report_time(cycles); + + return retval; +} + +U_BOOT_CMD(time, CONFIG_SYS_MAXARGS, 0, do_time, + run commands and summarize execution time, + command [args...]\n); diff --git a/include/config_cmd_all.h b/include/config_cmd_all.h index 9716f9c..181674b 100644 --- a/include/config_cmd_all.h +++ b/include/config_cmd_all.h @@ -82,6 +82,7 @@ #define CONFIG_CMD_SOURCE /* source command support */ #define CONFIG_CMD_SPI /* SPI utility */ #define CONFIG_CMD_TERMINAL/* built-in Serial Terminal */ +#define
[U-Boot] [PATCH 0/2] api: export LCD and video to external apps
This patch set exports LCD and video clearing and bitmap-rendering on screen functions to external apps, and provides a unified interface of accessing them. Che-Liang Chiou (2): lcd: video: add clear and draw bitmap declaration api: export LCD and video to external apps api/Makefile |3 +- api/api.c| 51 ++ api/api_display.c| 85 ++ api/api_private.h|4 ++ common/lcd.c | 15 +--- examples/api/demo.c | 28 examples/api/glue.c | 31 ++ examples/api/glue.h |5 +++ include/api_public.h | 16 + include/lcd.h|2 + include/video.h |2 + include/video_font.h |6 +++ 12 files changed, 241 insertions(+), 7 deletions(-) create mode 100644 api/api_display.c -- 1.7.3.1 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 1/2] lcd: video: add clear and draw bitmap declaration
The functions for clearing and drawing bitmaps on the screen were not exposed publicly and are made public in this patch in preparation for implementing the display interface of api_public.h. Signed-off-by: Che-Liang Chiou clch...@chromium.org --- common/lcd.c| 15 +-- include/lcd.h |2 ++ include/video.h |2 ++ 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/common/lcd.c b/common/lcd.c index d9cb8ca..d6e3188 100644 --- a/common/lcd.c +++ b/common/lcd.c @@ -78,7 +78,6 @@ static inline void lcd_putc_xy (ushort x, ushort y, uchar c); static int lcd_init (void *lcdbase); -static int lcd_clear (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]); static void *lcd_logo (void); static int lcd_getbgcolor (void); @@ -353,7 +352,13 @@ int drv_lcd_init (void) } /*--*/ -static int lcd_clear (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) +static int do_lcd_clear (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) +{ + lcd_clear(); + return 0; +} + +void lcd_clear (void) { #if LCD_BPP == LCD_MONOCHROME /* Setting the palette */ @@ -394,12 +399,10 @@ static int lcd_clear (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[] console_col = 0; console_row = 0; - - return (0); } U_BOOT_CMD( - cls,1, 1, lcd_clear, + cls,1, 1, do_lcd_clear, clear screen, ); @@ -413,7 +416,7 @@ static int lcd_init (void *lcdbase) lcd_ctrl_init (lcdbase); lcd_is_enabled = 1; - lcd_clear (NULL, 1, 1, NULL); /* dummy args */ + lcd_clear (); lcd_enable (); /* Initialize the console */ diff --git a/include/lcd.h b/include/lcd.h index 0e098d9..fba4ec2 100644 --- a/include/lcd.h +++ b/include/lcd.h @@ -210,6 +210,8 @@ voidlcd_disable (void); void lcd_putc(const char c); void lcd_puts(const char *s); void lcd_printf (const char *fmt, ...); +void lcd_clear (void); +intlcd_display_bitmap(ulong bmp_image, int x, int y); /* Allow boards to customize the information displayed */ void lcd_show_board_info(void); diff --git a/include/video.h b/include/video.h index efcc682..6cd6f72 100644 --- a/include/video.h +++ b/include/video.h @@ -15,5 +15,7 @@ int video_init (void *videobase); void video_putc (const char c); void video_puts (const char *s); void video_printf(const char *fmt, ...); +void video_clear (void); +intvideo_display_bitmap(ulong bmp_image, int x, int y); #endif -- 1.7.3.1 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 2/2] api: export LCD and video to external apps
This patch exports LCD and video information and bitmap-rendering functions to external apps. This patch is tested on a Seaboard, which does not have a video output. So I only tested LCD code paths. NOTE: The Seaboard LCD driver is not yet upstreamed; the test was done in a local downstream repo. Signed-off-by: Che-Liang Chiou clch...@chromium.org --- api/Makefile |3 +- api/api.c| 51 ++ api/api_display.c| 85 ++ api/api_private.h|4 ++ examples/api/demo.c | 28 examples/api/glue.c | 31 ++ examples/api/glue.h |5 +++ include/api_public.h | 16 + include/video_font.h |6 +++ 9 files changed, 228 insertions(+), 1 deletions(-) create mode 100644 api/api_display.c diff --git a/api/Makefile b/api/Makefile index 2a64c4d..0e99f74 100644 --- a/api/Makefile +++ b/api/Makefile @@ -24,7 +24,8 @@ include $(TOPDIR)/config.mk LIB= $(obj)libapi.o -COBJS-$(CONFIG_API) += api.o api_net.o api_storage.o api_platform-$(ARCH).o +COBJS-$(CONFIG_API) += api.o api_display.o api_net.o api_storage.o \ + api_platform-$(ARCH).o COBJS := $(COBJS-y) SRCS := $(COBJS:.o=.c) diff --git a/api/api.c b/api/api.c index 853f010..ddf2edd 100644 --- a/api/api.c +++ b/api/api.c @@ -553,6 +553,54 @@ static int API_env_enum(va_list ap) return 0; } +/* + * pseudo signature: + * + * int API_display_get_info(int type, struct display_info *di) + */ +static int API_display_get_info(va_list ap) +{ + int type; + struct display_info *di; + + type = (int)va_arg(ap, u_int32_t); + di = (struct display_info *)va_arg(ap, u_int32_t); + if (!di) + return API_EINVAL; + + return display_get_info(type, di); +} + +/* + * pseudo signature: + * + * int API_display_draw_bitmap(void *bitmap, int x, int y) + */ +static int API_display_draw_bitmap(va_list ap) +{ + ulong bitmap; + int x, y; + + bitmap = (ulong)va_arg(ap, ulong); + if (!bitmap) + return API_EINVAL; + x = (int)va_arg(ap, u_int32_t); + y = (int)va_arg(ap, u_int32_t); + + return display_draw_bitmap(bitmap, x, y); +} + +/* + * pseudo signature: + * + * void API_display_clear(void) + */ +static int API_display_clear(va_list ap) +{ + display_clear(); + return 0; +} + static cfp_t calls_table[API_MAXCALL] = { NULL, }; /* @@ -616,6 +664,9 @@ void api_init(void) calls_table[API_ENV_GET] = API_env_get; calls_table[API_ENV_SET] = API_env_set; calls_table[API_ENV_ENUM] = API_env_enum; + calls_table[API_DISPLAY_GET_INFO] = API_display_get_info; + calls_table[API_DISPLAY_DRAW_BITMAP] = API_display_draw_bitmap; + calls_table[API_DISPLAY_CLEAR] = API_display_clear; calls_no = API_MAXCALL; debugf(API initialized with %d calls\n, calls_no); diff --git a/api/api_display.c b/api/api_display.c new file mode 100644 index 000..6255848 --- /dev/null +++ b/api/api_display.c @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2011 The Chromium OS Authors. + * See file CREDITS for list of people who contributed to this + * project. + * + * 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., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include common.h +#include lcd.h +#include video.h +#include video_font.h /* Get font width and height */ +#include api_public.h + +int display_get_info(int type, struct display_info *di) +{ + switch (type) { + default: + debug(%s: unsupport display device type: %d\n, __FILE__, type); + return API_ENODEV; + +#ifdef CONFIG_LCD + case DISPLAY_TYPE_LCD: + di-pixel_width = panel_info.vl_col; + di-pixel_height = panel_info.vl_row; + di-screen_rows = CONSOLE_ROWS; + di-screen_cols = CONSOLE_COLS; + break; +#endif + +#if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE) + case DISPLAY_TYPE_VIDEO: + di-pixel_width = VIDEO_VISIBLE_COLS; + di-pixel_height = VIDEO_VISIBLE_ROWS; + di-screen_rows = CONSOLE_ROWS; + di-screen_cols = CONSOLE_COLS; + break; +#endif + } + + di-type = type
[U-Boot] [PATCH] examples: api: allow build with private libgcc
The examples/api is not configured with USE_PRIVATE_LIBGCC. This makes building examples/api break on certain boards that do not/cannot use the public libgcc. Nevertheless, this patch has to also touch the top-level Makefile to fix this problem because the current top-level Makefile does not specify libgcc as a prerequisite of examples/api, and explicitly builds examples/api _before_ libgcc. For testing this patch, I added the following to configs/seaboard.h and ran demo.bin on a Seaboard. +#define CONFIG_API +#define CONFIG_SYS_MMC_MAX_DEVICE 2 +#define CONFIG_CMD_NET +#define CONFIG_NET_MULTI Signed-off-by: Che-Liang Chiou clch...@chromium.org --- Makefile | 16 ++-- examples/api/Makefile |4 +--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index dfe939f..550088f 100644 --- a/Makefile +++ b/Makefile @@ -137,9 +137,11 @@ unexport CDPATH # The tools are needed early, so put this first # Don't include stuff already done in $(LIBS) -SUBDIRS= tools \ - examples/standalone \ - examples/api +# The examples conditionally depend on U-Boot (say, when USE_PRIVATE_LIBGCC +# is yes), so compile examples after U-Boot is compiled. +SUBDIR_TOOLS = tools +SUBDIR_EXAMPLES = examples/standalone examples/api +SUBDIRS = $(SUBDIR_TOOLS) $(SUBDIR_EXAMPLES) .PHONY : $(SUBDIRS) $(VERSION_FILE) @@ -350,7 +352,7 @@ ONENAND_BIN ?= $(obj)onenand_ipl/onenand-ipl-2k.bin ALL-$(CONFIG_MMC_U_BOOT) += $(obj)mmc_spl/u-boot-mmc-spl.bin ALL-$(CONFIG_SPL) += $(obj)spl/u-boot-spl.bin -all: $(ALL-y) +all: $(ALL-y) $(SUBDIR_EXAMPLES) $(obj)u-boot.hex: $(obj)u-boot $(OBJCOPY) ${OBJCFLAGS} -O ihex $ $@ @@ -405,7 +407,7 @@ GEN_UBOOT = \ --start-group $(__LIBS) --end-group $(PLATFORM_LIBS) \ -Map u-boot.map -o u-boot $(obj)u-boot: depend \ - $(SUBDIRS) $(OBJS) $(LIBBOARD) $(LIBS) $(LDSCRIPT) $(obj)u-boot.lds + $(SUBDIR_TOOLS) $(OBJS) $(LIBBOARD) $(LIBS) $(LDSCRIPT) $(obj)u-boot.lds $(GEN_UBOOT) ifeq ($(CONFIG_KALLSYMS),y) smap=`$(call SYSTEM_MAP,u-boot) | \ @@ -418,7 +420,7 @@ endif $(OBJS): depend $(MAKE) -C $(CPUDIR) $(if $(REMOTE_BUILD),$@,$(notdir $@)) -$(LIBS): depend $(SUBDIRS) +$(LIBS): depend $(SUBDIR_TOOLS) $(MAKE) -C $(dir $(subst $(obj),,$@)) $(LIBBOARD): depend $(LIBS) @@ -427,6 +429,8 @@ $(LIBBOARD):depend $(LIBS) $(SUBDIRS):depend $(MAKE) -C $@ all +$(SUBDIR_EXAMPLES): $(obj)u-boot + $(LDSCRIPT): depend $(MAKE) -C $(dir $@) $(notdir $@) diff --git a/examples/api/Makefile b/examples/api/Makefile index 5b5f7a6..bad05af 100644 --- a/examples/api/Makefile +++ b/examples/api/Makefile @@ -62,8 +62,6 @@ OBJS += $(addprefix $(obj),$(COBJ_FILES-y)) OBJS += $(addprefix $(obj),$(notdir $(EXT_COBJ_FILES-y))) OBJS += $(addprefix $(obj),$(notdir $(EXT_SOBJ_FILES-y))) -gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`) - CPPFLAGS += -I.. all: $(obj).depend $(OUTPUT) @@ -71,7 +69,7 @@ all: $(obj).depend $(OUTPUT) # $(OUTPUT): $(OBJS) - $(LD) -Ttext $(LOAD_ADDR) -o $@ $^ -L$(gcclibdir) -lgcc + $(LD) -Ttext $(LOAD_ADDR) -o $@ $^ $(PLATFORM_LIBS) $(OBJCOPY) -O binary $@ $(OUTPUT).bin 2/dev/null # Rule to build generic library C files -- 1.7.3.1 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] arm: add 64-64 bit divider
Hi, Thanks for the insightful comments. Here are my responses: * Why don't I implement the divider in C? It is not because I think it's performance critical (I haven't benchmarked it yet), but because I have a probably wrong impression that the divider has to be written in assembly --- all dividers in arch/arm/lib/ are written in ARM assembly. What is the policy here for using assembly or C? * When do we need a 64-bit divider? In kernel code do_div() is used for various purposes. So I think it should be quite often that we would need a 64-bit divider in U-Boot. * Do we need a 64-64 bit divider? do_div() defines 64-32 bit division semantics (dividend is 64-bit and divisor is 32-bit), and this patch implements a 64-64 bit divider (both dividend and divisor are 64-bit). I have to admit that I can't think of scenarios or reasons to justify a 64-64 bit divider instead of a 64-32 bit divider, except that a 64-64 bit divider is more generic than a 64-32 bit one. So I guess we can agree that a 64-bit divider is feature that is nice to have, and we should decide: * Do we need a 64-64 bit divider or a 64-32 bit one? * Do we write it in C or assembly? Depending on our decisions, I will rewrite (or abandon) this patch accordingly. Regards, Che-Liang On Thu, Sep 1, 2011 at 4:03 AM, Wolfgang Denk w...@denx.de wrote: Dear Che-Liang Chiou, In message 1314787130-1043-1-git-send-email-clch...@chromium.org you wrote: This patch adds a 64-64 bit divider that supports ARMv4 and above. To summarize the misc feedback: Please explain in detail which problem you are trying to fix. We see no need for this patch so far. Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de Success covers a multitude of blunders. - George Bernard Shaw ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] arm: add 64-64 bit divider
Hi Marek, I will abandon this patch and submit a new patch that is adapted from do_div() and lib64.c of the Linux kernel. Does this sound okay to you? Regards, Che-Liang On Thu, Sep 1, 2011 at 6:16 PM, Marek Vasut marek.va...@gmail.com wrote: On Thursday, September 01, 2011 12:09:18 PM Che-liang Chiou wrote: Hi, Thanks for the insightful comments. Here are my responses: * Why don't I implement the divider in C? It is not because I think it's performance critical (I haven't benchmarked it yet), but because I have a probably wrong impression that the divider has to be written in assembly --- all dividers in arch/arm/lib/ are written in ARM assembly. What is the policy here for using assembly or C? No, C is just fine and is more generic. Those assembler versions are just optimized things, you don't need to be bothered by those. * When do we need a 64-bit divider? In kernel code do_div() is used for various purposes. So I think it should be quite often that we would need a 64-bit divider in U-Boot. Not much really ... and for the rare cases, we can do with do_div() as is. * Do we need a 64-64 bit divider? do_div() defines 64-32 bit division semantics (dividend is 64-bit and divisor is 32-bit), and this patch implements a 64-64 bit divider (both dividend and divisor are 64-bit). I have to admit that I can't think of scenarios or reasons to justify a 64-64 bit divider instead of a 64-32 bit divider, except that a 64-64 bit divider is more generic than a 64-32 bit one. So we don't need 64/64 divide at all. So I guess we can agree that a 64-bit divider is feature that is nice to have, and we should decide: * Do we need a 64-64 bit divider or a 64-32 bit one? 64-32 is do_div() * Do we write it in C or assembly? C is OK. Depending on our decisions, I will rewrite (or abandon) this patch accordingly. Look, I don't mean to be rough, but honestly. I see no use for this code. Adding code to anywhere so it'd just sit there is bad. Cheers Regards, Che-Liang On Thu, Sep 1, 2011 at 4:03 AM, Wolfgang Denk w...@denx.de wrote: Dear Che-Liang Chiou, In message 1314787130-1043-1-git-send-email-clch...@chromium.org you wrote: This patch adds a 64-64 bit divider that supports ARMv4 and above. To summarize the misc feedback: Please explain in detail which problem you are trying to fix. We see no need for this patch so far. Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de Success covers a multitude of blunders. - George Bernard Shaw ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] arm: add 64-64 bit divider
Hi Marek, do_div() and lib/div64.c of linux kernel has been ported to U-Boot since Oct, 2006 (this date is the earliest record that I can find; see commit 7b64fef3). Regards, Che-Liang On Thu, Sep 1, 2011 at 6:42 PM, Marek Vasut marek.va...@gmail.com wrote: On Thursday, September 01, 2011 12:30:47 PM Che-liang Chiou wrote: Hi Marek, I will abandon this patch and submit a new patch that is adapted from do_div() and lib64.c of the Linux kernel. Does this sound okay to you? I'm not against it, but is it worth the effort? Like ... why do we need it ? Regards, Che-Liang [...] ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] arm: add 64-64 bit divider
Dear Wolfgang, I am convinced that a 64-64 bit divider (this patch) is not needed. Is there any way that we could mark a patch abandon? Regards, Che-Liang On Thu, Sep 1, 2011 at 9:07 PM, Wolfgang Denk w...@denx.de wrote: Dear Che-liang Chiou, In message CANJuy2K9uWdxT6T=mmj0yliv3cajuhlnc4lgdv21sp-dmgv...@mail.gmail.com you wrote: do_div() and lib/div64.c of linux kernel has been ported to U-Boot since Oct, 2006 (this date is the earliest record that I can find; see commit 7b64fef3). Indeed, and so far nobody ever needed the patch you submitted, so please explain in detail why you need it now? Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de More software projects have gone awry for lack of calendar time than for all other causes combined. - Fred Brooks, Jr., _The Mythical Man Month_ ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH] arm: add 64-64 bit divider
This patch adds a 64-64 bit divider that supports ARMv4 and above. Because clz (count leading zero) instruction is added until ARMv5, the divider implements a clz function for ARMv4 targets. The divider was tested with the following test driver code ran by qemu-arm: int main(void) { uint64_t a, b, q, r; while (scanf(%llx %llx %llx %llx, a, b, q, r) 0) printf(%016llx %016llx %016llx %016llx\n, a, b, a / b, a % b); return 0; } Signed-off-by: Che-Liang Chiou clch...@chromium.org Cc: Albert Aribaud albert.u.b...@aribaud.net --- This patch is alos tested with `MAKEALL -a arm` arch/arm/lib/Makefile|1 + arch/arm/lib/_uldivmod.S | 266 ++ 2 files changed, 267 insertions(+), 0 deletions(-) create mode 100644 arch/arm/lib/_uldivmod.S diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile index 300c8fa..31770dd 100644 --- a/arch/arm/lib/Makefile +++ b/arch/arm/lib/Makefile @@ -33,6 +33,7 @@ GLSOBJS += _divsi3.o GLSOBJS+= _lshrdi3.o GLSOBJS+= _modsi3.o GLSOBJS+= _udivsi3.o +GLSOBJS+= _uldivmod.o GLSOBJS+= _umodsi3.o GLCOBJS+= div0.o diff --git a/arch/arm/lib/_uldivmod.S b/arch/arm/lib/_uldivmod.S new file mode 100644 index 000..9e3a5e6 --- /dev/null +++ b/arch/arm/lib/_uldivmod.S @@ -0,0 +1,266 @@ +/* + * Copyright (c) 2011 The Chromium OS Authors. + * See file CREDITS for list of people who contributed to this + * project. + * + * 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., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +/* + * A, Q = r0 + (r1 32) + * B, R = r2 + (r3 32) + * A / B = Q ... R + */ + + .text + .global __aeabi_uldivmod + .type __aeabi_uldivmod, function + .align 0 + +/* armv4 does not support clz (count leading zero) instruction. */ +#if __LINUX_ARM_ARCH__ = 4 +# define CLZ(dst, src)bl L_clz_ ## dst ## _ ## src +# define CLZEQ(dst, src) bleqL_clz_ ## dst ## _ ## src +#else +# define CLZ(dst, src)clz dst, src +# define CLZEQ(dst, src) clzeq dst, src +#endif + +A_0.reqr0 +A_1.reqr1 +B_0.reqr2 +B_1.reqr3 +C_0.reqr4 +C_1.reqr5 +D_0.reqr6 +D_1.reqr7 + +Q_0.reqr0 +Q_1.reqr1 +R_0.reqr2 +R_1.reqr3 + +__aeabi_uldivmod: + stmfd sp!, {r4, r5, r6, r7, lr} + @ Test if B == 0 + orrsip, B_0, B_1@ Z set - B == 0 + beq L_div_by_0 + @ Test if B is power of 2: (B (B - 1)) == 0 + subsC_0, B_0, #1 + sbc C_1, B_1, #0 + tst C_0, B_0 + tsteq B_1, C_1 + beq L_pow2 + @ Test if A_1 == B_1 == 0 + orrsip, A_1, B_1 + beq L_div_32_32 + +L_div_64_64: + mov C_0, #1 + mov C_1, #0 + @ D_0 = clz A + CLZ(D_0, A_1) + teq A_1, #0 + CLZEQ(ip, A_0) + teq A_1, #0 + addeq D_0, D_0, ip + @ D_1 = clz B + CLZ(D_1, B_1) + teq B_1, #0 + CLZEQ(ip, B_0) + teq B_1, #0 + addeq D_1, D_1, ip + @ if clz B - clz A = 0: goto L_done_shift + subsD_0, D_1, D_0 + bls L_done_shift + subsD_1, D_0, #32 + rsb ip, D_0, #32 + @ B = (clz B - clz A) + movmi B_1, B_1, lsl D_0 + orrmi B_1, B_1, B_0, lsr ip + movpl B_1, B_0, lsl D_1 + mov B_0, B_0, lsl D_0 + @ C = 1 (clz B - clz A) + movmi C_1, C_1, lsl D_0 + orrmi C_1, C_1, C_0, lsr ip + movpl C_1, C_0, lsl D_1 + mov C_0, C_0, lsl D_0 +L_done_shift: + mov D_0, #0 + mov D_1, #0 + @ C: current bit; D: result +L_subtract: + @ if A = B + cmp A_1, B_1 + cmpeq A_0, B_0 + bcc L_update + @ A -= B + subsA_0, A_0, B_0 + sbc A_1, A_1, B_1 + @ D |= C + orr D_0, D_0, C_0 + orr D_1, D_1, C_1 +L_update: + @ if A == 0: break + orrsip, A_1, A_0 + beq L_exit + @ C = 1 + movsC_1, C_1, lsr #1 + movsC_0, C_0, rrx + @ if C == 0: break + orrsip, C_1, C_0 + beq L_exit + @ B = 1 + movsB_1, B_1, lsr #1 + mov B_0
[U-Boot] [PATCH] arm: tegra2: fix out-of-tree build
The out-of-tree build fails because the Makefiles in question depend on source files of another directory but do not explicitly mkdir that directory. As a matter of fact, other Makefiles under board/*/ directory that refer to source files under another directory explicitly call mkdir. This patch adds explicit mkdir's to the Makefiles in question, and verifies that out-of-tree build is working. Signed-off-by: Che-Liang Chiou clch...@chromium.org Cc: Albert Aribaud albert.u.b...@aribaud.net --- board/nvidia/harmony/Makefile |4 board/nvidia/seaboard/Makefile |4 2 files changed, 8 insertions(+), 0 deletions(-) diff --git a/board/nvidia/harmony/Makefile b/board/nvidia/harmony/Makefile index 9fb6b57..ebd8e02 100644 --- a/board/nvidia/harmony/Makefile +++ b/board/nvidia/harmony/Makefile @@ -24,6 +24,10 @@ include $(TOPDIR)/config.mk +ifneq ($(OBJTREE),$(SRCTREE)) +$(shell mkdir -p $(obj)../common) +endif + LIB= $(obj)lib$(BOARD).o COBJS := $(BOARD).o diff --git a/board/nvidia/seaboard/Makefile b/board/nvidia/seaboard/Makefile index 9fb6b57..ebd8e02 100644 --- a/board/nvidia/seaboard/Makefile +++ b/board/nvidia/seaboard/Makefile @@ -24,6 +24,10 @@ include $(TOPDIR)/config.mk +ifneq ($(OBJTREE),$(SRCTREE)) +$(shell mkdir -p $(obj)../common) +endif + LIB= $(obj)lib$(BOARD).o COBJS := $(BOARD).o -- 1.7.3.1 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] arm: tegra2: fix out-of-tree build
Hi Anton, Thanks for comments. Replied below. Regards, Che-Liang On Wed, Aug 24, 2011 at 1:01 AM, Anton Staaf robot...@google.com wrote: On Tue, Aug 23, 2011 at 3:03 AM, Che-Liang Chiou clch...@chromium.org wrote: The out-of-tree build fails because the Makefiles in question depend on source files of another directory but do not explicitly mkdir that directory. As a matter of fact, other Makefiles under board/*/ directory that refer to source files under another directory explicitly call mkdir. This patch adds explicit mkdir's to the Makefiles in question, and verifies that out-of-tree build is working. Signed-off-by: Che-Liang Chiou clch...@chromium.org Cc: Albert Aribaud albert.u.b...@aribaud.net --- board/nvidia/harmony/Makefile | 4 board/nvidia/seaboard/Makefile | 4 2 files changed, 8 insertions(+), 0 deletions(-) diff --git a/board/nvidia/harmony/Makefile b/board/nvidia/harmony/Makefile index 9fb6b57..ebd8e02 100644 --- a/board/nvidia/harmony/Makefile +++ b/board/nvidia/harmony/Makefile @@ -24,6 +24,10 @@ include $(TOPDIR)/config.mk +ifneq ($(OBJTREE),$(SRCTREE)) +$(shell mkdir -p $(obj)../common) +endif + We should actually fix this by making the other directory build a library and then include the library in this Makefile. I had a reminder to get back to this but haven't yet. Thanks, Anton I find that Makefiles that call mkdir are those depend on a board/*/common/ directory which is shared among board variants (with a couple of exceptions). I guess the reason why none of boards implemented your proposal is because it involves changes to the top-level Makefile. The top-level Makefile cherry-picks the libraries, and the (only?) board-dependent library is LIBBOARD = board/$(BOARDDIR)/lib$(BOARD).o. And I guess implementing your proposal means we have to add a LIBBOARD_COMMON to the top-level Makefile. I am not sure whether adding a board-common library to the top-level Makefile is possible. If it is possible, maybe we could start from this patch. What do you think? LIB = $(obj)lib$(BOARD).o COBJS := $(BOARD).o diff --git a/board/nvidia/seaboard/Makefile b/board/nvidia/seaboard/Makefile index 9fb6b57..ebd8e02 100644 --- a/board/nvidia/seaboard/Makefile +++ b/board/nvidia/seaboard/Makefile @@ -24,6 +24,10 @@ include $(TOPDIR)/config.mk +ifneq ($(OBJTREE),$(SRCTREE)) +$(shell mkdir -p $(obj)../common) +endif + LIB = $(obj)lib$(BOARD).o COBJS := $(BOARD).o -- 1.7.3.1 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v3] Add 'sf update' command to do smart SPI flash update
Hi Simon, I have a dumb question: How did you make u-boot run native under Linux? Did you mock out all platform functions? Or did you bundle u-boot with a emulator? Regards, Che-Liang On Wed, Aug 24, 2011 at 6:16 AM, Mike Frysinger vap...@gentoo.org wrote: On Tuesday, August 23, 2011 18:01:34 Simon Glass wrote: That's a great trick. How much of the drivers did you implement in the simulator? probably more than i'd like to admit, but not as many as i'd like ;) http://docs.blackfin.uclinux.org/doku.php?id=toolchain:sim#peripherals How about this, running native under Linux: also pretty cool. i think both are worth while efforts. -mike ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] Fix variable flavor in examples/standalone/Makefile
Thanks, Wolfgang. On Fri, May 13, 2011 at 4:30 AM, Wolfgang Denk w...@denx.de wrote: Dear Che-liang Chiou, In message aanlktimw1vlc8gm_xsdgqgkluyyzkqofyfb8-bjvb...@mail.gmail.com you wrote: GNU Makefile have two flavors of variables, recursively expanded that is defined by using '=', and simply expanded that is defined by using ':='. The bug is caused by using recursively expanded flavor for BIN and SREC. As you can see below, they are prepended by $(obj) twice. We can reproduce this bug with a simplified version of this Makefile: $ cat Makefile EOF obj := /path/to/obj/ ELF := hello_world BIN_rec = $(addsuffix .bin,$(ELF)) # recursively expanded BIN_sim := $(addsuffix .bin,$(ELF)) # simply expanded ELF := $(addprefix $(obj),$(ELF)) BIN_rec := $(addprefix $(obj),$(BIN_rec)) BIN_sim := $(addprefix $(obj),$(BIN_sim)) show: @echo BIN_rec=$(BIN_rec) @echo BIN_sim=$(BIN_sim) .PHONY: show EOF $ make show BIN_rec=/path/to/obj//path/to/obj/hello_world.bin BIN_sim=/path/to/obj/hello_world.bin Signed-off-by: Che-Liang Chiou clch...@chromium.org --- examples/standalone/Makefile | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Applied, thanks. Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de It all seemed, he thought, to be rather a lot of trouble to go to just sharpen a razor blade. - Terry Pratchett, _The Light Fantastic_ ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] Fix variable flavor in examples/standalone/Makefile
Dear Wolfgang Denk, On Tue, Feb 22, 2011 at 3:33 PM, Wolfgang Denk w...@denx.de wrote: In message aanlktimw1vlc8gm_xsdgqgkluyyzkqofyfb8-bjvb...@mail.gmail.com you wrote: The bug is caused by using recursively expanded flavor for BIN and SREC. You wrote The bug. How does this bug manifest in U-Boot? For which configuration do you see issues? The bug I refer to is that hello_world.bin and hello_world.srec are not built. I can reproduce this bug in versatile_config, but I believe it is generally applicable to other configures as well since it is caused by Makefile syntax. Here is how I found the bug: $ make O=/tmp/build distclean $ make O=/tmp/build versatile_config $ make O=/tmp/build -j8 $ ls /tmp/build/examples/standalone/ hello_world hello_world.o libstubs.o smc9_eeprom smc9_eeprom.o stubs.o Notice that hello_world.bin and hello_world.srec are not found. Regards, Che-Liang ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH] Fix variable flavor in examples/standalone/Makefile
GNU Makefile have two flavors of variables, recursively expanded that is defined by using '=', and simply expanded that is defined by using ':='. The bug is caused by using recursively expanded flavor for BIN and SREC. As you can see below, they are prepended by $(obj) twice. We can reproduce this bug with a simplified version of this Makefile: $ cat Makefile EOF obj := /path/to/obj/ ELF := hello_world BIN_rec = $(addsuffix .bin,$(ELF)) # recursively expanded BIN_sim := $(addsuffix .bin,$(ELF)) # simply expanded ELF := $(addprefix $(obj),$(ELF)) BIN_rec := $(addprefix $(obj),$(BIN_rec)) BIN_sim := $(addprefix $(obj),$(BIN_sim)) show: @echo BIN_rec=$(BIN_rec) @echo BIN_sim=$(BIN_sim) .PHONY: show EOF $ make show BIN_rec=/path/to/obj//path/to/obj/hello_world.bin BIN_sim=/path/to/obj/hello_world.bin Signed-off-by: Che-Liang Chiou clch...@chromium.org --- examples/standalone/Makefile |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/standalone/Makefile b/examples/standalone/Makefile index c1dfdce..6fd9f5d 100644 --- a/examples/standalone/Makefile +++ b/examples/standalone/Makefile @@ -45,8 +45,8 @@ ELF-oxc += eepro100_eeprom # ELF := $(strip $(ELF-y) $(ELF-$(ARCH)) $(ELF-$(BOARD)) $(ELF-$(CPU))) -SREC = $(addsuffix .srec,$(ELF)) -BIN = $(addsuffix .bin,$(ELF)) +SREC := $(addsuffix .srec,$(ELF)) +BIN := $(addsuffix .bin,$(ELF)) COBJS := $(ELF:=.o) -- 1.7.3.1 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot