OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rc203soc/] [sw/] [uClinux/] [arch/] [m68k/] [tools/] [amiga/] [dmesg.c] - Blame information for rev 1777

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1623 jcastillo
/*
2
 *  linux/arch/m68k/tools/amiga/dmesg.c -- Retrieve the kernel messages stored
3
 *                                         in Chip RAM with the kernel command
4
 *                                         line option `debug=mem'.
5
 *
6
 *  © Copyright 1996 by Geert Uytterhoeven
7
 *                     (Geert.Uytterhoeven@cs.kuleuven.ac.be)
8
 *
9
 *
10
 *  Compilation (under AmigaOS):
11
 *
12
 *      gcc -o dmesg dmesg.c -noixemul -idirafter INCLUDE: -Wall -s -O3
13
 *
14
 *  Usage:
15
 *
16
 *      dmesg
17
 *      dmesg <CHIPMEM_END>
18
 *
19
 *
20
 *  This file is subject to the terms and conditions of the GNU General Public
21
 *  License.  See the file COPYING in the main directory of the Linux
22
 *  distribution for more details.
23
 */
24
 
25
 
26
#include <stdio.h>
27
#include <stdlib.h>
28
#include <unistd.h>
29
 
30
 
31
#define CHIPMEM_START   0x00000000
32
#define CHIPMEM_END     0x00200000      /* overridden by argv[1] */
33
 
34
#define SAVEKMSG_MAGIC1 0x53415645      /* 'SAVE' */
35
#define SAVEKMSG_MAGIC2 0x4B4D5347      /* 'KMSG' */
36
 
37
struct savekmsg {
38
    u_long magic1;      /* SAVEKMSG_MAGIC1 */
39
    u_long magic2;      /* SAVEKMSG_MAGIC2 */
40
    u_long magicptr;    /* address of magic1 */
41
    u_long size;
42
    char data[0];
43
};
44
 
45
 
46
int main(int argc, char *argv[])
47
{
48
    u_long start = CHIPMEM_START, end = CHIPMEM_END, p;
49
    int found = 0;
50
    struct savekmsg *m = NULL;
51
 
52
    if (argc >= 2)
53
        end = strtoul(argv[1], NULL, 0);
54
    printf("Searching for SAVEKMSG magic...\n");
55
    for (p = start; p <= end-sizeof(struct savekmsg); p += 4) {
56
        m = (struct savekmsg *)p;
57
        if ((m->magic1 == SAVEKMSG_MAGIC1) && (m->magic2 == SAVEKMSG_MAGIC2) &&
58
            (m->magicptr == p)) {
59
            found = 1;
60
            break;
61
        }
62
    }
63
    if (!found)
64
        printf("Not found\n");
65
    else {
66
        printf("Found %ld bytes at 0x%08lx\n", m->size, (u_long)&m->data);
67
        puts(">>>>>>>>>>>>>>>>>>>>");
68
        fflush(stdout);
69
        write(1, &m->data, m->size);
70
        fflush(stdout);
71
        puts("<<<<<<<<<<<<<<<<<<<<");
72
    }
73
    return(0);
74
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.