ASELSANMicrokernel
S91 · SOURCE-BOUND GATE EVIDENCE

G8g UART capture aynı descriptor'da arm edildi; power-on bekleniyor

S91 UART capture kapısı → kendi G8G same-descriptor helper kodu Bu sayfa yalnız S91 kapısına aittir; komşu kapıların kaynakları bu kabulün içine katılmaz.

S91Komut / fiziksel sözleşmeOperations id exactsource SHA exact

operation: rpi5-g8g-uart-prearm-verified

script/Makefile/config · Operations · 2 exact excerpt

sequence-bound=true · implementation-bound=false
01 · Yürütme / doğrulama kodu

Kapının gerçek repository sözleşmesi

tam C fonksiyonuL133–L529
scripts/capture-rpi5-g8g-uart10.c::main
int main(int argc, char **argv) {
    int result = 2;
    int serial_fd = -1;
    int output_fd = -1;
    bool output_opened = false;
    bool output_closed = false;
    bool output_mode_locked = false;
    bool terminal_seen = false;
    bool terminal_grace_complete = false;
    bool finalization_ok = true;
    uint64_t total_bytes = 0;
    uint64_t terminal_marker_start_offset = 0;
    uint64_t terminal_marker_end_offset = 0;
    double terminal_seen_at = 0.0;
    struct marker_window scanner = {{0}, 0, 0};

    if (argc != 3) {
        fprintf(stderr, "usage: %s DEVICE OUTPUT\n", argv[0]);
        return 2;
    }
    if (!install_signal_handlers()) {
        return 2;
    }

    const char *device = argv[1];
    const char *output = argv[2];

    serial_fd = open(device, O_RDWR | O_NOCTTY | O_NONBLOCK);
    if (serial_fd < 0) {
        perror("open serial device");
        return 2;
    }
    if (!isatty(serial_fd)) {
        fprintf(stderr, "serial device is not a tty\n");
        goto finalize;
    }
#ifdef TIOCEXCL
    if (ioctl(serial_fd, TIOCEXCL) != 0) {
        perror("ioctl TIOCEXCL");
        goto finalize;
    }
#else
#error "TIOCEXCL is required for the G8g capture helper"
#endif
    struct termios settings;
    if (tcgetattr(serial_fd, &settings) != 0) {
        perror("tcgetattr before configure");
        goto finalize;
    }

    cfmakeraw(&settings);
    settings.c_iflag &= (tcflag_t)~(IGNBRK | BRKINT | PARMRK | ISTRIP |
                                    INLCR | IGNCR | ICRNL);
    settings.c_oflag &= (tcflag_t)~OPOST;
    settings.c_lflag &=
        (tcflag_t)~(ICANON | ECHO | ECHONL | ISIG | IEXTEN);
    settings.c_cflag &= (tcflag_t)~(PARENB | CSTOPB | CSIZE);
    settings.c_cflag |= CS8 | CLOCAL | CREAD;
#ifdef CRTSCTS
    settings.c_cflag &= (tcflag_t)~CRTSCTS;
#endif
    settings.c_iflag &= (tcflag_t)~(IXON | IXOFF | IXANY);
    settings.c_cc[VMIN] = 0;
    settings.c_cc[VTIME] = 0;
    if (cfsetispeed(&settings, B115200) != 0 ||
        cfsetospeed(&settings, B115200) != 0) {
        perror("cfset speed");
        goto finalize;
    }
    if (tcsetattr(serial_fd, TCSANOW, &settings) != 0) {
        perror("tcsetattr");
        goto finalize;
    }

    struct termios effective;
    if (tcgetattr(serial_fd, &effective) != 0) {
        perror("tcgetattr after configure");
        goto finalize;
    }

    const bool raw_ok =
        (effective.c_lflag & (ICANON | ECHO | ISIG | IEXTEN)) == 0 &&
        (effective.c_oflag & OPOST) == 0 &&
        (effective.c_iflag &
         (BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL)) == 0 &&
        (effective.c_lflag & ECHONL) == 0;
    const bool bits_ok = (effective.c_cflag & CSIZE) == CS8 &&
                         (effective.c_cflag & (PARENB | CSTOPB)) == 0 &&
                         (effective.c_cflag & (CLOCAL | CREAD)) ==
                             (CLOCAL | CREAD) &&
                         effective.c_cc[VMIN] == 0 &&
                         effective.c_cc[VTIME] == 0;
    bool flow_ok = (effective.c_iflag & (IXON | IXOFF | IXANY)) == 0;
#ifdef CRTSCTS
    flow_ok = flow_ok && (effective.c_cflag & CRTSCTS) == 0;
#endif
    const bool speed_ok = cfgetispeed(&effective) == B115200 &&
                          cfgetospeed(&effective) == B115200;
    if (!raw_ok || !bits_ok || !flow_ok || !speed_ok) {
        fprintf(stderr,
                "effective termios mismatch raw=%s bits8n1=%s "
                "flow_off=%s speed=%s iflag=0x%lx oflag=0x%lx "
                "lflag=0x%lx cflag=0x%lx vmin=%u vtime=%u\n",
                raw_ok ? "true" : "false",
                bits_ok ? "true" : "false",
                flow_ok ? "true" : "false",
                speed_ok ? "true" : "false",
                (unsigned long)effective.c_iflag,
                (unsigned long)effective.c_oflag,
                (unsigned long)effective.c_lflag,
                (unsigned long)effective.c_cflag,
                (unsigned int)effective.c_cc[VMIN],
                (unsigned int)effective.c_cc[VTIME]);
        goto finalize;
    }

    if (tcflush(serial_fd, TCIFLUSH) != 0) {
        perror("tcflush TCIFLUSH");
        goto finalize;
    }
    if (stop_requested) {
        fprintf(stderr, "capture_signal_before_arm=YES\n");
        result = 4;
        goto finalize;
    }

    output_fd = open(output, O_WRONLY | O_CREAT | O_EXCL, 0600);
    if (output_fd < 0) {
        perror("open raw output");
        goto finalize;
    }
    output_opened = true;

    double started_at = 0.0;
    if (!monotonic_seconds(&started_at)) {
        goto finalize;
    }
    if (stop_requested) {
        fprintf(stderr, "capture_signal_before_arm=YES\n");
        result = 4;
        goto finalize;
    }

    printf("device=%s\n", device);
    printf("same_descriptor=true fd=%d "
           "exclusive_request=TIOCEXCL_APPLIED\n",
           serial_fd);
    printf("effective_baud_115200=true ispeed=%lu ospeed=%lu\n",
           (unsigned long)cfgetispeed(&effective),
           (unsigned long)cfgetospeed(&effective));
    printf("format=8N1 raw=true flow_control=false\n");
    printf("effective_termios_masks iflag=0x%lx oflag=0x%lx "
           "lflag=0x%lx cflag=0x%lx vmin=%u vtime=%u\n",
           (unsigned long)effective.c_iflag,
           (unsigned long)effective.c_oflag,
           (unsigned long)effective.c_lflag,
           (unsigned long)effective.c_cflag,
           (unsigned int)effective.c_cc[VMIN],
           (unsigned int)effective.c_cc[VTIME]);
    printf("input_flushed=true method=TCIFLUSH\n");
    printf("capture_path=%s\n", output);
    printf("capture_armed=YES\n");
    if (fflush(stdout) != 0) {
        perror("fflush capture_armed");
        goto finalize;
    }

    uint8_t buffer[READ_BUFFER_BYTES];
    result = 3;
    for (;;) {
        double now = 0.0;
        if (!monotonic_seconds(&now)) {
            result = 2;
            break;
        }
        bool grace_deadline_reached =
            terminal_seen && now - terminal_seen_at >= TERMINAL_GRACE_SECONDS;
        if (!grace_deadline_reached && stop_requested) {
            fprintf(stderr, "capture_signal_before_complete=YES\n");
            result = 4;
            break;
        }
        if (!grace_deadline_reached &&
            now - started_at >= CAPTURE_TIMEOUT_SECONDS) {
            fprintf(stderr,
                    "capture_timeout=YES limit_seconds=%.3f\n",
                    CAPTURE_TIMEOUT_SECONDS);
            result = 3;
            break;
        }

        struct pollfd pfd = {.fd = serial_fd, .events = POLLIN, .revents = 0};
        const int polled = poll(&pfd, 1, grace_deadline_reached ? 0 : 250);
        if (polled < 0) {
            if (errno == EINTR) {
                continue;
            }
            perror("poll serial");
            result = 2;
            break;
        }
        if (polled == 0) {
            if (grace_deadline_reached) {
                terminal_grace_complete = true;
                printf("terminal_grace_complete=true seconds=3\n");
                break;
            }
            continue;
        }
        const bool poll_error = (pfd.revents & (POLLERR | POLLNVAL)) != 0;
        const bool hangup_pending = (pfd.revents & POLLHUP) != 0;
        if ((pfd.revents & POLLIN) == 0 && !hangup_pending && !poll_error) {
            continue;
        }

        bool drain_stopped = false;
        bool drain_exhausted = true;
        for (unsigned int drain_reads = 0; drain_reads < MAX_DRAIN_READS;
             ++drain_reads) {
            const ssize_t got = read(serial_fd, buffer, sizeof(buffer));
            if (got < 0) {
                if (errno == EINTR) {
                    continue;
                }
                if (errno == EAGAIN || errno == EWOULDBLOCK) {
                    drain_exhausted = false;
                    break;
                }
                perror("read serial");
                result = 2;
                break;
            }
            if (got == 0) {
                /* VMIN=0 makes zero a completed drain, not an EOF signal. */
                drain_exhausted = false;
                break;
            }

            if (!write_all(output_fd, buffer, (size_t)got)) {
                result = 2;
                break;
            }
            total_bytes += (uint64_t)got;
            for (ssize_t i = 0; i < got; ++i) {
                marker_window_push(&scanner, buffer[i]);
                if (!terminal_seen &&
                    marker_window_matches(&scanner,
                                          &terminal_marker_start_offset,
                                          &terminal_marker_end_offset)) {
                    terminal_seen = true;
                    if (!monotonic_seconds(&terminal_seen_at)) {
                        result = 2;
                        drain_stopped = true;
                        break;
                    }
                    printf("terminal_marker_seen=ASELSAN/BOOT8G "
                           "start_offset=%llu end_offset=%llu\n",
                           (unsigned long long)terminal_marker_start_offset,
                           (unsigned long long)terminal_marker_end_offset);
                    if (fflush(stdout) != 0) {
                        perror("fflush terminal marker");
                        result = 2;
                        drain_stopped = true;
                        break;
                    }
                }
            }
            if (drain_stopped || result == 2) {
                break;
            }

            double drain_now = 0.0;
            if (!monotonic_seconds(&drain_now)) {
                result = 2;
                drain_stopped = true;
                break;
            }
            grace_deadline_reached =
                terminal_seen &&
                drain_now - terminal_seen_at >= TERMINAL_GRACE_SECONDS;
            if (!grace_deadline_reached && stop_requested) {
                fprintf(stderr, "capture_signal_before_complete=YES\n");
                result = 4;
                drain_stopped = true;
                break;
            }
            if (!grace_deadline_reached &&
                drain_now - started_at >= CAPTURE_TIMEOUT_SECONDS) {
                fprintf(stderr,
                        "capture_timeout=YES limit_seconds=%.3f\n",
                        CAPTURE_TIMEOUT_SECONDS);
                result = 3;
                drain_stopped = true;
                break;
            }
        }
        if (drain_stopped || result == 2 || result == 4) {
            break;
        }
        if (poll_error) {
            fprintf(stderr, "serial poll failure revents=0x%x\n", pfd.revents);
            result = 2;
            break;
        }
        if (hangup_pending && !grace_deadline_reached) {
            fprintf(stderr, "serial_hangup_before_complete=YES\n");
            result = 3;
            break;
        }
        if (grace_deadline_reached) {
            if (drain_exhausted) {
                fprintf(stderr, "terminal_grace_drain_saturated=YES\n");
                result = 3;
                break;
            }
            terminal_grace_complete = true;
            printf("terminal_grace_complete=true seconds=3\n");
            break;
        }
    }

    if (terminal_seen && terminal_grace_complete) {
        result = 0;
    } else if (result == 0) {
        result = 3;
    }

finalize:
    if (output_opened) {
        if (fsync(output_fd) != 0) {
            perror("fsync raw output before chmod");
            finalization_ok = false;
        }
        if (fchmod(output_fd, 0444) != 0) {
            perror("fchmod raw output");
            finalization_ok = false;
        } else {
            output_mode_locked = true;
        }
        if (fsync(output_fd) != 0) {
            perror("fsync raw output after chmod");
            finalization_ok = false;
        }
        struct stat finalized_output;
        if (fstat(output_fd, &finalized_output) != 0) {
            perror("fstat finalized raw output");
            finalization_ok = false;
            output_mode_locked = false;
        } else if (!S_ISREG(finalized_output.st_mode) ||
                   (finalized_output.st_mode & 0777) != 0444 ||
                   finalized_output.st_nlink != 1 ||
                   finalized_output.st_size < 0 ||
                   (uint64_t)finalized_output.st_size != total_bytes) {
            fprintf(stderr,
                    "finalized raw output identity/mode/size mismatch\n");
            finalization_ok = false;
            output_mode_locked = false;
        }
        if (close(output_fd) != 0) {
            perror("close raw output");
            finalization_ok = false;
        } else {
            output_closed = true;
        }
        output_fd = -1;
    }
    if (serial_fd >= 0 && close(serial_fd) != 0) {
        perror("close serial device");
        finalization_ok = false;
    }
    serial_fd = -1;

    if (!finalization_ok) {
        result = 2;
    }
    const bool output_durable = output_opened && output_closed &&
                                output_mode_locked && finalization_ok;
    const bool success = result == 0 && terminal_seen &&
                         terminal_grace_complete && output_durable;
    if (!success && result == 0) {
        result = 3;
    }
    const int report_status =
        printf("capture_closed=%s terminal_seen=%s grace_complete=%s "
               "exact_bytes=%llu mode=%s durable=%s success=%s\n",
           output_closed ? "true" : "false",
           terminal_seen ? "true" : "false",
           terminal_grace_complete ? "true" : "false",
           (unsigned long long)total_bytes,
           output_mode_locked ? "0444" : "UNLOCKED",
           output_durable ? "true" : "false",
           success ? "true" : "false");
    if (report_status < 0 || fflush(stdout) != 0) {
        result = 2;
    }
    return result;
}
snippet sha256: 47cc39fc1da6file sha256: 0edad27372e6
02 · Kapı kimlik kaydı

Operations sıra, kimlik ve başlık bağı

tam Operations kaydıL28732–L28820
website/src/lib/operations.ts::rpi5-g8g-uart-prearm-verified
  {
    id: "rpi5-g8g-uart-prearm-verified",
    date: "2026-08-22",
    sequence: 91,
    status: "verified",
    title:
      "G8g UART capture aynı descriptor'da arm edildi; power-on bekleniyor",
    summary:
      "Kullanıcı verified S90 kartını güçsüz Raspberry Pi'ye taktığını teyit etti; `/dev/disk6` ve `/Volumes/ASELSANBOOT` yokluğu yeniden doğrulandı. İki bağımsız salt-okunur pre-arm audit GO verdi. Root 3 örnek/10 saniye ve bağımsız 3 örnek/12 saniye boyunca tek IOSerial pair sabit kaldı: `/dev/cu.usbmodem214402` inode 799 rdev 9,3 ve `/dev/tty.usbmodem214402` inode 801 rdev 9,2, IOSerial object 0x1000044a7; başka usbmodem veya holder yoktu. Frozen source 17.775 B / 0edad273…d3599 ve prepared binary 35.016 B / 5029a0f5…c28d kimliğiyle helper PID 83702 olarak açıldı. Aynı süreçte serial FD 3 ve raw FD 4 tutuluyor; helper `same_descriptor=true`, `exclusive_request=TIOCEXCL_APPLIED`, effective 115200/8N1 raw/flow-off read-back, `TCIFLUSH` ve exact `capture_armed=YES` yayımladı. Üç post-arm pre-power örneği boyunca USB kimliği ve FD 3 sabit, raw exact size 1 / inode 21967471 / mode 0600 / nlink 1 / hex 00 kaldı. POWER NOT GIVEN: terminal marker, capture close, raw mode 0444 ve fiziksel BOOT8G henüz yoktur. Sıra 91 pre-arm VERIFIED; aktif kapı Sıra 92 fiziksel BOOT8G'dir. Son fiziksel boot kabulü Sıra 80 BOOT8F olarak kalır.",
    evidence: [
      "Kullanıcı S90 verified kartının güçsüz Pi'ye takıldığını açıkça teyit etti; pre-arm sırasında `/dev/disk6` ve `/Volumes/ASELSANBOOT` absent kaldı.",
      "İki bağımsız salt-okunur pre-arm audit FINAL GO verdi; hiçbir audit serial descriptor veya raw dosyayı açmadı/değiştirmedi.",
      "Root kimlik örneklemesi 3/3 over 10s, bağımsız örnekleme 3/3 over 12s stable verdi; başka `usbmodem` endpoint yoktu ve `holders=0` kaldı.",
      "Exact pair: `/dev/cu.usbmodem214402` inode 799 rdev 9,3 ve `/dev/tty.usbmodem214402` inode 801 rdev 9,2; IOSerial object 0x1000044a7.",
      "Debug Probe USB object 0x100004496, session 783935390455, address 7, location 0x02144000 / 34881536 ve serial E6647C74033F9131 olarak bütün pre-arm örneklerinde sabit kaldı.",
      "Frozen capture source exact 17.775 B / 0edad27372e6d89a940320dd232174cd1cf97ce1a9040904344f6932c6dd3599.",
      "Prepared helper binary exact 35.016 B / 5029a0f592c68d70f40f7e4cd9df01877dd04afea3ed52d269c186d4b85dc28d.",
      "Live helper PID 83702; tek serial FD 3 ve raw FD 4; output path exact `/tmp/aselsanos-g8g-s91-prearm.QU5V4V/uart10.raw`.",
      "Helper read-back exact `same_descriptor=true fd=3 exclusive_request=TIOCEXCL_APPLIED effective=115200 data_bits=8 parity=none stop_bits=1 raw=true flow=false`.",
      "Termios read-back exact `iflag=0 oflag=0 lflag=0 cflag=0xcb00 vmin=0 vtime=0`; input `TCIFLUSH` tamamlandı ve helper `capture_armed=YES` yayımladı.",
      "Üç post-arm pre-power sample over 10s: raw inode 21967471, size=1, mode 0600, nlink=1, hex=00; USB identity ve open FD 3 exact sabit.",
      "S91 same-descriptor UART pre-arm proof exact 146 satır / 3.672 B / 960bd7bfaf9da80e5b83a07ebbf18c416e741f6fc31b2127ac2dc1da24ae407b.",
      "S90 package/kart prerequisite değişmedi; disk/mount absent olduğundan capture açıkken hiçbir storage komutu çalıştırılmadı.",
      "POWER NOT GIVEN; terminal marker=ABSENT, capture close=NOT_RUN, raw mode 0444=NOT_YET, strict physical validator=NOT_RUN ve BOOT8G=STOP.",
    ],
    terminalSessionsNote:
      "Capture helper PID 83702 bu kayıt yayımlanırken aynı descriptor'da açık kalır. Buradaki oturumlar yalnız pre-power identity/arm durumunu özetler; process, UART veya raw'a yeniden erişmez.",
    terminalSessions: [
      {
        id: "g8g-sequence91-prearm-identity",
        title: "Powerless Pi, stable IOSerial pair ve holder-free kapısı",
        commandLines: [
          "confirm verified card inserted into powerless Pi",
          "sample disk/mount absence and IOSerial/USB identity without opening UART",
          "run root and independent holder-free stability audits",
        ],
        outputLines: [
          "disk6/mount=ABSENT/ABSENT · POWER=OFF_CONFIRMED",
          "root identity samples=3/3 over10s · independent=3/3 over12s",
          "cu inode799 rdev9,3 · tty inode801 rdev9,2 · IOSerial=0x1000044a7",
          "Debug Probe serial=E6647C74033F9131 · other_usbmodem=0 · holders=0",
        ],
        exitCode: 0,
        outputMode: "complete",
      },
      {
        id: "g8g-sequence91-live-helper-arm",
        title: "Frozen helper ile same-descriptor arm/read-back",
        commandLines: [
          "verify frozen source and prepared binary identity",
          "open exact cu endpoint once and retain same descriptor",
          "apply TIOCEXCL, 115200/8N1 raw flow-off, TCIFLUSH and arm capture",
        ],
        outputLines: [
          "source=17775 B/0edad273…d3599 · binary=35016 B/5029a0f5…c28d",
          "PID=83702 · serial_fd=3 · raw_fd=4 · same_descriptor=true",
          "exclusive_request=TIOCEXCL_APPLIED · effective=115200 · raw=true · flow=false",
          "TCIFLUSH=PASS · capture_armed=YES",
        ],
        exitCode: 0,
        outputMode: "complete",
      },
      {
        id: "g8g-sequence91-post-arm-pre-power",
        title: "Arm sonrası güç-öncesi sabitlik ve STOP sınırı",
        commandLines: [
          "sample helper/raw/USB identity three times without touching open descriptors",
          "hold power until Operations/Timeline checkpoint is published",
        ],
        outputLines: [
          "post-arm samples=3/3 over10s · fd3/USB identity=STABLE",
          "raw inode=21967471 · size=1 · mode=0600 · nlink=1 · hex=00",
          "POWER NOT GIVEN · terminal marker=ABSENT · capture close=NOT_RUN",
          "raw0444=NOT_YET · physical BOOT8G=STOP · active gate=S92",
        ],
        exitCode: 0,
        outputMode: "complete",
      },
    ],
    limitations: [
      "POWER NOT GIVEN: Pi bu checkpoint'te açılmadı; S91 yalnız verified pre-arm durumudur.",
      "Raw hâlâ açık capture dosyasıdır: size 1 / leading hex 00 / mode 0600; terminal marker ve close olmadan mode 0444 veya immutable capture iddiası yapılamaz.",
      "Capture helper PID 83702, serial FD 3 ve raw FD 4 canlıdır; web/docs işi process, UART descriptor veya raw'a dokunmaz.",
      "S92 physical raw ve BOOT8G henüz yoktur; strict validator çalıştırılmadı ve firmware promotion yapılmadı.",
      "Son fiziksel boot kabulü Sıra 80 BOOT8F / QUIESCENT_ATOMIC_HANDOFF_ONLY olarak kalır.",
      "Generic SMP, scheduler/runqueue ownership, migration, TLBI, CPU2/CPU3, soak ve hotplug kapalıdır.",
      "Production deployment dirty/untracked workspace ve stale 47d22c9 source etiketiyle yapılır; canlı artifact doğrulansa da Git-provider provenance kurulmuş sayılmaz.",
    ],
  },
snippet sha256: 1aa46775dd39file sha256: 9726dbf00f84
Kayıtlı yürütme/kanıt komutu
confirm verified card inserted into powerless Pi
Registry schema v5 · generator website/scripts/generate-code-gates.mjs · Tam SHA-256: 3050638b71a684d8f8f947a8a6faa237a17fa8db5dc0db04fb207b668b462af9