Update from omapzoom 18-Aug-2008
[bridge-dev.git] / 0004-TI-DSP-BRIDGE-Generic-Utilities.patch
blob45eb741556a6d36d3c668a2c772eddc2326921b9
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
9 For details,
10 http://omapzoom.org/gf/project/omapbridge/docman/?subdir=3
12 Signed-off-by: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
13 ---
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
32 @@ -0,0 +1,107 @@
33 +/*
34 + * linux/drivers/dsp/bridge/gen/linux/_gt_para.c
35 + *
36 + * DSP-BIOS Bridge driver support functions for TI OMAP processors.
37 + *
38 + * Copyright (C) 2005-2006 Texas Instruments, Inc.
39 + *
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.
43 + *
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.
47 + */
50 +/*
51 + * ======== _gt_para.c ========
52 + * Description:
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.
58 + *
59 + *! Revision History:
60 + *! ================
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.
66 + *!
67 + */
69 +/* ----------------------------------- Host OS */
70 +#include <host_os.h>
72 +/* ----------------------------------- DSP/BIOS Bridge */
73 +#include <std.h>
75 +/* ----------------------------------- Trace & Debug */
76 +#include <gt.h>
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 */
89 +};
91 +/* ----------------------------------- Globals */
92 +struct GT_Config *GT = &_GT_params;
94 +/*
95 + * ======== GT_nop ========
96 + */
97 +static s32 GT_nop(void)
99 + return 0;
103 + * ======== error ========
104 + * purpose:
105 + * Prints error onto the standard output.
106 + */
107 +static void error(char *fmt, ...)
109 + s32 arg1, arg2, arg3, arg4, arg5, arg6;
111 + va_list va;
113 + va_start(va, fmt);
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);
122 + va_end(va);
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 "
130 + "are disabled\n");
131 + } else {
132 + set_current_state(TASK_INTERRUPTIBLE);
133 + flush_signals(current);
134 + schedule();
135 + flush_signals(current);
136 + printk(KERN_INFO "Signaled in error function\n");
138 +#endif
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
144 @@ -0,0 +1,182 @@
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.
159 + */
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().
173 + *!
174 + */
176 +/* ----------------------------------- DSP/BIOS Bridge */
177 +#include <std.h>
178 +#include <linux/types.h>
179 +/* ----------------------------------- This */
180 +#include <gs.h>
181 +#include <gb.h>
183 +typedef GB_BitNum GB_WordNum;
185 +struct GB_TMap {
186 + GB_BitNum len;
187 + GB_WordNum wcnt;
188 + u32 *words;
192 + * ======== GB_clear ========
193 + * purpose:
194 + * Clears a bit in the bit map.
195 + */
197 +void GB_clear(struct GB_TMap *map, GB_BitNum bitn)
199 + u32 mask;
201 + mask = 1L << (bitn % BITS_PER_LONG);
202 + map->words[bitn / BITS_PER_LONG] &= ~mask;
206 + * ======== GB_create ========
207 + * purpose:
208 + * Creates a bit map.
209 + */
211 +struct GB_TMap *GB_create(GB_BitNum len)
213 + struct GB_TMap *map;
214 + GB_WordNum i;
215 + map = (struct GB_TMap *)GS_alloc(sizeof(struct GB_TMap));
216 + if (map != NULL) {
217 + map->len = len;
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;
224 + } else {
225 + GS_frees(map, sizeof(struct GB_TMap));
226 + map = NULL;
230 + return map;
234 + * ======== GB_delete ========
235 + * purpose:
236 + * Frees a bit map.
237 + */
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 ========
247 + * purpose:
248 + * Finds a free bit and sets it.
249 + */
250 +GB_BitNum GB_findandset(struct GB_TMap *map)
252 + GB_BitNum bitn;
254 + bitn = GB_minclear(map);
256 + if (bitn != GB_NOBITS)
257 + GB_set(map, bitn);
259 + return bitn;
263 + * ======== GB_minclear ========
264 + * purpose:
265 + * returns the location of the first unset bit in the bit map.
266 + */
267 +GB_BitNum GB_minclear(struct GB_TMap *map)
269 + GB_BitNum bit_location = 0;
270 + GB_BitNum bitAcc = 0;
271 + GB_WordNum i;
272 + GB_BitNum bit;
273 + u32 *word;
275 + for (word = map->words, i = 0; i < map->wcnt; word++, i++) {
276 + if (~*word) {
277 + for (bit = 0; bit < BITS_PER_LONG; bit++, bitAcc++) {
278 + if (bitAcc == map->len)
279 + return GB_NOBITS;
281 + if (~*word & (1L << bit)) {
282 + bit_location = i * BITS_PER_LONG + bit;
283 + return bit_location;
287 + } else {
288 + bitAcc += BITS_PER_LONG;
292 + return GB_NOBITS;
296 + * ======== GB_set ========
297 + * purpose:
298 + * Sets a bit in the bit map.
299 + */
301 +void GB_set(struct GB_TMap *map, GB_BitNum bitn)
303 + u32 mask;
305 + mask = 1L << (bitn % BITS_PER_LONG);
306 + map->words[bitn / BITS_PER_LONG] |= mask;
310 + * ======== GB_test ========
311 + * purpose:
312 + * Returns true if the bit is set in the specified location.
313 + */
315 +bool GB_test(struct GB_TMap *map, GB_BitNum bitn)
317 + bool state;
318 + u32 mask;
319 + u32 word;
321 + mask = 1L << (bitn % BITS_PER_LONG);
322 + word = map->words[bitn / BITS_PER_LONG];
323 + state = word & mask ? TRUE : FALSE;
325 + return state;
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
331 @@ -0,0 +1,191 @@
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.
346 + */
350 + * ======== gh.c ========
351 + */
353 +#include <std.h>
355 +#include <host_os.h>
357 +#include <gs.h>
359 +#include <gh.h>
361 +struct Elem {
362 + struct Elem *next;
363 + u8 data[1];
366 +struct GH_THashTab {
367 + u16 maxBucket;
368 + u16 valSize;
369 + struct Elem **buckets;
370 + u16(*hash) (void *, u16);
371 + bool(*match) (void *, void *);
372 + void(*delete) (void *);
375 +static void Nop(void *p);
376 +static s32 curInit;
377 +static void myfree(void *ptr, s32 size);
380 + * ======== GH_create ========
381 + */
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;
388 + u16 i;
389 + hashTab = (struct GH_THashTab *)GS_alloc(sizeof(struct GH_THashTab));
390 + if (hashTab == NULL)
391 + return 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);
402 + return NULL;
405 + for (i = 0; i < maxBucket; i++)
406 + hashTab->buckets[i] = NULL;
408 + return hashTab;
412 + * ======== GH_delete ========
413 + */
414 +void GH_delete(struct GH_THashTab *hashTab)
416 + struct Elem *elem, *next;
417 + u16 i;
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;
423 + elem = next) {
424 + next = elem->next;
425 + (*hashTab->delete) (elem->data);
426 + myfree(elem, sizeof(struct Elem) - 1 +
427 + hashTab->valSize);
431 + myfree(hashTab->buckets, sizeof(struct Elem *)
432 + * hashTab->maxBucket);
435 + myfree(hashTab, sizeof(struct GH_THashTab));
440 + * ======== GH_exit ========
441 + */
443 +void GH_exit(void)
445 + if (curInit-- == 1)
446 + GS_exit();
451 + * ======== GH_find ========
452 + */
454 +void *GH_find(struct GH_THashTab *hashTab, void *key)
456 + struct Elem *elem;
458 + elem = hashTab->buckets[(*hashTab->hash)(key, hashTab->maxBucket)];
460 + for (; elem; elem = elem->next) {
461 + if ((*hashTab->match)(key, elem->data))
462 + return elem->data;
465 + return NULL;
469 + * ======== GH_init ========
470 + */
472 +void GH_init(void)
474 + if (curInit++ == 0)
475 + GS_init();
479 + * ======== GH_insert ========
480 + */
482 +void *GH_insert(struct GH_THashTab *hashTab, void *key, void *value)
484 + struct Elem *elem;
485 + u16 i;
486 + char *src, *dst;
488 + elem = (struct Elem *)GS_alloc(sizeof(struct Elem) - 1 +
489 + hashTab->valSize);
490 + if (elem != NULL) {
492 + dst = (char *)elem->data;
493 + src = (char *)value;
494 + for (i = 0; i < hashTab->valSize; i++)
495 + *dst++ = *src++;
497 + i = (*hashTab->hash)(key, hashTab->maxBucket);
498 + elem->next = hashTab->buckets[i];
499 + hashTab->buckets[i] = elem;
501 + return elem->data;
504 + return NULL;
508 + * ======== Nop ========
509 + */
510 +/* ARGSUSED */
511 +static void Nop(void *p)
513 + p = p; /* stifle compiler warning */
517 + * ======== myfree ========
518 + */
519 +static void myfree(void *ptr, s32 size)
521 + GS_free(ptr);
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
527 @@ -0,0 +1,108 @@
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.
542 + */
546 + * ======== gs.c ========
547 + * Description:
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.
557 + */
559 +/* ----------------------------------- DSP/BIOS Bridge */
560 +#include <std.h>
561 +#include <dbdefs.h>
562 +#include <linux/types.h>
563 +/* ----------------------------------- OS Adaptation Layer */
564 +#include <mem.h>
566 +/* ----------------------------------- This */
567 +#include <gs.h>
569 +/* ----------------------------------- Globals */
570 +static u32 cumsize;
573 + * ======== GS_alloc ========
574 + * purpose:
575 + * Allocates memory of the specified size.
576 + */
577 +void *GS_alloc(u32 size)
579 + void *p;
581 + p = MEM_Calloc(size, MEM_PAGED);
582 + if (p == NULL)
583 + return NULL;
584 + cumsize += size;
585 + return p;
589 + * ======== GS_exit ========
590 + * purpose:
591 + * Discontinue the usage of the GS module.
592 + */
593 +void GS_exit(void)
595 + MEM_Exit();
599 + * ======== GS_free ========
600 + * purpose:
601 + * Frees the memory.
602 + */
603 +void GS_free(void *ptr)
605 + MEM_Free(ptr);
606 + /* ack! no size info */
607 + /* cumsize -= size; */
611 + * ======== GS_frees ========
612 + * purpose:
613 + * Frees the memory.
614 + */
615 +void GS_frees(void *ptr, u32 size)
617 + MEM_Free(ptr);
618 + cumsize -= size;
622 + * ======== GS_init ========
623 + * purpose:
624 + * Initializes the GS module.
625 + */
626 +void GS_init(void)
628 + static bool curInit = false;
630 + if (curInit == false) {
631 + curInit = true;
633 + MEM_Init();
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
640 @@ -0,0 +1,346 @@
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.
655 + */
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
665 + *! standards.
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.
669 + */
671 +/* ----------------------------------- DSP/BIOS Bridge */
672 +#include <std.h>
674 +/* ----------------------------------- This */
675 +#include <gt.h>
677 +#define GT_WILD '*'
679 +#define GT_CLEAR '='
680 +#define GT_ON '+'
681 +#define GT_OFF '-'
683 +enum GT_State {
684 + GT_SEP,
685 + GT_FIRST,
686 + GT_SECOND,
687 + GT_OP,
688 + GT_DIGITS
689 +} ;
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 ========
705 + * purpose:
706 + * Creates GT mask.
707 + */
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 ========
716 + * purpose:
717 + * Initializes GT module.
718 + */
719 +#ifdef GT_init
720 +#undef GT_init
721 +#endif
722 +void GT_init(void)
724 + register unsigned char index1;
725 + register unsigned char index2;
727 + if (!curInit) {
728 + curInit = true;
730 + separator = " ,;/";
732 + for (index1 = 0; index1 < GT_BOUND; index1++) {
733 + GT_tMask[index1] = tabMem[index1];
734 + for (index2 = 0; index2 < GT_BOUND; index2++) {
735 + /* no tracing */
736 + GT_tMask[index1][index2] = 0x00;
743 + * ======== _GT_set ========
744 + * purpose:
745 + * Sets the trace string format.
746 + */
748 +void _GT_set(char *str)
750 + enum GT_State state;
751 + char *sep;
752 + s16 index1 = GT_BOUND; /* indicates all values */
753 + s16 index2 = GT_BOUND; /* indicates all values */
754 + char op = GT_CLEAR;
755 + bool maskValid;
756 + s16 digit;
757 + register unsigned char mask = 0x0; /* no tracing */
759 + if (str == NULL)
760 + return;
762 + maskValid = false;
763 + state = GT_SEP;
764 + while (*str != '\0') {
765 + switch ((s32) state) {
766 + case (s32) GT_SEP:
767 + maskValid = false;
768 + sep = separator;
769 + while (*sep != '\0') {
770 + if (*str == *sep) {
771 + str++;
772 + break;
773 + } else {
774 + sep++;
777 + if (*sep == '\0')
778 + state = GT_FIRST;
780 + break;
781 + case (s32) GT_FIRST:
782 + if (*str == GT_WILD) {
783 + /* indicates all values */
784 + index1 = GT_BOUND;
785 + /* indicates all values */
786 + index2 = GT_BOUND;
787 + state = GT_OP;
788 + } else {
789 + if (*str >= 'a')
790 + index1 = (s16) (*str - 'a');
791 + else
792 + index1 = (s16) (*str - 'A');
793 + if ((index1 >= 0) && (index1 < GT_BOUND))
794 + state = GT_SECOND;
795 + else
796 + state = GT_SEP;
798 + str++;
799 + break;
800 + case (s32) GT_SECOND:
801 + if (*str == GT_WILD) {
802 + index2 = GT_BOUND; /* indicates all values */
803 + state = GT_OP;
804 + str++;
805 + } else {
806 + if (*str >= 'a')
807 + index2 = (s16) (*str - 'a');
808 + else
809 + index2 = (s16) (*str - 'A');
810 + if ((index2 >= 0) && (index2 < GT_BOUND)) {
811 + state = GT_OP;
812 + str++;
813 + } else {
814 + state = GT_SEP;
817 + break;
818 + case (s32) GT_OP:
819 + op = *str;
820 + mask = 0x0; /* no tracing */
821 + switch (op) {
822 + case (s32) GT_CLEAR:
823 + maskValid = true;
824 + case (s32) GT_ON:
825 + case (s32) GT_OFF:
826 + state = GT_DIGITS;
827 + str++;
828 + break;
829 + default:
830 + state = GT_SEP;
831 + break;
833 + break;
834 + case (s32) GT_DIGITS:
835 + digit = (s16) (*str - '0');
836 + if ((digit >= 0) && (digit <= 7)) {
837 + mask |= (0x01 << digit);
838 + maskValid = true;
839 + str++;
840 + } else {
841 + if (maskValid == true) {
842 + setMask(index1, index2, op, mask);
843 + maskValid = false;
845 + state = GT_SEP;
847 + break;
848 + default:
849 + error("illegal trace mask");
850 + break;
854 + if (maskValid)
855 + setMask(index1, index2, op, mask);
859 + * ======== _GT_trace ========
860 + * purpose:
861 + * Prints the input string onto standard output
862 + */
864 +s32 _GT_trace(struct GT_Mask *mask, char *format, ...)
866 + s32 arg1, arg2, arg3, arg4, arg5, arg6;
867 + va_list va;
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);
878 + va_end(va);
879 +#ifdef DEBUG
880 + if (GT->PIDFXN == NULL) {
881 + (*GT->PRINTFXN)(GT_1format, mask->modName, GT->TIDFXN ?
882 + (*GT->TIDFXN)() : 0);
883 + } else {
884 + (*GT->PRINTFXN)(GT_2format, mask->modName, (*GT->PIDFXN)(),
885 + GT->TIDFXN ? (*GT->TIDFXN)() : 0);
887 +#endif
888 + (*GT->PRINTFXN)(format, arg1, arg2, arg3, arg4, arg5, arg6);
890 + return 0;
894 + * ======== error ========
895 + * purpose:
896 + * Prints errors onto the standard output.
897 + */
898 +static void error(char *string)
900 + (*GT->PRINTFXN)("GT: %s", string);
904 + * ======== setmask ========
905 + * purpose:
906 + * Sets mask for the GT module.
907 + */
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) {
915 + switch (op) {
916 + case (s32) GT_CLEAR:
917 + GT_tMask[index1][index2] = mask;
918 + break;
919 + case (s32) GT_ON:
920 + GT_tMask[index1][index2] |= mask;
921 + break;
922 + case (s32) GT_OFF:
923 + GT_tMask[index1][index2] &= ~mask;
924 + break;
925 + default:
926 + error("illegal trace mask");
927 + break;
929 + } else {
930 + for (index2--; index2 >= 0; index2--) {
931 + switch (op) {
932 + case (s32) GT_CLEAR:
933 + GT_tMask[index1][index2] = mask;
934 + break;
935 + case (s32) GT_ON:
936 + GT_tMask[index1][index2] |= mask;
937 + break;
938 + case (s32) GT_OFF:
939 + GT_tMask[index1][index2] &= ~mask;
940 + break;
941 + default:
942 + error("illegal trace mask");
943 + break;
947 + } else {
948 + for (index1--; index1 >= 0; index1--) {
949 + if (index2 < GT_BOUND) {
950 + switch (op) {
951 + case (s32) GT_CLEAR:
952 + GT_tMask[index1][index2] = mask;
953 + break;
954 + case (s32) GT_ON:
955 + GT_tMask[index1][index2] |= mask;
956 + break;
957 + case (s32) GT_OFF:
958 + GT_tMask[index1][index2] &= ~mask;
959 + break;
960 + default:
961 + error("illegal trace mask");
962 + break;
964 + } else {
965 + index = GT_BOUND;
966 + for (index--; index >= 0; index--) {
967 + switch (op) {
968 + case (s32) GT_CLEAR:
969 + GT_tMask[index1][index] = mask;
970 + break;
971 + case (s32) GT_ON:
972 + GT_tMask[index1][index] |= mask;
973 + break;
974 + case (s32) GT_OFF:
975 + GT_tMask[index1][index] &=
976 + ~mask;
977 + break;
978 + default:
979 + error("illegal trace mask");
980 + break;
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
991 @@ -0,0 +1,238 @@
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.
1006 + */
1010 + * ======== uuidutil.c ========
1011 + * Description:
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.
1023 + *!
1024 + */
1026 +/* ----------------------------------- Host OS */
1027 +#include <host_os.h>
1029 +/* ----------------------------------- DSP/BIOS Bridge */
1030 +#include <std.h>
1031 +#include <dbdefs.h>
1033 +/* ----------------------------------- Trace & Debug */
1034 +#include <dbc.h>
1036 +/* ----------------------------------- This */
1037 +#include <uuidutil.h>
1040 + * ======== UUID_UuidToString ========
1041 + * Purpose:
1042 + * Converts a struct DSP_UUID to a string.
1043 + * Note: snprintf format specifier is:
1044 + * %[flags] [width] [.precision] [{h | l | I64 | L}]type
1045 + */
1046 +void UUID_UuidToString(IN struct DSP_UUID *pUuid, OUT char *pszUuid,
1047 + IN s32 size)
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 ========
1065 + * Purpose:
1066 + * Converts a hex value to a decimal integer.
1067 + */
1069 +static int htoi(char c)
1071 + switch (c) {
1072 + case '0':
1073 + return 0;
1074 + case '1':
1075 + return 1;
1076 + case '2':
1077 + return 2;
1078 + case '3':
1079 + return 3;
1080 + case '4':
1081 + return 4;
1082 + case '5':
1083 + return 5;
1084 + case '6':
1085 + return 6;
1086 + case '7':
1087 + return 7;
1088 + case '8':
1089 + return 8;
1090 + case '9':
1091 + return 9;
1092 + case 'A':
1093 + return 10;
1094 + case 'B':
1095 + return 11;
1096 + case 'C':
1097 + return 12;
1098 + case 'D':
1099 + return 13;
1100 + case 'E':
1101 + return 14;
1102 + case 'F':
1103 + return 15;
1104 + case 'a':
1105 + return 10;
1106 + case 'b':
1107 + return 11;
1108 + case 'c':
1109 + return 12;
1110 + case 'd':
1111 + return 13;
1112 + case 'e':
1113 + return 14;
1114 + case 'f':
1115 + return 15;
1117 + return 0;
1121 + * ======== UUID_UuidFromString ========
1122 + * Purpose:
1123 + * Converts a string to a struct DSP_UUID.
1124 + */
1125 +void UUID_UuidFromString(IN char *pszUuid, OUT struct DSP_UUID *pUuid)
1127 + char c;
1128 + s32 i, j;
1129 + s32 result;
1130 + char *temp = pszUuid;
1132 + result = 0;
1133 + for (i = 0; i < 8; i++) {
1134 + /* Get first character in string */
1135 + c = *temp;
1137 + /* Increase the results by new value */
1138 + result *= 16;
1139 + result += htoi(c);
1141 + /* Go to next character in string */
1142 + temp++;
1144 + pUuid->ulData1 = result;
1146 + /* Step over underscore */
1147 + temp++;
1149 + result = 0;
1150 + for (i = 0; i < 4; i++) {
1151 + /* Get first character in string */
1152 + c = *temp;
1154 + /* Increase the results by new value */
1155 + result *= 16;
1156 + result += htoi(c);
1158 + /* Go to next character in string */
1159 + temp++;
1161 + pUuid->usData2 = (u16)result;
1163 + /* Step over underscore */
1164 + temp++;
1166 + result = 0;
1167 + for (i = 0; i < 4; i++) {
1168 + /* Get first character in string */
1169 + c = *temp;
1171 + /* Increase the results by new value */
1172 + result *= 16;
1173 + result += htoi(c);
1175 + /* Go to next character in string */
1176 + temp++;
1178 + pUuid->usData3 = (u16)result;
1180 + /* Step over underscore */
1181 + temp++;
1183 + result = 0;
1184 + for (i = 0; i < 2; i++) {
1185 + /* Get first character in string */
1186 + c = *temp;
1188 + /* Increase the results by new value */
1189 + result *= 16;
1190 + result += htoi(c);
1192 + /* Go to next character in string */
1193 + temp++;
1195 + pUuid->ucData4 = (u8)result;
1197 + result = 0;
1198 + for (i = 0; i < 2; i++) {
1199 + /* Get first character in string */
1200 + c = *temp;
1202 + /* Increase the results by new value */
1203 + result *= 16;
1204 + result += htoi(c);
1206 + /* Go to next character in string */
1207 + temp++;
1209 + pUuid->ucData5 = (u8)result;
1211 + /* Step over underscore */
1212 + temp++;
1214 + for (j = 0; j < 6; j++) {
1215 + result = 0;
1216 + for (i = 0; i < 2; i++) {
1217 + /* Get first character in string */
1218 + c = *temp;
1220 + /* Increase the results by new value */
1221 + result *= 16;
1222 + result += htoi(c);
1224 + /* Go to next character in string */
1225 + temp++;
1227 + pUuid->ucData6[j] = (u8)result;