File: | obj-scan-build/../i386/i386/phys.c |
Location: | line 133, column 3 |
Description: | Function call argument is an uninitialized value |
1 | /* | |||
2 | * Mach Operating System | |||
3 | * Copyright (c) 1991,1990,1989 Carnegie Mellon University | |||
4 | * All Rights Reserved. | |||
5 | * | |||
6 | * Permission to use, copy, modify and distribute this software and its | |||
7 | * documentation is hereby granted, provided that both the copyright | |||
8 | * notice and this permission notice appear in all copies of the | |||
9 | * software, derivative works or modified versions, and any portions | |||
10 | * thereof, and that both notices appear in supporting documentation. | |||
11 | * | |||
12 | * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" | |||
13 | * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR | |||
14 | * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. | |||
15 | * | |||
16 | * Carnegie Mellon requests users of this software to return to | |||
17 | * | |||
18 | * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU | |||
19 | * School of Computer Science | |||
20 | * Carnegie Mellon University | |||
21 | * Pittsburgh PA 15213-3890 | |||
22 | * | |||
23 | * any improvements or extensions that they make and grant Carnegie Mellon | |||
24 | * the rights to redistribute these changes. | |||
25 | */ | |||
26 | ||||
27 | #include <string.h> | |||
28 | ||||
29 | #include <mach/boolean.h> | |||
30 | #include <mach/xen.h> | |||
31 | #include <kern/task.h> | |||
32 | #include <kern/thread.h> | |||
33 | #include <vm/vm_map.h> | |||
34 | #include "vm_param.h" | |||
35 | #include <mach/vm_prot.h> | |||
36 | #include <vm/vm_kern.h> | |||
37 | #include <vm/vm_page.h> | |||
38 | ||||
39 | #include <i3861/pmap.h> | |||
40 | #include <i3861/model_dep.h> | |||
41 | #include <mach/machine/vm_param.h> | |||
42 | ||||
43 | #define INTEL_PTE_W(p)(0x00000001 | 0x00000002 | 0x00000020 | 0x00000040 | ((p) & 0x00007ffffffff000ULL)) (INTEL_PTE_VALID0x00000001 | INTEL_PTE_WRITE0x00000002 | INTEL_PTE_REF0x00000020 | INTEL_PTE_MOD0x00000040 | pa_to_pte(p)((p) & 0x00007ffffffff000ULL)) | |||
44 | #define INTEL_PTE_R(p)(0x00000001 | 0x00000020 | ((p) & 0x00007ffffffff000ULL)) (INTEL_PTE_VALID0x00000001 | INTEL_PTE_REF0x00000020 | pa_to_pte(p)((p) & 0x00007ffffffff000ULL)) | |||
45 | ||||
46 | /* | |||
47 | * pmap_zero_page zeros the specified (machine independent) page. | |||
48 | */ | |||
49 | void | |||
50 | pmap_zero_page(p) | |||
51 | vm_offset_t p; | |||
52 | { | |||
53 | assert(p != vm_page_fictitious_addr)({ if (!(p != vm_page_fictitious_addr)) Assert("p != vm_page_fictitious_addr" , "../i386/i386/phys.c", 53); }); | |||
54 | vm_offset_t v; | |||
55 | pmap_mapwindow_t *map; | |||
56 | ||||
57 | if (p >= phys_last_addr) | |||
58 | { | |||
59 | map = pmap_get_mapwindow(INTEL_PTE_W(p)(0x00000001 | 0x00000002 | 0x00000020 | 0x00000040 | ((p) & 0x00007ffffffff000ULL))); | |||
60 | v = map->vaddr; | |||
61 | } | |||
62 | else | |||
63 | v = phystokv(p)((vm_offset_t)(p) + 0xC0000000UL); | |||
64 | ||||
65 | memset((void*) v, 0, PAGE_SIZE(1 << 12)); | |||
66 | ||||
67 | if (p >= phys_last_addr) | |||
68 | pmap_put_mapwindow(map); | |||
69 | } | |||
70 | ||||
71 | /* | |||
72 | * pmap_copy_page copies the specified (machine independent) pages. | |||
73 | */ | |||
74 | void | |||
75 | pmap_copy_page(src, dst) | |||
76 | vm_offset_t src, dst; | |||
77 | { | |||
78 | vm_offset_t src_addr_v, dst_addr_v; | |||
79 | pmap_mapwindow_t *src_map, *dst_map; | |||
80 | assert(src != vm_page_fictitious_addr)({ if (!(src != vm_page_fictitious_addr)) Assert("src != vm_page_fictitious_addr" , "../i386/i386/phys.c", 80); }); | |||
81 | assert(dst != vm_page_fictitious_addr)({ if (!(dst != vm_page_fictitious_addr)) Assert("dst != vm_page_fictitious_addr" , "../i386/i386/phys.c", 81); }); | |||
82 | ||||
83 | if (src >= phys_last_addr) | |||
84 | { | |||
85 | src_map = pmap_get_mapwindow(INTEL_PTE_R(src)(0x00000001 | 0x00000020 | ((src) & 0x00007ffffffff000ULL ))); | |||
86 | src_addr_v = src_map->vaddr; | |||
87 | } | |||
88 | else | |||
89 | src_addr_v = phystokv(src)((vm_offset_t)(src) + 0xC0000000UL); | |||
90 | ||||
91 | if (dst >= phys_last_addr) | |||
92 | { | |||
93 | dst_map = pmap_get_mapwindow(INTEL_PTE_W(dst)(0x00000001 | 0x00000002 | 0x00000020 | 0x00000040 | ((dst) & 0x00007ffffffff000ULL))); | |||
94 | dst_addr_v = dst_map->vaddr; | |||
95 | } | |||
96 | else | |||
97 | dst_addr_v = phystokv(dst)((vm_offset_t)(dst) + 0xC0000000UL); | |||
98 | ||||
99 | memcpy((void *) dst_addr_v, (void *) src_addr_v, PAGE_SIZE(1 << 12)); | |||
100 | ||||
101 | if (src >= phys_last_addr) | |||
102 | pmap_put_mapwindow(src_map); | |||
103 | if (dst >= phys_last_addr) | |||
104 | pmap_put_mapwindow(dst_map); | |||
105 | } | |||
106 | ||||
107 | /* | |||
108 | * copy_to_phys(src_addr_v, dst_addr_p, count) | |||
109 | * | |||
110 | * Copy virtual memory to physical memory | |||
111 | */ | |||
112 | void | |||
113 | copy_to_phys(src_addr_v, dst_addr_p, count) | |||
114 | vm_offset_t src_addr_v, dst_addr_p; | |||
115 | int count; | |||
116 | { | |||
117 | vm_offset_t dst_addr_v; | |||
118 | pmap_mapwindow_t *dst_map; | |||
| ||||
119 | assert(dst_addr_p != vm_page_fictitious_addr)({ if (!(dst_addr_p != vm_page_fictitious_addr)) Assert("dst_addr_p != vm_page_fictitious_addr" , "../i386/i386/phys.c", 119); }); | |||
120 | assert(pa_to_pte(dst_addr_p + count-1) == pa_to_pte(dst_addr_p))({ if (!(((dst_addr_p + count-1) & 0x00007ffffffff000ULL) == ((dst_addr_p) & 0x00007ffffffff000ULL))) Assert("pa_to_pte(dst_addr_p + count-1) == pa_to_pte(dst_addr_p)" , "../i386/i386/phys.c", 120); }); | |||
121 | ||||
122 | if (dst_addr_p >= phys_last_addr) | |||
123 | { | |||
124 | dst_map = pmap_get_mapwindow(INTEL_PTE_W(dst_addr_p)(0x00000001 | 0x00000002 | 0x00000020 | 0x00000040 | ((dst_addr_p ) & 0x00007ffffffff000ULL))); | |||
125 | dst_addr_v = dst_map->vaddr; | |||
126 | } | |||
127 | else | |||
128 | dst_addr_v = phystokv(dst_addr_p)((vm_offset_t)(dst_addr_p) + 0xC0000000UL); | |||
129 | ||||
130 | memcpy((void *)dst_addr_v, (void *)src_addr_v, count); | |||
131 | ||||
132 | if (dst_addr_p >= phys_last_addr) | |||
133 | pmap_put_mapwindow(dst_map); | |||
| ||||
134 | } | |||
135 | ||||
136 | /* | |||
137 | * copy_from_phys(src_addr_p, dst_addr_v, count) | |||
138 | * | |||
139 | * Copy physical memory to virtual memory. The virtual memory | |||
140 | * is assumed to be present (e.g. the buffer pool). | |||
141 | */ | |||
142 | void | |||
143 | copy_from_phys(src_addr_p, dst_addr_v, count) | |||
144 | vm_offset_t src_addr_p, dst_addr_v; | |||
145 | int count; | |||
146 | { | |||
147 | vm_offset_t src_addr_v; | |||
148 | pmap_mapwindow_t *src_map; | |||
149 | assert(src_addr_p != vm_page_fictitious_addr)({ if (!(src_addr_p != vm_page_fictitious_addr)) Assert("src_addr_p != vm_page_fictitious_addr" , "../i386/i386/phys.c", 149); }); | |||
150 | assert(pa_to_pte(src_addr_p + count-1) == pa_to_pte(src_addr_p))({ if (!(((src_addr_p + count-1) & 0x00007ffffffff000ULL) == ((src_addr_p) & 0x00007ffffffff000ULL))) Assert("pa_to_pte(src_addr_p + count-1) == pa_to_pte(src_addr_p)" , "../i386/i386/phys.c", 150); }); | |||
151 | ||||
152 | if (src_addr_p >= phys_last_addr) | |||
153 | { | |||
154 | src_map = pmap_get_mapwindow(INTEL_PTE_R(src_addr_p)(0x00000001 | 0x00000020 | ((src_addr_p) & 0x00007ffffffff000ULL ))); | |||
155 | src_addr_v = src_map->vaddr; | |||
156 | } | |||
157 | else | |||
158 | src_addr_v = phystokv(src_addr_p)((vm_offset_t)(src_addr_p) + 0xC0000000UL); | |||
159 | ||||
160 | memcpy((void *)dst_addr_v, (void *)src_addr_v, count); | |||
161 | ||||
162 | if (src_addr_p >= phys_last_addr) | |||
163 | pmap_put_mapwindow(src_map); | |||
164 | } | |||
165 | ||||
166 | /* | |||
167 | * kvtophys(addr) | |||
168 | * | |||
169 | * Convert a kernel virtual address to a physical address | |||
170 | */ | |||
171 | vm_offset_t | |||
172 | kvtophys(addr) | |||
173 | vm_offset_t addr; | |||
174 | { | |||
175 | pt_entry_t *pte; | |||
176 | ||||
177 | if ((pte = pmap_pte(kernel_pmap, addr)) == PT_ENTRY_NULL((pt_entry_t *) 0)) | |||
178 | return 0; | |||
179 | return pte_to_pa(*pte)({ pt_entry_t __a = (pt_entry_t) ((*pte) & 0x00007ffffffff000ULL ); ((((unsigned long *) 0xF5800000UL)[__a >> 12]) << 12) | (__a & ((1 << 12)-1)); }) | (addr & INTEL_OFFMASK0xfff); | |||
180 | } |