From nobody Sat May 21 22:20:00 2022 X-Original-To: freebsd-current@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id B4CD81B463AE for ; Sat, 21 May 2022 22:21:04 +0000 (UTC) (envelope-from obiwac@gmail.com) Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4L5J2m23rlz3j0V for ; Sat, 21 May 2022 22:21:04 +0000 (UTC) (envelope-from obiwac@gmail.com) Received: by mail-pl1-x62e.google.com with SMTP id m12so10077332plb.4 for ; Sat, 21 May 2022 15:21:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:from:date:message-id:subject:to; bh=/sLnr9WNV5DGSOFyw2wjIAg8N+QFI55SjFDS3pE8g5M=; b=OYkMyg9AyO9IQyMzB+98PeIWJJpYk1DvCTXWoLsXxMu6AU93x9NzMhqA5L2eSozzh2 KBiaY7Zkd99C6/nvBRp6Yvmeg2w9OccBy1dw6tpwvGzsUlHGXwVtdI3jzBu4pnKi+x4o YrflIsjqgotS2z3XRCQIuVWvf9BoIOE7eNLyQ53HHmJlRPOR+6juCZsI/0zUO/+COjjA tQkr+//7kHmk2AnTw+VmTJyttZbXrur9UWN5zH+ASPdLPqUakTdMUaZV8jVLt7ICI9wY uXN+7Hz0VALqCdHYhw6YctmmQMxRtCOhYRhlr3Iu0TekfA+qU5ndE7RzSn45lcLMr9B/ jytA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=/sLnr9WNV5DGSOFyw2wjIAg8N+QFI55SjFDS3pE8g5M=; b=naOtnZ648O9o2luKyC/ZCsvvsPfztYeU7wEOjlBp38Vz0TGkxK/HJB4d298lykrGBD NtlLc+8yI3+2aO9qTQAlo1riDy62Z5leqerMcF/+3xRI5ONLA3g/o7YeI5hy64UnIXJ2 qwjmOr7hFY9xAKM1PPS8xusyu37jf0P4BlbzRlBE+KNOpe8QjSGpNPEi/G4/HXcoc840 Nw/ysEG+xT0zHrXP/wqmOX+KjSs7ckikOfCzN2Wzuhe6iWJOSoFbi6D/AHmsf1JKFkFz Gc/8h7xfSZ/gnaIzDLc11nCJByHpzWB5RccRBynajqDW2njdHS35xUj2z5w3GgpG6Bgi habQ== X-Gm-Message-State: AOAM5327tjOQcKcE812ah2UfBNyFWKrRAM9Yy5lOgJzhg7576mFNNF2A A4ddxytUNTtXhT7nPEL7G730lQnGntcgOZHu/QTNh7Jbw/0= X-Google-Smtp-Source: ABdhPJz/Qjt54PYlIiR5SoXPwxXpacCk+9j2cCT5evl4cA1GoJZ2+oPY4kIPZ7j+EcOUI9yX+8J2V8SNHvc8kokIl1Q= X-Received: by 2002:a17:90a:4f0a:b0:1df:b37b:75b1 with SMTP id p10-20020a17090a4f0a00b001dfb37b75b1mr18982911pjh.199.1653171662970; Sat, 21 May 2022 15:21:02 -0700 (PDT) List-Id: Discussions about the use of FreeBSD-current List-Archive: https://lists.freebsd.org/archives/freebsd-current List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-current@freebsd.org MIME-Version: 1.0 From: obiwac Date: Sun, 22 May 2022 00:20:00 +0200 Message-ID: Subject: Writing to vt framebuffer To: freebsd-current@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 4L5J2m23rlz3j0V X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20210112 header.b=OYkMyg9A; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (mx1.freebsd.org: domain of obiwac@gmail.com designates 2607:f8b0:4864:20::62e as permitted sender) smtp.mailfrom=obiwac@gmail.com X-Spamd-Result: default: False [-2.32 / 15.00]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20210112]; FROM_HAS_DN(0.00)[]; FREEMAIL_FROM(0.00)[gmail.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-current@freebsd.org]; TO_DN_NONE(0.00)[]; NEURAL_SPAM_MEDIUM(0.60)[0.596]; RCPT_COUNT_ONE(0.00)[1]; NEURAL_HAM_LONG(-0.91)[-0.912]; MID_RHS_MATCH_FROMTLD(0.00)[]; R_SPF_ALLOW(-0.20)[+ip6:2607:f8b0:4000::/36]; DKIM_TRACE(0.00)[gmail.com:+]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; RCVD_IN_DNSWL_NONE(0.00)[2607:f8b0:4864:20::62e:from]; NEURAL_HAM_SHORT(-1.00)[-1.000]; MLMMJ_DEST(0.00)[freebsd-current]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; DWL_DNSWL_NONE(0.00)[gmail.com:dkim] X-ThisMailContainsUnwantedMimeParts: N Good evening all, For a certain application I need to be able to draw directly to the VBE/GOP framebuffer without the help of xorg-server (too cumbersome), and I had no problems getting this to work with the old syscons driver a while back: ioctl(0, KDENABIO, 0); ioctl(0, VT_WAITACTIVE, 0); ioctl(0, KDSETMODE, KD_GRAPHICS); ioctl(0, _IO('V', 280 - M_VESA_BASE), 0); video_adapter_info_t adp; ioctl(0, CONS_ADPINFO, &adp); ioctl(0, CONS_SETWINORG, 0); uint8_t* fb = mmap(NULL, adp.va_window_size, PROT_READ | PROT_WRITE, MAP_FILE | MAP_SHARED, STDOUT_FILENO, 0); (Error handling omitted for the sake of brevity.) No problems up until here, but I'd like to move on to newcons (for UEFI, and because I've been having some slightly weird behaviour with it and the i915kms & radeonkms drivers). Problem is I can only find very little information about vt! By faffing around in the vt source (src/sys/dev/vt) & Xorg source (especially hw/xfree86/os-support/bsd/bsd_init.c), I've come up with: int fd = open("/dev/ttyv0", O_RDWR | O_NDELAY); int vtno = 2; // rolled a dice and it landed on 2 ioctl(fd, VT_ACTIVATE, vtno); ioctl(fd, VT_WAITACTIVE, vtno); This does... something, at least. If I'm running Xorg, it switches to a virtual terminal and displays random blocks of colours on screen (at least I think that's what it's doing; ngl I don't understand much of all this, mostly distilling what Xorg does... one thing I did gather from this little promenade through bsd_init.c is that vt is the same thing as pcvt on OpenBSD, or at the very least is meant to be compatible with it?) But further than this, I can't, it would seem, set modes, map framebuffer memory, or do anything of the sorts. And I'm a bit at wits end here; I seriously can't understand how Xorg does things after this. I don't even get how it can possibly work, actually, as the KD_SETMODE ioctl in vt_core.c doesn't seem like it's even doing anything at all. I don't really need to set modes either. Just having the correct mode set by the loader and being able to simply draw to a framebuffer would be all that I need. Hopefully someone can enlighten me on vt's mystique which transcends what the likes of mere mortals such as myself can comprehend. I think once (read: if) I wrap my head around all this I'll finally get vidcontrol working with vt (if that's possible at all) because that's been bugging me for a while too!