Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
uuidutil.c
Go to the documentation of this file.
1 /*
2  * uuidutil.c
3  *
4  * DSP-BIOS Bridge driver support functions for TI OMAP processors.
5  *
6  * This file contains the implementation of UUID helper functions.
7  *
8  * Copyright (C) 2005-2006 Texas Instruments, Inc.
9  *
10  * This package is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License version 2 as
12  * published by the Free Software Foundation.
13  *
14  * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
15  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
16  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
17  */
18 #include <linux/types.h>
19 
20 /* ----------------------------------- Host OS */
21 #include <dspbridge/host_os.h>
22 
23 /* ----------------------------------- DSP/BIOS Bridge */
24 #include <dspbridge/dbdefs.h>
25 
26 /* ----------------------------------- This */
27 #include <dspbridge/uuidutil.h>
28 
29 static s32 uuid_hex_to_bin(char *buf, s32 len)
30 {
31  s32 i;
32  s32 result = 0;
33  int value;
34 
35  for (i = 0; i < len; i++) {
36  value = hex_to_bin(*buf++);
37  result *= 16;
38  if (value > 0)
39  result += value;
40  }
41 
42  return result;
43 }
44 
45 /*
46  * ======== uuid_uuid_from_string ========
47  * Purpose:
48  * Converts a string to a struct dsp_uuid.
49  */
50 void uuid_uuid_from_string(char *sz_uuid, struct dsp_uuid *uuid_obj)
51 {
52  s32 j;
53 
54  uuid_obj->data1 = uuid_hex_to_bin(sz_uuid, 8);
55  sz_uuid += 8;
56 
57  /* Step over underscore */
58  sz_uuid++;
59 
60  uuid_obj->data2 = (u16) uuid_hex_to_bin(sz_uuid, 4);
61  sz_uuid += 4;
62 
63  /* Step over underscore */
64  sz_uuid++;
65 
66  uuid_obj->data3 = (u16) uuid_hex_to_bin(sz_uuid, 4);
67  sz_uuid += 4;
68 
69  /* Step over underscore */
70  sz_uuid++;
71 
72  uuid_obj->data4 = (u8) uuid_hex_to_bin(sz_uuid, 2);
73  sz_uuid += 2;
74 
75  uuid_obj->data5 = (u8) uuid_hex_to_bin(sz_uuid, 2);
76  sz_uuid += 2;
77 
78  /* Step over underscore */
79  sz_uuid++;
80 
81  for (j = 0; j < 6; j++) {
82  uuid_obj->data6[j] = (u8) uuid_hex_to_bin(sz_uuid, 2);
83  sz_uuid += 2;
84  }
85 }