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

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"
1.1.1.7 ! root       11: #include "scheduler.h"
1.1       root       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.7 ! root       22:        int 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: 
1.1.1.6   root       45:        // CLI 側では関係ないが wx 側で必要なので初期化は2ステージに分かれている
                     46:        rv = gMainApp.Init1(true, ac, av);
1.1.1.4   root       47:        if (rv != MainApp::PASS) {
                     48:                return rv;
1.1       root       49:        }
1.1.1.6   root       50:        if (!gMainApp.Init2()) {
1.1.1.4   root       51:                return EXIT_FAILURE;
1.1       root       52:        }
                     53: 
1.1.1.6   root       54:        // VM にコールバックを登録
                     55:        if (gMPU680x0) {
                     56:                gMPU680x0->SetHaltCallback(cli_halt_callback, NULL);
                     57:        }
                     58: 
1.1       root       59:        // メインウィンドウに相当するところ
                     60:        OnCreate();
                     61: 
1.1.1.4   root       62:        return EXIT_SUCCESS;
1.1       root       63: }
                     64: 
                     65: // メインウィンドウ作成後のイベントに相当するところ
1.1.1.7 ! root       66: int
1.1       root       67: CLIApp::OnCreate()
                     68: {
1.1.1.6   root       69:        // 電源投入
1.1       root       70:        gVM->PowerButton();
                     71: 
1.1.1.7 ! root       72:        // スケジューラの終了を待つ
        !            73: 
        !            74:        gScheduler->Wait();
        !            75: 
        !            76:        return 0;
1.1       root       77: }
1.1.1.3   root       78: 
                     79: // m680x0 ダブルバスフォールト時に呼ばれるコールバック。
                     80: void
                     81: cli_halt_callback(void *dummy)
                     82: {
                     83:        // どうする?
                     84:        warnx("Double bus fault has occurred in VM");
                     85: }

unix.superglobalmegacorp.com

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