Notice: We have migrated to GitLab launching 2024-05-01 see here: https://gitlab.rtems.org/

Ticket #2012: memory.t

File memory.t, 14.6 KB (added by Ric Claus, on 02/02/12 at 18:20:26)

Updated memory documentation

Line 
1@c
2@c  COPYRIGHT (c) 1988-2008.
3@c  On-Line Applications Research Corporation (OAR).
4@c  All rights reserved.
5@c
6@c  $Id: memory.t,v 1.7 2008/02/29 00:23:04 joel Exp $
7@c
8
9@chapter Memory Commands
10
11@section Introduction
12
13The RTEMS shell has the following memory commands:
14
15@itemize @bullet
16
17@item @code{mdump} - Display contents of memory
18@item @code{wdump} - Display contents of memory (word)
19@item @code{medit} - Modify contents of memory
20@item @code{mfill} - File memory with pattern
21@item @code{mmove} - Move contents of memory
22@item @code{malloc} - Obtain information on C Program Heap
23
24@end itemize
25
26@section Commands
27
28This section details the Memory Commands available.  A
29subsection is dedicated to each of the commands and
30describes the behavior and configuration of that
31command as well as providing an example usage.
32
33@c
34@c
35@c
36@page
37@subsection mdump - display contents of memory
38
39@pgindex mdump
40
41@subheading SYNOPSYS:
42
43@example
44mdump [address [length]]
45@end example
46
47@subheading DESCRIPTION:
48
49This command displays the contents of memory at the @code{address}
50and @code{length} in bytes specified on the command line. 
51
52When @code{length} is not provided, it defaults to @code{320} which
53is twenty lines of output with sixteen bytes of output per line.
54
55When @code{address} is not provided, it defaults to @code{0x00000000}.
56
57@subheading EXIT STATUS:
58
59This command always returns 0 to indicate success.
60
61@subheading NOTES:
62
63Dumping memory from a non-existent address may result in an unrecoverable
64program fault.
65
66@subheading EXAMPLES:
67
68The following is an example of how to use @code{mdump}:
69
70@smallexample
71SHLL [/] $ mdump 0x10000 32
720x0001000000 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
730x0001001000 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
74SHLL [/] $ mdump 0x02000000 32
750x02000000A1 48 00 00 29 00 80 33-81 C5 22 BC A6 10 21 00 .H..)..3.."...!.
760x02000010A1 48 00 00 29 00 80 33-81 C5 22 BC A6 10 21 01 .H..)..3.."...!.
77SHLL [/] $ mdump 0x02001000 32
780x0200100003 00 80 00 82 10 60 00-81 98 40 00 83 48 00 00 ......`...@..H..
790x0200101084 00 60 01 84 08 A0 07-86 10 20 01 87 28 C0 02 ..`....... ..(..
80@end smallexample
81
82@subheading CONFIGURATION:
83
84@findex CONFIGURE_SHELL_NO_COMMAND_MDUMP
85@findex CONFIGURE_SHELL_COMMAND_MDUMP
86
87This command is included in the default shell command set. 
88When building a custom command set, define
89@code{CONFIGURE_SHELL_COMMAND_MDUMP} to have this
90command included.
91
92This command can be excluded from the shell command set by
93defining @code{CONFIGURE_SHELL_NO_COMMAND_MDUMP} when all
94shell commands have been configured.
95
96@subheading PROGRAMMING INFORMATION:
97
98@findex rtems_shell_rtems_main_mdump
99
100The @code{mdump} is implemented by a C language function
101which has the following prototype:
102
103@example
104int rtems_shell_rtems_main_mdump(
105  int    argc,
106  char **argv
107);
108@end example
109
110The configuration structure for the @code{mdump} has the
111following prototype:
112
113@example
114extern rtems_shell_cmd_t rtems_shell_MDUMP_Command;
115@end example
116
117@c
118@c
119@c
120@page
121@subsection wdump - display contents of memory (word)
122
123@pgindex wdump
124
125@subheading SYNOPSYS:
126
127@example
128wdump [address [length]]
129@end example
130
131@subheading DESCRIPTION:
132
133This command displays the contents of memory at the @code{address}
134and @code{length} in bytes specified on the command line. 
135
136When @code{length} is not provided, it defaults to @code{320} which
137is twenty lines of output with sixteen bytes of output per line.
138
139When @code{address} is not provided, it defaults to @code{0x00000000}.
140
141@subheading EXIT STATUS:
142
143This command always returns 0 to indicate success.
144
145@subheading NOTES:
146
147Dumping memory from a non-existent address may result in an unrecoverable
148program fault.
149
150@subheading EXAMPLES:
151
152The following is an example of how to use @code{wdump}:
153
154@smallexample
155SHLL [/] $ wdump 0x02010000 32
1560x02010000 0201 08D8 0201 08C0-0201 08AC 0201 0874 ...............t
1570x02010010 0201 0894 0201 0718-0201 0640 0201 0798 ...........@....
158@end smallexample
159
160@subheading CONFIGURATION:
161
162@findex CONFIGURE_SHELL_NO_COMMAND_WDUMP
163@findex CONFIGURE_SHELL_COMMAND_WDUMP
164
165This command is included in the default shell command set. 
166When building a custom command set, define
167@code{CONFIGURE_SHELL_COMMAND_WDUMP} to have this
168command included.
169
170This command can be excluded from the shell command set by
171defining @code{CONFIGURE_SHELL_NO_COMMAND_WDUMP} when all
172shell commands have been configured.
173
174@subheading PROGRAMMING INFORMATION:
175
176@findex rtems_shell_rtems_main_wdump
177
178The @code{wdump} is implemented by a C language function
179which has the following prototype:
180
181@example
182int rtems_shell_rtems_main_wdump(
183  int    argc,
184  char **argv
185);
186@end example
187
188The configuration structure for the @code{wdump} has the
189following prototype:
190
191@example
192extern rtems_shell_cmd_t rtems_shell_WDUMP_Command;
193@end example
194
195@c
196@c
197@c
198@page
199@subsection medit - modify contents of memory
200
201@pgindex medit
202
203@subheading SYNOPSYS:
204
205@example
206medit address value1 [value2 ... valueN]
207@end example
208
209@subheading DESCRIPTION:
210
211This command is used to modify the contents of the memory starting
212at @code{address} using the octets specified by the parameters
213@code{value1} through @code{valueN}.
214
215@subheading EXIT STATUS:
216
217This command returns 0 on success and non-zero if an error is encountered.
218
219@subheading NOTES:
220
221Dumping memory from a non-existent address may result in an unrecoverable
222program fault.
223
224@subheading EXAMPLES:
225
226The following is an example of how to use @code{medit}:
227
228@smallexample
229SHLL [/] $ mdump 0x02000000 32
2300x02000000 A1 48 00 00 29 00 80 33-81 C5 22 BC A6 10 21 00 .H..)..3.."...!.
2310x02000010 A1 48 00 00 29 00 80 33-81 C5 22 BC A6 10 21 01 .H..)..3.."...!.
232SHLL [/] $  medit 0x02000000 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09
233SHLL [/] $ mdump 0x02000000 32
2340x02000000 01 02 03 04 05 06 07 08-09 00 22 BC A6 10 21 00 .........."...!.
2350x02000010 A1 48 00 00 29 00 80 33-81 C5 22 BC A6 10 21 01 .H..)..3.."...!.
236@end smallexample
237
238@subheading CONFIGURATION:
239
240@findex CONFIGURE_SHELL_NO_COMMAND_MEDIT
241@findex CONFIGURE_SHELL_COMMAND_MEDIT
242
243This command is included in the default shell command set. 
244When building a custom command set, define
245@code{CONFIGURE_SHELL_COMMAND_MEDIT} to have this
246command included.
247
248This command can be excluded from the shell command set by
249defining @code{CONFIGURE_SHELL_NO_COMMAND_MEDIT} when all
250shell commands have been configured.
251
252@subheading PROGRAMMING INFORMATION:
253
254@findex rtems_shell_rtems_main_medit
255
256The @code{medit} is implemented by a C language function
257which has the following prototype:
258
259@example
260int rtems_shell_rtems_main_medit(
261  int    argc,
262  char **argv
263);
264@end example
265
266The configuration structure for the @code{medit} has the
267following prototype:
268
269@example
270extern rtems_shell_cmd_t rtems_shell_MEDIT_Command;
271@end example
272
273@c
274@c
275@c
276@page
277@subsection mfill - file memory with pattern
278
279@pgindex mfill
280
281@subheading SYNOPSYS:
282
283@example
284mfill address length value
285@end example
286
287@subheading DESCRIPTION:
288
289This command is used to fill the memory starting at @code{address}
290for the specified @code{length} in octets when the specified at
291@code{value}.
292
293@subheading EXIT STATUS:
294
295This command returns 0 on success and non-zero if an error is encountered.
296
297@subheading NOTES:
298
299Filling a non-existent address range may result in an unrecoverable
300program fault.  Similarly overwriting interrupt vector tables, code
301space or critical data areas can be fatal as shown in the example.
302
303@subheading EXAMPLES:
304
305In this example, the address used (@code{0x23d89a0}) as the base
306address of the filled area is the end of the stack for the
307Idle thread.  This address was determined manually using gdb and
308is very specific to this application and BSP.  The first command
309in this example is an @code{mdump} to display the initial contents
310of this memory.  We see that the first 8 bytes are 0xA5 which is
311the pattern used as a guard by the Stack Checker.  On
312the first context switch after the pattern is overwritten
313by the  @code{mfill} command, the Stack Checker detect the pattern
314has been corrupted and generates a fatal error.
315
316@smallexample
317SHLL [/] $ mdump 0x23d89a0 16
3180x023D89A0 A5 A5 A5 A5 A5 A5 A5 A5-FE ED F0 0D 0B AD 0D 06 ................
319SHLL [/] $ mfill 0x23d89a0 13 0x5a
320SHLL [/] $ BLOWN STACK!!! Offending task(0x23D4418): id=0x09010001; name=0x0203D908
321  stack covers range 0x23D89A0 - 0x23D99AF (4112 bytes)
322  Damaged pattern begins at 0x023D89A8 and is 16 bytes long
323@end smallexample
324
325@subheading CONFIGURATION:
326
327@findex CONFIGURE_SHELL_NO_COMMAND_MFILL
328@findex CONFIGURE_SHELL_COMMAND_MFILL
329
330This command is included in the default shell command set. 
331When building a custom command set, define
332@code{CONFIGURE_SHELL_COMMAND_MFILL} to have this
333command included.
334
335This command can be excluded from the shell command set by
336defining @code{CONFIGURE_SHELL_NO_COMMAND_MFILL} when all
337shell commands have been configured.
338
339@subheading PROGRAMMING INFORMATION:
340
341@findex rtems_shell_rtems_main_mfill
342
343The @code{mfill} is implemented by a C language function
344which has the following prototype:
345
346@example
347int rtems_shell_rtems_main_mfill(
348  int    argc,
349  char **argv
350);
351@end example
352
353The configuration structure for the @code{mfill} has the
354following prototype:
355
356@example
357extern rtems_shell_cmd_t rtems_shell_MFILL_Command;
358@end example
359
360@c
361@c
362@c
363@page
364@subsection mmove - move contents of memory
365
366@pgindex mmove
367
368@subheading SYNOPSYS:
369
370@example
371mmove dst src length
372@end example
373
374@subheading DESCRIPTION:
375
376This command is used to copy the contents of the memory
377starting at @code{src} to the memory located at @code{dst}
378for the specified @code{length} in octets.
379
380@subheading EXIT STATUS:
381
382This command returns 0 on success and non-zero if an error is encountered.
383
384@subheading NOTES:
385
386NONE
387
388@subheading EXAMPLES:
389
390The following is an example of how to use @code{mmove}:
391
392@smallexample
393SHLL [/] $ mdump 0x023d99a0 16
3940x023D99A0 A5 A5 A5 A5 A5 A5 A5 A5-A5 A5 A5 A5 A5 A5 A5 A5 ................
395SHLL [/] $ mdump 0x02000000 16
3960x02000000 A1 48 00 00 29 00 80 33-81 C5 22 BC A6 10 21 00 .H..)..3.."...!.
397SHLL [/] $ mmove 0x023d99a0 0x02000000 13
398SHLL [/] $ mdump 0x023d99a0 16
3990x023D99A0 A1 48 00 00 29 00 80 33-81 C5 22 BC A6 A5 A5 A5 .H..)..3..".....
400@end smallexample
401
402@subheading CONFIGURATION:
403
404@findex CONFIGURE_SHELL_NO_COMMAND_MMOVE
405@findex CONFIGURE_SHELL_COMMAND_MMOVE
406
407This command is included in the default shell command set. 
408When building a custom command set, define
409@code{CONFIGURE_SHELL_COMMAND_MMOVE} to have this
410command included.
411
412This command can be excluded from the shell command set by
413defining @code{CONFIGURE_SHELL_NO_COMMAND_MMOVE} when all
414shell commands have been configured.
415
416@subheading PROGRAMMING INFORMATION:
417
418@findex rtems_shell_rtems_main_mmove
419
420The @code{mmove} is implemented by a C language function
421which has the following prototype:
422
423@example
424int rtems_shell_rtems_main_mmove(
425  int    argc,
426  char **argv
427);
428@end example
429
430The configuration structure for the @code{mmove} has the
431following prototype:
432
433@example
434extern rtems_shell_cmd_t rtems_shell_MMOVE_Command;
435@end example
436
437@c
438@c
439@c
440@page
441@subsection malloc - obtain information on C program heap
442
443@pgindex malloc
444
445@subheading SYNOPSYS:
446
447@example
448malloc [info|stats]
449@end example
450
451@subheading DESCRIPTION:
452
453This command prints either information or statistics about the
454C Program Heap used by the @code{malloc} family of calls based upon
455the value of the first argument passed to the command.
456
457When the subcommand @code{info} is specified, information on the
458current state of the C Program Heap is reported.  This includes the following
459information:
460
461@itemize @bullet
462@item Number of free blocks
463@item Largest free block
464@item Total bytes free
465@item Number of used blocks
466@item Largest used block
467@item Total bytes used
468@end itemize
469
470When the subcommand @code{stats} is specified, statistics on the
471the C Program Heap are reported.  Malloc Family Statistics must
472be enabled for all of the values to be updated.  The statistics
473available includes the following information:
474
475@itemize @bullet
476@item
477@item Currently available memory (in kilobytes)
478@item Currently allocated memory (in kilobytes)
479@item Maximum amount of memory ever allocated (in kilobytes)
480@item Lifetime tally of allocated memory  (in kilobytes)
481@item Lifetime tally of freed memory (in kilobytes)
482@item Number of calls to @code{malloc}
483@item Number of calls to @code{free}
484@item Number of calls to @code{realloc}
485@item Number of calls to @code{calloc}
486@end itemize
487
488@subheading EXIT STATUS:
489
490This command returns 0 on success and non-zero if an error is encountered.
491
492@subheading NOTES:
493
494@findex CONFIGURE_MALLOC_STATISTICS
495
496The @code{CONFIGURE_MALLOC_STATISTICS} @code{confdefs.h} constant
497must be defined when the application is configured for the full
498set of statistics information to be available.
499
500@subheading EXAMPLES:
501
502The following is an example of how to use the @code{malloc} command.
503
504@example
505SHLL [/] $ malloc info
506Number of free blocks: 3
507Largest free block:    3626672
508Total bytes free:      3627768
509Number of used blocks: 130
510Largest used block:    1048
511Total bytes used:      10136
512SHLL [/] $ malloc stats
513Malloc statistics
514  avail:3552k  allocated:9k (0%) max:10k (0%) lifetime:21k freed:12k
515  Call counts:   malloc:203   free:93   realloc:0   calloc:20
516SHLL [/] $ malloc info
517Number of free blocks: 3
518Largest free block:    3626672
519Total bytes free:      3627768
520Number of used blocks: 130
521Largest used block:    1048
522Total bytes used:      10136
523SHLL [/] $ malloc stats
524Malloc statistics
525  avail:3552k  allocated:9k (0%) max:10k (0%) lifetime:23k freed:14k
526  Call counts:   malloc:205   free:95   realloc:0   calloc:20
527@end example
528
529Note that in the above example, the lifetime allocated and free
530values have increased between the two calls to @code{malloc stats}
531even though the amount of memory available in the C Program Heap
532is the same in both the @code{malloc info} invocations. This indicates
533that memory was allocated and freed as a side-effect of the commands.
534
535@subheading CONFIGURATION:
536
537@findex CONFIGURE_SHELL_NO_COMMAND_MALLOC
538@findex CONFIGURE_SHELL_COMMAND_MALLOC
539
540This command is included in the default shell command set. 
541When building a custom command set, define
542@code{CONFIGURE_SHELL_COMMAND_MALLOC} to have this
543command included.
544
545This command can be excluded from the shell command set by
546defining @code{CONFIGURE_SHELL_NO_COMMAND_MALLOC} when all
547shell commands have been configured.
548
549@subheading PROGRAMMING INFORMATION:
550
551@findex rtems_shell_rtems_main_malloc
552
553The @code{malloc} is implemented by a C language function
554which has the following prototype:
555
556@example
557int rtems_shell_rtems_main_malloc(
558  int    argc,
559  char **argv
560);
561@end example
562
563The configuration structure for the @code{malloc} has the
564following prototype:
565
566@example
567extern rtems_shell_cmd_t rtems_shell_MALLOC_Command;
568@end example
569