Annotation of nono/cli/cli_app.cpp, revision 1.1.1.4

1.1       root        1: //
                      2: // nono
1.1.1.3   root        3: // Copyright (C) 2020 nono project
                      4: // Licensed under nono-license.txt
1.1       root        5: //
                      6: 
                      7: #include "header.h"
                      8: #include "mainapp.h"
1.1.1.3   root        9: #include "mpu680x0.h"
1.1       root       10: #include "pluto.h"
                     11: #include "rtc.h"
                     12: #include "vm.h"
                     13: 
1.1.1.3   root       14: void cli_halt_callback(void *);
                     15: 
1.1       root       16: // wxApp と相似にするためのクラス
                     17: class CLIApp
                     18: {
                     19:  public:
1.1.1.4 ! root       20:        int OnInit();
1.1       root       21:        bool Parse();
1.1.1.3   root       22:        [[noreturn]] void OnCreate();
1.1       root       23: 
                     24:        int ac;
                     25:        char **av;
                     26: };
                     27: 
                     28: int
                     29: main(int ac, char *av[])
                     30: {
1.1.1.2   root       31:        std::unique_ptr<CLIApp> app(new CLIApp());
1.1       root       32: 
                     33:        // wxApp とよく似せるため
                     34:        app->ac = ac;
                     35:        app->av = av;
1.1.1.4 ! root       36:        return app->OnInit();
1.1       root       37: }
                     38: 
                     39: // ここがエントリポイント(のつもり)
1.1.1.4 ! root       40: int
1.1       root       41: CLIApp::OnInit()
                     42: {
1.1.1.4 ! root       43:        int rv;
        !            44: 
        !            45:        rv = gMainApp.Init(true, ac, av);
        !            46:        if (rv != MainApp::PASS) {
        !            47:                return rv;
1.1       root       48:        }
1.1.1.2   root       49:        if (!gMainApp.Start()) {
1.1.1.4 ! root       50:                return EXIT_FAILURE;
1.1       root       51:        }
                     52: 
                     53:        // メインウィンドウに相当するところ
                     54:        OnCreate();
                     55: 
1.1.1.4 ! root       56:        return EXIT_SUCCESS;
1.1       root       57: }
                     58: 
                     59: // メインウィンドウ作成後のイベントに相当するところ
                     60: void
                     61: CLIApp::OnCreate()
                     62: {
1.1.1.3   root       63:        // VM にコールバックを登録
                     64:        if (gMPU680x0) {
                     65:                gMPU680x0->SetHaltCallback(cli_halt_callback, NULL);
                     66:        }
                     67: 
1.1       root       68:        // 時刻開始?
                     69:        // なるべく VM が開始する直前にしたい。
                     70:        gRTC->InitRTC();
                     71: 
                     72:        // VM 実行開始
                     73:        gVM->PowerButton();
                     74: 
                     75:        // ?
                     76:        for (;;) {
                     77:                sleep(1);
                     78:        }
                     79: }
1.1.1.3   root       80: 
                     81: // m680x0 ダブルバスフォールト時に呼ばれるコールバック。
                     82: void
                     83: cli_halt_callback(void *dummy)
                     84: {
                     85:        // どうする?
                     86:        warnx("Double bus fault has occurred in VM");
                     87: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.