3 allocmap, addseg, findseg, addrtoseg,
4 addrtosegafter, removeseg, freemap,
5 get1, get2, get4, get8,
6 put1, put2, put4, put8,
7 rget1, rget2, rget4, rget8,
8 rput1, rput2, rput4, rput8,
9 locaddr, locconst, locreg, locindir,
10 loccmp, loceval, locfmt, locredir,
11 lget1, lget2, lget4, lget8,
12 lput1, lput2, lput4, lput8 \- machine-independent
13 access to address spaces and register sets
22 .ta \w'\fBxxxxxx'u +\w'xxxxxxx'u
24 typedef struct Map Map;
25 typedef struct Seg Seg;
37 int (*rw)(Map*, Seg*, ulong, void*, uint, int);
52 int addseg(Map *map, Seg seg)
54 int findseg(Map *map, char *name, char *file)
56 int addrtoseg(Map *map, ulong addr, Seg *seg)
58 int addrtosegafter(Map *map, ulong addr, Seg *seg)
60 void removeseg(Map *map, int i)
62 void freemap(Map *map)
65 int get1(Map *map, ulong addr, uchar *a, uint n)
67 int get2(Map *map, ulong addr, u16int *u)
69 int get4(Map *map, ulong addr, u32int *u)
71 int get8(Map *map, ulong addr, u64int *u)
74 int put1(Map *map, ulong addr, uchar *a, uint n)
76 int put2(Map *map, ulong addr, u16int u)
78 int put4(Map *map, ulong addr, u32int u)
80 int put8(Map *map, ulong addr, u64int u)
83 int rget1(Map *map, char *reg, u8int *u)
85 int rget2(Map *map, char *reg, u16int *u)
87 int rget4(Map *map, char *reg, u32int *u)
89 int rget8(Map *map, char *reg, u64int *u)
91 int fpformat(Map *map, char *reg, char *a, uint n, char code);
94 int rput1(Map *map, char *reg, u8int u)
96 int rput2(Map *map, char *reg, u16int u)
98 int rput4(Map *map, char *reg, u32int u)
100 int rput8(Map *map, char *reg, u64int u)
103 Loc locaddr(ulong addr)
105 Loc locconst(ulong con)
107 Loc locreg(char *reg)
109 Loc locindir(char *reg, long offset)
112 int loccmp(Loc *a, Loc *b)
114 int loceval(Map *map, Loc loc, ulong *addr)
118 int locredir(Map *map, Loc *regs, Loc loc, Loc *newloc)
121 int lget1(Map *map, Loc loc, uchar *a, uint n)
123 int lget2(Map *map, Loc loc, u16int *u)
125 int lget4(Map *map, Loc loc, u32int *u)
127 int lget8(Map *map, Loc loc, u64int *u)
130 int lput1(Map *map, Loc loc, uchar *a, uint n)
132 int lput2(Map *map, Loc loc, u16int u)
134 int lput4(Map *map, Loc loc, u32int u)
136 int lput8(Map *map, Loc loc, u64int u)
139 These functions provide
140 a processor-independent interface for accessing
141 executable files, core files, and running processes
144 data structures that provides access to an address space
146 The functions described in
148 are typically used to construct these maps.
149 Related library functions described in
151 provide similar access to symbol tables.
155 comprises an optional register set and one or more
157 each associating a non-overlapping range of
158 memory addresses with a logical section of
159 an executable file or of a running process's address space.
160 Other library functions then use a map
161 and the architecture-specific data structures
162 to provide a generic interface to the
163 processor-dependent data.
165 Each segment has a name (e.g.,
169 and may be associated with a particular file.
170 A segment represents a range of accessible address space.
171 Segments may be backed an arbitary access function
175 or by the contents of an open file
179 Each range has a starting address in the space
184 In segments mapped by files,
185 the range begins at byte
190 function is most commonly used to provide
191 access to executing processes via
193 and to zeroed segments.
196 creates an empty map;
201 adds the given segment to the map, resizing the map's
204 A negative return value indicates an allocation error.
207 returns the index of the segment with the given name (and, if
209 is non-nil, the given file),
210 or \-1 if no such segment is found.
213 returns the index of the segment containing
214 for the given address, or \-1 if that address is not mapped.
215 Segments may have overlapping address ranges:
217 appends segments to the end of the
219 array in the map, and
221 searches the map backwards from the end,
222 so the most recently mapped segment wins.
225 returns the index of the segment containing the lowest mapped
230 removes the segment at the given index.
237 retrieve the data stored at address
239 in the address space associated
245 bytes of data beginning at
253 retrieve 16-bit, 32-bit and 64-bit values respectively,
254 into the location pointed to by
256 The value is byte-swapped if the source
257 byte order differs from that of the current architecture.
258 This implies that the value returned by
263 may not be the same as the byte sequences
268 is two, four or eight; the former may be byte-swapped, the
269 latter reflects the byte order of the target architecture.
270 These functions return the number
271 of bytes read or a \-1 when there is an error.
279 the address space associated with
281 The address is translated using the
282 map parameters and multi-byte quantities are
283 byte-swapped, if necessary, before they are written.
293 write the 16-bit, 32-bit or 64-bit quantity contained in
295 respectively. The number of bytes transferred is returned.
296 A \-1 return value indicates an error.
298 When representing core files or running programs,
299 maps also provide access to the register set.
309 read or write the 1-, 2-, 4-, or 8-byte register
312 If the register is not the requested size, the
313 behavior is undefined.
316 converts the contents of a floating-point register to a string.
318 is the address of a buffer of
320 bytes to hold the resulting string.
326 selecting double or single precision, respectively.
331 the contents of the specified register and the
332 following register are interpreted as a double-precision
333 floating-point number;
334 this is meaningful only for architectures that implement
335 double-precision floats by combining adjacent single-precision
340 represents a place in an executing image capable of
342 Note that locations are typically passed by value rather than by reference.
345 returns an unreadable, unwritable location.
347 returns a location representing the memory address
350 returns a location representing the register
353 returns an location representing the memory address
356 added to the value of
359 returns an imaginary unwritable location holding the constant
361 such locations are useful for passing specific constants to
362 functions expect locations, such as
368 compares two locations, returning negative, zero, or positive
371 is less than, equal to, or greater than
374 Register locations are ordered before memory addresses,
375 which are ordered before indirections.
386 Indirection locations are needed in some contexts (e.g., when
390 .IR mach-symbol (3))),
391 but bothersome in most.
393 rewrites indirections as absolute memory addresses, by evaluating
394 the register using the given map and adding the offset.
406 read and write the given locations, using the
412 function families as necessary.
414 .B /usr/local/plan9/src/libmach