summaryrefslogtreecommitdiffstats
path: root/g2/main.c
blob: a782e17f2ef51bfacc3bbe0e785751ae4889a24e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
/* 
 *------------------------------------------------------------------
 * Copyright (c) 2005-2016 Cisco and/or its affiliates.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at:
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "g2.h"
#include "props.h"
#include <pwd.h>
#include <strings.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>

/*
 * globals
 */

GtkWidget *g_mainwindow;        /* The main window */

/* Graphical object heirarchy
 *
 * [main window]
 *   [main vbox]
 *     [main (e.g. file) menubar]
 *     [view hbox] 
 *     [view bottom menu]
 */

GtkWidget *g_mainvbox;
GtkWidget *g_mainhbox;

gint delete_event(GtkWidget *widget, GdkEvent *event, gpointer data)
{
    /* Allow window to be destroyed */
    return(FALSE);
}

void destroy(GtkWidget *widget, gpointer data)
{
    gtk_main_quit();
}

int main (int argc, char **argv)
{
    char tmpbuf [128];
    struct passwd *pw;
    char *event_file = 0;
    char *cpel_file = 0;
    char *clib_file =0;
    char *title = "none";
    int curarg=1;
    char *homedir;
    
    gtk_init(&argc, &argv);

    homedir = getenv ("HOME");
    tmpbuf[0] = 0;

    if (homedir) {
        sprintf(tmpbuf, "%s/.g2", homedir);
    } else {
        pw = getpwuid(geteuid());
        if (pw) {
            sprintf(tmpbuf, "%s/.g2", pw->pw_dir);
        }
    }
    if (tmpbuf[0])
        readprops(tmpbuf);

    g_mainwindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);

    gtk_signal_connect (GTK_OBJECT(g_mainwindow), "delete_event",
                        GTK_SIGNAL_FUNC (delete_event), NULL);

    gtk_signal_connect (GTK_OBJECT(g_mainwindow), "destroy",
                        GTK_SIGNAL_FUNC (destroy), NULL);

    gtk_container_set_border_width(GTK_CONTAINER(g_mainwindow), 5);

    g_mainvbox = gtk_vbox_new(FALSE, 0);
    g_mainhbox = gtk_hbox_new(FALSE, 0);

    /* 
     * init routines
     */

    menu1_init();
    point_selector_init();
    view1_init();
    event_init();

    /* 
     * Now that we're ready to rock 'n roll, see if we've been asked to
     * press a few buttons...
     */
    
    while (curarg < argc) {
        if (!strncmp(argv[curarg], "--cpel-input", 4)) {
            curarg++;
            if (curarg < argc) {
                cpel_file = argv[curarg];
                curarg++;
                break;
            }
            g_error("Missing filename after --cpel-input");
        }
        if (!strncmp(argv[curarg], "--clib-input", 4)) {
            curarg++;
            if (curarg < argc) {
                clib_file = argv[curarg];
                curarg++;
                break;
            }
            g_error("Missing filename after --cpel-input");
        }

        if (!strncmp(argv[curarg], "--pointdefs", 3)) {
            curarg++;
            if (curarg < argc) {
                read_event_definitions(argv[curarg]);
                curarg++;
                continue;
            }
            g_error ("Missing filename after --pointdefs\n");
        }
        if (!strncmp(argv[curarg], "--event-log", 3)) {
            curarg++;
            if (curarg < argc) {
                event_file = argv[curarg];
                curarg++;
                continue;
            }
            g_error ("Missing filename after --event-log\n");
        }

        if (!strncmp(argv[curarg], "--ticks-per-us", 3)) {
            curarg++;
            if (curarg < argc) {
                ticks_per_ns = 0.0;
                ticks_per_ns = atof(argv[curarg]);
                if (ticks_per_ns == 0.0) {
                    g_error("ticks-per-ns (%s) didn't convert properly\n",
                            argv[curarg]);
                }
                ticks_per_ns_set = TRUE;
                curarg++;
                continue;
            }
            g_error ("Missing filename after --event-log\n");
        }

        fprintf(stderr, 
                "g2 [--pointdefs <filename>] [--event-log <filename>]\n");
        fprintf(stderr, "   [--ticks-per-us <value>]\n");
        fprintf(stderr, 
                "   [--cpel-input <filename>] [--clib-input <filename]>\n");
        fprintf(stderr, 
                "%s\n%s\n", version_string, minor_v_string);
        exit(0);
    }

    if (clib_file) {
        read_clib_file (clib_file);
        title = clib_file;
    } else if (cpel_file) {
        read_cpel_file(cpel_file);
        title = cpel_file;
    } else if (event_file) {
        read_events(event_file);
        title = event_file;
    }

    set_window_title(title);

    gtk_signal_connect (GTK_OBJECT (g_mainwindow), "key_press_event",
                        (GtkSignalFunc) view1_handle_key_press_event, NULL);
    gtk_container_add(GTK_CONTAINER(g_mainvbox), g_mainhbox);
    gtk_widget_show(g_mainhbox);
    gtk_container_add(GTK_CONTAINER(g_mainwindow), g_mainvbox);
    gtk_widget_show(g_mainvbox);
    gtk_widget_show(g_mainwindow);

    gtk_main();
    return(0);
}
Minimum Voltage: 1.2 V Maximum Voltage: 1.2 V Configured Voltage: 1.2 V Handle 0x0050, DMI type 16, 23 bytes Physical Memory Array Location: System Board Or Motherboard Use: System Memory Error Correction Type: Multi-bit ECC Maximum Capacity: 2 TB Error Information Handle: Not Provided Number Of Devices: 12 Handle 0x0051, DMI type 17, 40 bytes Memory Device Array Handle: 0x0050 Error Information Handle: Not Provided Total Width: 72 bits Data Width: 64 bits Size: 32 GB Form Factor: DIMM Set: None Locator: DIMM_P1_I0 Bank Locator: N1 Type: DDR4 Type Detail: Registered (Buffered) Speed: 2400 MT/s Manufacturer: Micron Technology Serial Number: 469567519 Asset Tag: Not Specified Part Number: 36ASF4G72PZ-2G3B1 Rank: 2 Configured Memory Speed: 2400 MT/s Minimum Voltage: 1.2 V Maximum Voltage: 1.2 V Configured Voltage: 1.2 V Handle 0x0052, DMI type 17, 40 bytes Memory Device Array Handle: 0x0050 Error Information Handle: Not Provided Total Width: 72 bits Data Width: 64 bits Size: 32 GB Form Factor: DIMM Set: None Locator: DIMM_P1_J0 Bank Locator: N1 Type: DDR4 Type Detail: Registered (Buffered) Speed: 2400 MT/s Manufacturer: Micron Technology Serial Number: 469567696 Asset Tag: Not Specified Part Number: 36ASF4G72PZ-2G3B1 Rank: 2 Configured Memory Speed: 2400 MT/s Minimum Voltage: 1.2 V Maximum Voltage: 1.2 V Configured Voltage: 1.2 V ``` ## Linux cmdline ``` BOOT_IMAGE=/boot/vmlinuz-5.4.0-65-generic root=UUID=7d1d0e77-4df0-43df-9619-a99db29ffb83 ro audit=0 intel_iommu=on isolcpus=1-27,29-55 nmi_watchdog=0 nohz_full=1-27,29-55 nosoftlockup processor.max_cstate=1 rcu_nocbs=1-27,29-55 console=ttyAMA0,115200n8 quiet ```