• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2008, Google Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *  * Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  *  * Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in
12  *    the documentation and/or other materials provided with the
13  *    distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  * SUCH DAMAGE.
27  */
28 
29 struct smem_heap_info
30 {
31 	unsigned initialized;
32 	unsigned free_offset;
33 	unsigned heap_remaining;
34 	unsigned reserved;
35 };
36 
37 struct smem_heap_entry
38 {
39 	unsigned allocated;
40 	unsigned offset;
41 	unsigned size;
42 	unsigned reserved;
43 };
44 
45 struct smem_proc_comm
46 {
47 	unsigned command;
48 	unsigned status;
49 	unsigned data1;
50 	unsigned data2;
51 };
52 
53 struct smem_shared
54 {
55 	struct smem_proc_comm proc_comm[4];
56 	unsigned version[32];
57 	struct smem_heap_info heap_info;
58 	struct smem_heap_entry heap_toc[128];
59 };
60 
61 struct smsm_shared
62 {
63 	unsigned host;
64 	unsigned state;
65 };
66 
67 #define SZ_DIAG_ERR_MSG 0xC8
68 #define ID_DIAG_ERR_MSG 6
69 #define ID_HEAP_INFO    3
70 #define ID_SMD_CHANNELS 13
71 #define ID_SHARED_STATE 82
72 
73 
dump_smem_info(void)74 void dump_smem_info(void)
75 {
76     unsigned n;
77     struct smem_heap_entry *he;
78     struct smem_shared *shared = (void*) 0x01f00000;
79     dprintf("--- smem info ---\n");
80 
81     dprintf("heap: init=%x free=%x remain=%x\n",
82             shared->heap_info.initialized,
83             shared->heap_info.free_offset,
84             shared->heap_info.heap_remaining);
85 
86     he = shared->heap_toc;
87     for(n = 0; n < 128; n++) {
88         if(he->allocated) {
89             dprintf("%x: alloc=%x offset=%x size=%x\n",
90                     n, he->allocated, he->offset, he->size);
91         }
92         he++;
93     }
94 }
95