1 From 4c205f540190260d40e9fc539a5d839bf24fe0e7 Mon Sep 17 00:00:00 2001
2 From: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
3 Date: Fri, 15 Aug 2008 01:55:54 +0300
4 Subject: [PATCH 04/10] TI DSP BRIDGE: Generic Utilities
6 Initial port from omapzoom
7 http://omapzoom.org/gf/project/omapbridge
10 http://omapzoom.org/gf/project/omapbridge/docman/?subdir=3
12 Signed-off-by: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
14 drivers/dsp/bridge/gen/_gt_para.c | 107 ++++++++++++
15 drivers/dsp/bridge/gen/gb.c | 182 +++++++++++++++++++
16 drivers/dsp/bridge/gen/gh.c | 191 ++++++++++++++++++++
17 drivers/dsp/bridge/gen/gs.c | 108 ++++++++++++
18 drivers/dsp/bridge/gen/gt.c | 346 +++++++++++++++++++++++++++++++++++++
19 drivers/dsp/bridge/gen/uuidutil.c | 238 +++++++++++++++++++++++++
20 6 files changed, 1172 insertions(+), 0 deletions(-)
21 create mode 100644 drivers/dsp/bridge/gen/_gt_para.c
22 create mode 100644 drivers/dsp/bridge/gen/gb.c
23 create mode 100644 drivers/dsp/bridge/gen/gh.c
24 create mode 100644 drivers/dsp/bridge/gen/gs.c
25 create mode 100644 drivers/dsp/bridge/gen/gt.c
26 create mode 100644 drivers/dsp/bridge/gen/uuidutil.c
28 Index: lk/drivers/dsp/bridge/gen/_gt_para.c
29 ===================================================================
30 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
31 +++ lk/drivers/dsp/bridge/gen/_gt_para.c 2008-08-18 10:38:36.000000000 +0300
34 + * linux/drivers/dsp/bridge/gen/linux/_gt_para.c
36 + * DSP-BIOS Bridge driver support functions for TI OMAP processors.
38 + * Copyright (C) 2005-2006 Texas Instruments, Inc.
40 + * This package is free software; you can redistribute it and/or modify
41 + * it under the terms of the GNU General Public License version 2 as
42 + * published by the Free Software Foundation.
44 + * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
45 + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
46 + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
51 + * ======== _gt_para.c ========
53 + * Configuration parameters for GT. This file is separated from
54 + * gt.c so that GT_assert() can reference the error function without
55 + * forcing the linker to include all the code for GT_set(), GT_init(),
56 + * etc. into a fully bound image. Thus, GT_assert() can be retained in
57 + * a program for which GT_?trace() has been compiled out.
59 + *! Revision History:
61 + *! 24-Feb-2003 vp: Code Review Updates.
62 + *! 18-Oct-2002 sb: Ported to Linux platform.
63 + *! 03-Jul-2001 rr: Removed kfuncs.h because of build errors.
64 + *! 07-Dec-1999 ag: Fxn error now causes a WinCE DebugBreak;
65 + *! 30-Aug-1999 ag: Now uses GP_printf for printf and error.
69 +/* ----------------------------------- Host OS */
72 +/* ----------------------------------- DSP/BIOS Bridge */
75 +/* ----------------------------------- Trace & Debug */
78 +/* ----------------------------------- Function Prototypes */
79 +static void error(char *msg, ...);
80 +static s32 GT_nop(void);
82 +/* ----------------------------------- Defines, Data Structures, Typedefs */
84 +struct GT_Config _GT_params = {
85 + (Fxn) printk, /* printf */
86 + (Fxn) NULL, /* procid */
87 + (Fxn) GT_nop, /* taskid */
88 + (Fxn) error, /* error */
91 +/* ----------------------------------- Globals */
92 +struct GT_Config *GT = &_GT_params;
95 + * ======== GT_nop ========
97 +static s32 GT_nop(void)
103 + * ======== error ========
105 + * Prints error onto the standard output.
107 +static void error(char *fmt, ...)
109 + s32 arg1, arg2, arg3, arg4, arg5, arg6;
115 + arg1 = va_arg(va, s32);
116 + arg2 = va_arg(va, s32);
117 + arg3 = va_arg(va, s32);
118 + arg4 = va_arg(va, s32);
119 + arg5 = va_arg(va, s32);
120 + arg6 = va_arg(va, s32);
124 + (*GT->PRINTFXN) ("ERROR: ");
125 + (*GT->PRINTFXN) (fmt, arg1, arg2, arg3, arg4, arg5, arg6);
127 +#if (defined DEBUG) || (defined DDSP_DEBUG_PRODUCT)
128 + if (in_interrupt()) {
129 + printk(KERN_INFO "Not stopping after error since ISR/DPC "
132 + set_current_state(TASK_INTERRUPTIBLE);
133 + flush_signals(current);
135 + flush_signals(current);
136 + printk(KERN_INFO "Signaled in error function\n");
140 Index: lk/drivers/dsp/bridge/gen/gb.c
141 ===================================================================
142 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
143 +++ lk/drivers/dsp/bridge/gen/gb.c 2008-08-18 10:38:36.000000000 +0300
146 + * linux/drivers/dsp/bridge/gen/gb.c
148 + * DSP-BIOS Bridge driver support functions for TI OMAP processors.
150 + * Copyright (C) 2005-2006 Texas Instruments, Inc.
152 + * This package is free software; you can redistribute it and/or modify
153 + * it under the terms of the GNU General Public License version 2 as
154 + * published by the Free Software Foundation.
156 + * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
157 + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
158 + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
163 + * ======== gb.c ========
164 + * Description: Generic bitmap operations.
166 + *! Revision History
167 + *! ================
168 + *! 24-Feb-2003 vp Code review updates.
169 + *! 17-Dec-2002 map Fixed GB_minset(), GB_empty(), and GB_full(),
170 + *! to ensure only 'len' bits are considered in the map
171 + *! 18-Oct-2002 sb Ported to Linux platform.
172 + *! 06-Dec-2001 jeh Fixed bug in GB_minclear().
176 +/* ----------------------------------- DSP/BIOS Bridge */
178 +#include <linux/types.h>
179 +/* ----------------------------------- This */
183 +typedef GB_BitNum GB_WordNum;
192 + * ======== GB_clear ========
194 + * Clears a bit in the bit map.
197 +void GB_clear(struct GB_TMap *map, GB_BitNum bitn)
201 + mask = 1L << (bitn % BITS_PER_LONG);
202 + map->words[bitn / BITS_PER_LONG] &= ~mask;
206 + * ======== GB_create ========
208 + * Creates a bit map.
211 +struct GB_TMap *GB_create(GB_BitNum len)
213 + struct GB_TMap *map;
215 + map = (struct GB_TMap *)GS_alloc(sizeof(struct GB_TMap));
218 + map->wcnt = len / BITS_PER_LONG + 1;
219 + map->words = (u32 *)GS_alloc(map->wcnt * sizeof(u32));
220 + if (map->words != NULL) {
221 + for (i = 0; i < map->wcnt; i++)
222 + map->words[i] = 0L;
225 + GS_frees(map, sizeof(struct GB_TMap));
234 + * ======== GB_delete ========
239 +void GB_delete(struct GB_TMap *map)
241 + GS_frees(map->words, map->wcnt * sizeof(u32));
242 + GS_frees(map, sizeof(struct GB_TMap));
246 + * ======== GB_findandset ========
248 + * Finds a free bit and sets it.
250 +GB_BitNum GB_findandset(struct GB_TMap *map)
254 + bitn = GB_minclear(map);
256 + if (bitn != GB_NOBITS)
263 + * ======== GB_minclear ========
265 + * returns the location of the first unset bit in the bit map.
267 +GB_BitNum GB_minclear(struct GB_TMap *map)
269 + GB_BitNum bit_location = 0;
270 + GB_BitNum bitAcc = 0;
275 + for (word = map->words, i = 0; i < map->wcnt; word++, i++) {
277 + for (bit = 0; bit < BITS_PER_LONG; bit++, bitAcc++) {
278 + if (bitAcc == map->len)
281 + if (~*word & (1L << bit)) {
282 + bit_location = i * BITS_PER_LONG + bit;
283 + return bit_location;
288 + bitAcc += BITS_PER_LONG;
296 + * ======== GB_set ========
298 + * Sets a bit in the bit map.
301 +void GB_set(struct GB_TMap *map, GB_BitNum bitn)
305 + mask = 1L << (bitn % BITS_PER_LONG);
306 + map->words[bitn / BITS_PER_LONG] |= mask;
310 + * ======== GB_test ========
312 + * Returns true if the bit is set in the specified location.
315 +bool GB_test(struct GB_TMap *map, GB_BitNum bitn)
321 + mask = 1L << (bitn % BITS_PER_LONG);
322 + word = map->words[bitn / BITS_PER_LONG];
323 + state = word & mask ? TRUE : FALSE;
327 Index: lk/drivers/dsp/bridge/gen/gh.c
328 ===================================================================
329 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
330 +++ lk/drivers/dsp/bridge/gen/gh.c 2008-08-18 10:38:36.000000000 +0300
333 + * linux/drivers/dsp/bridge/gen/gh.c
335 + * DSP-BIOS Bridge driver support functions for TI OMAP processors.
337 + * Copyright (C) 2005-2006 Texas Instruments, Inc.
339 + * This package is free software; you can redistribute it and/or modify
340 + * it under the terms of the GNU General Public License version 2 as
341 + * published by the Free Software Foundation.
343 + * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
344 + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
345 + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
350 + * ======== gh.c ========
355 +#include <host_os.h>
366 +struct GH_THashTab {
369 + struct Elem **buckets;
370 + u16(*hash) (void *, u16);
371 + bool(*match) (void *, void *);
372 + void(*delete) (void *);
375 +static void Nop(void *p);
377 +static void myfree(void *ptr, s32 size);
380 + * ======== GH_create ========
383 +struct GH_THashTab *GH_create(u16 maxBucket, u16 valSize,
384 + u16(*hash)(void *, u16), bool(*match)(void *, void *),
385 + void(*delete)(void *))
387 + struct GH_THashTab *hashTab;
389 + hashTab = (struct GH_THashTab *)GS_alloc(sizeof(struct GH_THashTab));
390 + if (hashTab == NULL)
392 + hashTab->maxBucket = maxBucket;
393 + hashTab->valSize = valSize;
394 + hashTab->hash = hash;
395 + hashTab->match = match;
396 + hashTab->delete = delete == NULL ? Nop : delete;
398 + hashTab->buckets = (struct Elem **)
399 + GS_alloc(sizeof(struct Elem *) * maxBucket);
400 + if (hashTab->buckets == NULL) {
401 + GH_delete(hashTab);
405 + for (i = 0; i < maxBucket; i++)
406 + hashTab->buckets[i] = NULL;
412 + * ======== GH_delete ========
414 +void GH_delete(struct GH_THashTab *hashTab)
416 + struct Elem *elem, *next;
419 + if (hashTab != NULL) {
420 + if (hashTab->buckets != NULL) {
421 + for (i = 0; i < hashTab->maxBucket; i++) {
422 + for (elem = hashTab->buckets[i]; elem != NULL;
425 + (*hashTab->delete) (elem->data);
426 + myfree(elem, sizeof(struct Elem) - 1 +
431 + myfree(hashTab->buckets, sizeof(struct Elem *)
432 + * hashTab->maxBucket);
435 + myfree(hashTab, sizeof(struct GH_THashTab));
440 + * ======== GH_exit ========
445 + if (curInit-- == 1)
451 + * ======== GH_find ========
454 +void *GH_find(struct GH_THashTab *hashTab, void *key)
458 + elem = hashTab->buckets[(*hashTab->hash)(key, hashTab->maxBucket)];
460 + for (; elem; elem = elem->next) {
461 + if ((*hashTab->match)(key, elem->data))
469 + * ======== GH_init ========
474 + if (curInit++ == 0)
479 + * ======== GH_insert ========
482 +void *GH_insert(struct GH_THashTab *hashTab, void *key, void *value)
488 + elem = (struct Elem *)GS_alloc(sizeof(struct Elem) - 1 +
490 + if (elem != NULL) {
492 + dst = (char *)elem->data;
493 + src = (char *)value;
494 + for (i = 0; i < hashTab->valSize; i++)
497 + i = (*hashTab->hash)(key, hashTab->maxBucket);
498 + elem->next = hashTab->buckets[i];
499 + hashTab->buckets[i] = elem;
508 + * ======== Nop ========
511 +static void Nop(void *p)
513 + p = p; /* stifle compiler warning */
517 + * ======== myfree ========
519 +static void myfree(void *ptr, s32 size)
523 Index: lk/drivers/dsp/bridge/gen/gs.c
524 ===================================================================
525 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
526 +++ lk/drivers/dsp/bridge/gen/gs.c 2008-08-18 10:38:36.000000000 +0300
529 + * linux/drivers/dsp/bridge/gen/gs.c
531 + * DSP-BIOS Bridge driver support functions for TI OMAP processors.
533 + * Copyright (C) 2005-2006 Texas Instruments, Inc.
535 + * This package is free software; you can redistribute it and/or modify
536 + * it under the terms of the GNU General Public License version 2 as
537 + * published by the Free Software Foundation.
539 + * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
540 + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
541 + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
546 + * ======== gs.c ========
548 + * General storage memory allocator services.
550 + *! Revision History
551 + *! ================
552 + *! 29-Sep-1999 ag: Un-commented MEM_Init in GS_init().
553 + *! 14-May-1997 mg: Modified to use new GS API for GS_free() and GS_frees().
554 + *! 06-Nov-1996 gp: Re-commented MEM_Init in GS_init(). GS needs GS_Exit().
555 + *! 21-Oct-1996 db: Un-commented MEM_Init in GS_init().
556 + *! 21-May-1996 mg: Created from original stdlib implementation.
559 +/* ----------------------------------- DSP/BIOS Bridge */
562 +#include <linux/types.h>
563 +/* ----------------------------------- OS Adaptation Layer */
566 +/* ----------------------------------- This */
569 +/* ----------------------------------- Globals */
573 + * ======== GS_alloc ========
575 + * Allocates memory of the specified size.
577 +void *GS_alloc(u32 size)
581 + p = MEM_Calloc(size, MEM_PAGED);
589 + * ======== GS_exit ========
591 + * Discontinue the usage of the GS module.
599 + * ======== GS_free ========
601 + * Frees the memory.
603 +void GS_free(void *ptr)
606 + /* ack! no size info */
607 + /* cumsize -= size; */
611 + * ======== GS_frees ========
613 + * Frees the memory.
615 +void GS_frees(void *ptr, u32 size)
622 + * ======== GS_init ========
624 + * Initializes the GS module.
628 + static bool curInit = false;
630 + if (curInit == false) {
636 Index: lk/drivers/dsp/bridge/gen/gt.c
637 ===================================================================
638 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
639 +++ lk/drivers/dsp/bridge/gen/gt.c 2008-08-18 10:38:36.000000000 +0300
642 + * linux/drivers/dsp/bridge/gen/gt.c
644 + * DSP-BIOS Bridge driver support functions for TI OMAP processors.
646 + * Copyright (C) 2005-2006 Texas Instruments, Inc.
648 + * This package is free software; you can redistribute it and/or modify
649 + * it under the terms of the GNU General Public License version 2 as
650 + * published by the Free Software Foundation.
652 + * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
653 + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
654 + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
659 + * ======== gt.c ========
660 + * Description: This module implements the trace mechanism for bridge.
662 + *! Revision History
663 + *! ================
664 + *! 16-May-1997 dr Changed GT_Config member names to conform to coding
666 + *! 23-Apr-1997 ge Check for GT->TIDFXN for NULL before calling it.
667 + *! 03-Jan-1997 ge Changed GT_Config structure member names to eliminate
668 + *! preprocessor confusion with other macros.
671 +/* ----------------------------------- DSP/BIOS Bridge */
674 +/* ----------------------------------- This */
679 +#define GT_CLEAR '='
691 +static char *GT_1format = "%s - %d: ";
692 +static char *GT_2format = "%s - %d(%d): ";
694 +unsigned char *GT_tMask[GT_BOUND];
696 +static bool curInit = false;
697 +static char *separator;
698 +static unsigned char tabMem[GT_BOUND][sizeof(unsigned char) * GT_BOUND];
700 +static void error(char *string);
701 +static void setMask(s16 index1, s16 index2, char op, unsigned char mask);
704 + * ======== _GT_create ========
708 +void _GT_create(struct GT_Mask *mask, char *modName)
710 + mask->modName = modName;
711 + mask->flags = &(GT_tMask[modName[0] - 'A'][modName[1] - 'A']);
715 + * ======== GT_init ========
717 + * Initializes GT module.
724 + register unsigned char index1;
725 + register unsigned char index2;
730 + separator = " ,;/";
732 + for (index1 = 0; index1 < GT_BOUND; index1++) {
733 + GT_tMask[index1] = tabMem[index1];
734 + for (index2 = 0; index2 < GT_BOUND; index2++) {
736 + GT_tMask[index1][index2] = 0x00;
743 + * ======== _GT_set ========
745 + * Sets the trace string format.
748 +void _GT_set(char *str)
750 + enum GT_State state;
752 + s16 index1 = GT_BOUND; /* indicates all values */
753 + s16 index2 = GT_BOUND; /* indicates all values */
754 + char op = GT_CLEAR;
757 + register unsigned char mask = 0x0; /* no tracing */
764 + while (*str != '\0') {
765 + switch ((s32) state) {
769 + while (*sep != '\0') {
770 + if (*str == *sep) {
781 + case (s32) GT_FIRST:
782 + if (*str == GT_WILD) {
783 + /* indicates all values */
785 + /* indicates all values */
790 + index1 = (s16) (*str - 'a');
792 + index1 = (s16) (*str - 'A');
793 + if ((index1 >= 0) && (index1 < GT_BOUND))
800 + case (s32) GT_SECOND:
801 + if (*str == GT_WILD) {
802 + index2 = GT_BOUND; /* indicates all values */
807 + index2 = (s16) (*str - 'a');
809 + index2 = (s16) (*str - 'A');
810 + if ((index2 >= 0) && (index2 < GT_BOUND)) {
820 + mask = 0x0; /* no tracing */
822 + case (s32) GT_CLEAR:
834 + case (s32) GT_DIGITS:
835 + digit = (s16) (*str - '0');
836 + if ((digit >= 0) && (digit <= 7)) {
837 + mask |= (0x01 << digit);
841 + if (maskValid == true) {
842 + setMask(index1, index2, op, mask);
849 + error("illegal trace mask");
855 + setMask(index1, index2, op, mask);
859 + * ======== _GT_trace ========
861 + * Prints the input string onto standard output
864 +s32 _GT_trace(struct GT_Mask *mask, char *format, ...)
866 + s32 arg1, arg2, arg3, arg4, arg5, arg6;
869 + va_start(va, format);
871 + arg1 = va_arg(va, s32);
872 + arg2 = va_arg(va, s32);
873 + arg3 = va_arg(va, s32);
874 + arg4 = va_arg(va, s32);
875 + arg5 = va_arg(va, s32);
876 + arg6 = va_arg(va, s32);
880 + if (GT->PIDFXN == NULL) {
881 + (*GT->PRINTFXN)(GT_1format, mask->modName, GT->TIDFXN ?
882 + (*GT->TIDFXN)() : 0);
884 + (*GT->PRINTFXN)(GT_2format, mask->modName, (*GT->PIDFXN)(),
885 + GT->TIDFXN ? (*GT->TIDFXN)() : 0);
888 + (*GT->PRINTFXN)(format, arg1, arg2, arg3, arg4, arg5, arg6);
894 + * ======== error ========
896 + * Prints errors onto the standard output.
898 +static void error(char *string)
900 + (*GT->PRINTFXN)("GT: %s", string);
904 + * ======== setmask ========
906 + * Sets mask for the GT module.
909 +static void setMask(s16 index1, s16 index2, char op, u8 mask)
911 + register s16 index;
913 + if (index1 < GT_BOUND) {
914 + if (index2 < GT_BOUND) {
916 + case (s32) GT_CLEAR:
917 + GT_tMask[index1][index2] = mask;
920 + GT_tMask[index1][index2] |= mask;
923 + GT_tMask[index1][index2] &= ~mask;
926 + error("illegal trace mask");
930 + for (index2--; index2 >= 0; index2--) {
932 + case (s32) GT_CLEAR:
933 + GT_tMask[index1][index2] = mask;
936 + GT_tMask[index1][index2] |= mask;
939 + GT_tMask[index1][index2] &= ~mask;
942 + error("illegal trace mask");
948 + for (index1--; index1 >= 0; index1--) {
949 + if (index2 < GT_BOUND) {
951 + case (s32) GT_CLEAR:
952 + GT_tMask[index1][index2] = mask;
955 + GT_tMask[index1][index2] |= mask;
958 + GT_tMask[index1][index2] &= ~mask;
961 + error("illegal trace mask");
966 + for (index--; index >= 0; index--) {
968 + case (s32) GT_CLEAR:
969 + GT_tMask[index1][index] = mask;
972 + GT_tMask[index1][index] |= mask;
975 + GT_tMask[index1][index] &=
979 + error("illegal trace mask");
987 Index: lk/drivers/dsp/bridge/gen/uuidutil.c
988 ===================================================================
989 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
990 +++ lk/drivers/dsp/bridge/gen/uuidutil.c 2008-08-18 10:38:36.000000000 +0300
993 + * linux/drivers/dsp/bridge/gen/linux/uuidutil.c
995 + * DSP-BIOS Bridge driver support functions for TI OMAP processors.
997 + * Copyright (C) 2005-2006 Texas Instruments, Inc.
999 + * This package is free software; you can redistribute it and/or modify
1000 + * it under the terms of the GNU General Public License version 2 as
1001 + * published by the Free Software Foundation.
1003 + * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
1004 + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
1005 + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
1010 + * ======== uuidutil.c ========
1012 + * This file contains the implementation of UUID helper functions.
1014 + *! Revision History
1015 + *! ================
1016 + *! 23-Feb-2003 vp: Code review updates.
1017 + *! 18-Oct-2003 vp: Ported to Linux platform.
1018 + *! 31-Aug-2000 rr: UUID_UuidFromString bug fixed.
1019 + *! 29-Aug-2000 rr: Modified UUID_UuidFromString.
1020 + *! 09-Nov-2000 kc: Modified UUID_UuidFromString to simplify implementation.
1021 + *! 30-Oct-2000 kc: Modified UUID utility module function prefix.
1022 + *! 10-Aug-2000 kc: Created.
1026 +/* ----------------------------------- Host OS */
1027 +#include <host_os.h>
1029 +/* ----------------------------------- DSP/BIOS Bridge */
1031 +#include <dbdefs.h>
1033 +/* ----------------------------------- Trace & Debug */
1036 +/* ----------------------------------- This */
1037 +#include <uuidutil.h>
1040 + * ======== UUID_UuidToString ========
1042 + * Converts a struct DSP_UUID to a string.
1043 + * Note: snprintf format specifier is:
1044 + * %[flags] [width] [.precision] [{h | l | I64 | L}]type
1046 +void UUID_UuidToString(IN struct DSP_UUID *pUuid, OUT char *pszUuid,
1049 + s32 i; /* return result from snprintf. */
1051 + DBC_Require(pUuid && pszUuid);
1053 + i = snprintf(pszUuid, size,
1054 + "%.8X_%.4X_%.4X_%.2X%.2X_%.2X%.2X%.2X%.2X%.2X%.2X",
1055 + pUuid->ulData1, pUuid->usData2, pUuid->usData3,
1056 + pUuid->ucData4, pUuid->ucData5, pUuid->ucData6[0],
1057 + pUuid->ucData6[1], pUuid->ucData6[2], pUuid->ucData6[3],
1058 + pUuid->ucData6[4], pUuid->ucData6[5]);
1060 + DBC_Ensure(i != -1);
1064 + * ======== htoi ========
1066 + * Converts a hex value to a decimal integer.
1069 +static int htoi(char c)
1121 + * ======== UUID_UuidFromString ========
1123 + * Converts a string to a struct DSP_UUID.
1125 +void UUID_UuidFromString(IN char *pszUuid, OUT struct DSP_UUID *pUuid)
1130 + char *temp = pszUuid;
1133 + for (i = 0; i < 8; i++) {
1134 + /* Get first character in string */
1137 + /* Increase the results by new value */
1139 + result += htoi(c);
1141 + /* Go to next character in string */
1144 + pUuid->ulData1 = result;
1146 + /* Step over underscore */
1150 + for (i = 0; i < 4; i++) {
1151 + /* Get first character in string */
1154 + /* Increase the results by new value */
1156 + result += htoi(c);
1158 + /* Go to next character in string */
1161 + pUuid->usData2 = (u16)result;
1163 + /* Step over underscore */
1167 + for (i = 0; i < 4; i++) {
1168 + /* Get first character in string */
1171 + /* Increase the results by new value */
1173 + result += htoi(c);
1175 + /* Go to next character in string */
1178 + pUuid->usData3 = (u16)result;
1180 + /* Step over underscore */
1184 + for (i = 0; i < 2; i++) {
1185 + /* Get first character in string */
1188 + /* Increase the results by new value */
1190 + result += htoi(c);
1192 + /* Go to next character in string */
1195 + pUuid->ucData4 = (u8)result;
1198 + for (i = 0; i < 2; i++) {
1199 + /* Get first character in string */
1202 + /* Increase the results by new value */
1204 + result += htoi(c);
1206 + /* Go to next character in string */
1209 + pUuid->ucData5 = (u8)result;
1211 + /* Step over underscore */
1214 + for (j = 0; j < 6; j++) {
1216 + for (i = 0; i < 2; i++) {
1217 + /* Get first character in string */
1220 + /* Increase the results by new value */
1222 + result += htoi(c);
1224 + /* Go to next character in string */
1227 + pUuid->ucData6[j] = (u8)result;