From nobody Wed May 15 15:03:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of seabios.org designates 78.46.105.101 as permitted sender) client-ip=78.46.105.101; envelope-from=seabios-bounces@seabios.org; helo=coreboot.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of seabios.org designates 78.46.105.101 as permitted sender) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=fail(p=none dis=none) header.from=koconnor.net Return-Path: Received: from coreboot.org (coreboot.org [78.46.105.101]) by mx.zohomail.com with SMTPS id 1710547322317433.97665771273796; Fri, 15 Mar 2024 17:02:02 -0700 (PDT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTPA id 813FA39647; Sat, 16 Mar 2024 00:01:57 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTP id 61E9821E31 for ; Sat, 16 Mar 2024 00:01:36 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) for ; Fri, 15 Mar 2024 17:01:36 -0700 (PDT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by smtp.gmail.com with ESMTPSA id m15-20020a0562141bcf00b006913ee4a16esm2510703qvc.24.2024.03.15.17.01.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Mar 2024 17:01:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=koconnor.net; s=google; t=1710547295; x=1711152095; darn=seabios.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=LS+NLizMUHYMEBC471bE67wTsYRNrUMXjndHU3UsQwk=; b=bMTmTxiZfjQzwsXQ8iHr1jVQ7NQNM560CLRVmc35QZsbOfp3czKu6ihFCeDQAdr00c zQct9GOEUkXkKlvI6SMJxa4ydGZSMEvsGjKB6JDi0qMxfjw9iCKTukJXm6RW6+yvHRYU S8d/FBhD9qsS4ynUIa/kwGb2WPqffkhPvsC2w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710547295; x=1711152095; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LS+NLizMUHYMEBC471bE67wTsYRNrUMXjndHU3UsQwk=; b=uWEbonLS6CCeqbZLT7hA66QL4y+CxKPxtMJ+EWQFdqqo+iexIXiKRWnT2AAs+NpkqV 7z0iQPktS+N2lOkU2eyRXnJ7A9OpUkLH0sZlQSEb8ZsT1KQEgldO70mcayvy+E5bQym6 o4o270uOxyrv0MkE9/T61D+JVCVCHsEaJAvePeWZrHtou2LSUK+ubSoJBfElj8ikWmxd 3CiTa0iIN6ZrEUkLdP1NYagmFzVnOLqkgG+T6pHA/x/vR9DC3w7knvXxzjQawDmkYa4a 4w1qI8tgG3vHtpYmljOFpgzI1SBLetUww2DiBI5teN63wCEB/mn1Sc4jp4JgsJOhRJVH BwaQ== X-Gm-Message-State: AOJu0YxlGie1Fy2NjXXRBRqrS85Lu8sm7hltKeC2mD8YHnkyCtRLE92J xmrBhKU6Pq0OROkfS6u2baKVHpS1/Oe37klDegZcIzRkn9HVzS5ec0GyOebFGCfzoU9yMqzUgh4 V X-Google-Smtp-Source: AGHT+IHT1A8VruEEUPyT6k2piav7xyg8nDISvUSK+l2vWTHFrxF8dHWEE8170GWtVbpngR8dVdiiWA== X-Received: by 2002:ad4:57d0:0:b0:690:d86e:4f91 with SMTP id y16-20020ad457d0000000b00690d86e4f91mr4198453qvx.48.1710547294880; Fri, 15 Mar 2024 17:01:34 -0700 (PDT) From: Kevin O'Connor To: seabios@seabios.org Date: Fri, 15 Mar 2024 19:57:47 -0400 Message-ID: <20240316000129.4099892-2-kevin@koconnor.net> In-Reply-To: <20240316000129.4099892-1-kevin@koconnor.net> References: <20240316000129.4099892-1-kevin@koconnor.net> MIME-Version: 1.0 X-Spam-Level: *** Message-ID-Hash: TRQDJYHQAG53YGTSAW42AFTFWWGIEUAT X-Message-ID-Hash: TRQDJYHQAG53YGTSAW42AFTFWWGIEUAT X-MailFrom: kevin@koconnor.net X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-seabios.seabios.org-0; header-match-seabios.seabios.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.6b1 Precedence: list Subject: [SeaBIOS] [PATCH 1/2] vgasrc: Use curmode_g instead of vmode_g when mode is the current video mode List-Id: SeaBIOS mailing list Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable Authentication-Results: coreboot.org; auth=pass smtp.auth=mailman@coreboot.org smtp.mailfrom=seabios-bounces@seabios.org X-Spamd-Bar: / X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1710547324327100001 Content-Type: text/plain; charset="utf-8" Many functions are passed a pointer to the current video mode vgamode_s struct. Use the name 'curmode_g' for these functions and use 'vmode_g' for functions that can accept an arbitrary video mode. Hopefully this will make the goals of the functions more clear. Signed-off-by: Kevin O'Connor --- vgasrc/bochsvga.c | 40 ++++++++++---------- vgasrc/bochsvga.h | 16 ++++---- vgasrc/cbvga.c | 16 ++++---- vgasrc/clext.c | 20 +++++----- vgasrc/stdvga.c | 24 ++++++------ vgasrc/stdvga.h | 16 ++++---- vgasrc/stdvgamodes.c | 12 +++--- vgasrc/swcursor.c | 16 ++++---- vgasrc/vbe.c | 51 ++++++++++++------------- vgasrc/vgabios.c | 6 +-- vgasrc/vgafb.c | 88 ++++++++++++++++++++++---------------------- vgasrc/vgafb.h | 4 +- vgasrc/vgahw.h | 76 +++++++++++++++++++------------------- vgasrc/vgautil.h | 28 +++++++------- 14 files changed, 206 insertions(+), 207 deletions(-) diff --git a/vgasrc/bochsvga.c b/vgasrc/bochsvga.c index fd5e586..ab8f25e 100644 --- a/vgasrc/bochsvga.c +++ b/vgasrc/bochsvga.c @@ -93,20 +93,20 @@ bochsvga_dispi_enabled(void) } =20 int -bochsvga_get_window(struct vgamode_s *vmode_g, int window) +bochsvga_get_window(struct vgamode_s *curmode_g, int window) { if (!bochsvga_dispi_enabled()) - return stdvga_get_window(vmode_g, window); + return stdvga_get_window(curmode_g, window); if (window !=3D 0) return -1; return dispi_read(VBE_DISPI_INDEX_BANK); } =20 int -bochsvga_set_window(struct vgamode_s *vmode_g, int window, int val) +bochsvga_set_window(struct vgamode_s *curmode_g, int window, int val) { if (!bochsvga_dispi_enabled()) - return stdvga_set_window(vmode_g, window, val); + return stdvga_set_window(curmode_g, window, val); if (window !=3D 0) return -1; dispi_write(VBE_DISPI_INDEX_BANK, val); @@ -116,30 +116,30 @@ bochsvga_set_window(struct vgamode_s *vmode_g, int wi= ndow, int val) } =20 int -bochsvga_get_linelength(struct vgamode_s *vmode_g) +bochsvga_get_linelength(struct vgamode_s *curmode_g) { if (!bochsvga_dispi_enabled()) - return stdvga_get_linelength(vmode_g); - return dispi_read(VBE_DISPI_INDEX_VIRT_WIDTH) * vga_bpp(vmode_g) / 8; + return stdvga_get_linelength(curmode_g); + return dispi_read(VBE_DISPI_INDEX_VIRT_WIDTH) * vga_bpp(curmode_g) / 8; } =20 int -bochsvga_set_linelength(struct vgamode_s *vmode_g, int val) +bochsvga_set_linelength(struct vgamode_s *curmode_g, int val) { - stdvga_set_linelength(vmode_g, val); + stdvga_set_linelength(curmode_g, val); if (bochsvga_dispi_enabled()) { - int pixels =3D (val * 8) / vga_bpp(vmode_g); + int pixels =3D (val * 8) / vga_bpp(curmode_g); dispi_write(VBE_DISPI_INDEX_VIRT_WIDTH, pixels); } return 0; } =20 int -bochsvga_get_displaystart(struct vgamode_s *vmode_g) +bochsvga_get_displaystart(struct vgamode_s *curmode_g) { if (!bochsvga_dispi_enabled()) - return stdvga_get_displaystart(vmode_g); - int bpp =3D vga_bpp(vmode_g); + return stdvga_get_displaystart(curmode_g); + int bpp =3D vga_bpp(curmode_g); int linelength =3D dispi_read(VBE_DISPI_INDEX_VIRT_WIDTH) * bpp / 8; int x =3D dispi_read(VBE_DISPI_INDEX_X_OFFSET); int y =3D dispi_read(VBE_DISPI_INDEX_Y_OFFSET); @@ -147,11 +147,11 @@ bochsvga_get_displaystart(struct vgamode_s *vmode_g) } =20 int -bochsvga_set_displaystart(struct vgamode_s *vmode_g, int val) +bochsvga_set_displaystart(struct vgamode_s *curmode_g, int val) { - stdvga_set_displaystart(vmode_g, val); + stdvga_set_displaystart(curmode_g, val); if (bochsvga_dispi_enabled()) { - int bpp =3D vga_bpp(vmode_g); + int bpp =3D vga_bpp(curmode_g); int linelength =3D dispi_read(VBE_DISPI_INDEX_VIRT_WIDTH) * bpp / = 8; if (!linelength) return 0; @@ -162,19 +162,19 @@ bochsvga_set_displaystart(struct vgamode_s *vmode_g, = int val) } =20 int -bochsvga_get_dacformat(struct vgamode_s *vmode_g) +bochsvga_get_dacformat(struct vgamode_s *curmode_g) { if (!bochsvga_dispi_enabled()) - return stdvga_get_dacformat(vmode_g); + return stdvga_get_dacformat(curmode_g); u16 en =3D dispi_read(VBE_DISPI_INDEX_ENABLE); return (en & VBE_DISPI_8BIT_DAC) ? 8 : 6; } =20 int -bochsvga_set_dacformat(struct vgamode_s *vmode_g, int val) +bochsvga_set_dacformat(struct vgamode_s *curmode_g, int val) { if (!bochsvga_dispi_enabled()) - return stdvga_set_dacformat(vmode_g, val); + return stdvga_set_dacformat(curmode_g, val); u16 en =3D dispi_read(VBE_DISPI_INDEX_ENABLE); if (val =3D=3D 6) en &=3D ~VBE_DISPI_8BIT_DAC; diff --git a/vgasrc/bochsvga.h b/vgasrc/bochsvga.h index ae5f75d..93d1b38 100644 --- a/vgasrc/bochsvga.h +++ b/vgasrc/bochsvga.h @@ -42,14 +42,14 @@ =20 struct vgamode_s *bochsvga_find_mode(int mode); void bochsvga_list_modes(u16 seg, u16 *dest, u16 *last); -int bochsvga_get_window(struct vgamode_s *vmode_g, int window); -int bochsvga_set_window(struct vgamode_s *vmode_g, int window, int val); -int bochsvga_get_linelength(struct vgamode_s *vmode_g); -int bochsvga_set_linelength(struct vgamode_s *vmode_g, int val); -int bochsvga_get_displaystart(struct vgamode_s *vmode_g); -int bochsvga_set_displaystart(struct vgamode_s *vmode_g, int val); -int bochsvga_get_dacformat(struct vgamode_s *vmode_g); -int bochsvga_set_dacformat(struct vgamode_s *vmode_g, int val); +int bochsvga_get_window(struct vgamode_s *curmode_g, int window); +int bochsvga_set_window(struct vgamode_s *curmode_g, int window, int val); +int bochsvga_get_linelength(struct vgamode_s *curmode_g); +int bochsvga_set_linelength(struct vgamode_s *curmode_g, int val); +int bochsvga_get_displaystart(struct vgamode_s *curmode_g); +int bochsvga_set_displaystart(struct vgamode_s *curmode_g, int val); +int bochsvga_get_dacformat(struct vgamode_s *curmode_g); +int bochsvga_set_dacformat(struct vgamode_s *curmode_g, int val); int bochsvga_save_restore(int cmd, u16 seg, void *data); int bochsvga_set_mode(struct vgamode_s *vmode_g, int flags); int bochsvga_setup(void); diff --git a/vgasrc/cbvga.c b/vgasrc/cbvga.c index b919137..9e3cc93 100644 --- a/vgasrc/cbvga.c +++ b/vgasrc/cbvga.c @@ -70,49 +70,49 @@ cbvga_list_modes(u16 seg, u16 *dest, u16 *last) } =20 int -cbvga_get_window(struct vgamode_s *vmode_g, int window) +cbvga_get_window(struct vgamode_s *curmode_g, int window) { return -1; } =20 int -cbvga_set_window(struct vgamode_s *vmode_g, int window, int val) +cbvga_set_window(struct vgamode_s *curmode_g, int window, int val) { return -1; } =20 int -cbvga_get_linelength(struct vgamode_s *vmode_g) +cbvga_get_linelength(struct vgamode_s *curmode_g) { return GET_GLOBAL(CBlinelength); } =20 int -cbvga_set_linelength(struct vgamode_s *vmode_g, int val) +cbvga_set_linelength(struct vgamode_s *curmode_g, int val) { return -1; } =20 int -cbvga_get_displaystart(struct vgamode_s *vmode_g) +cbvga_get_displaystart(struct vgamode_s *curmode_g) { return 0; } =20 int -cbvga_set_displaystart(struct vgamode_s *vmode_g, int val) +cbvga_set_displaystart(struct vgamode_s *curmode_g, int val) { return -1; } =20 int -cbvga_get_dacformat(struct vgamode_s *vmode_g) +cbvga_get_dacformat(struct vgamode_s *curmode_g) { return -1; } =20 int -cbvga_set_dacformat(struct vgamode_s *vmode_g, int val) +cbvga_set_dacformat(struct vgamode_s *curmode_g, int val) { return -1; } diff --git a/vgasrc/clext.c b/vgasrc/clext.c index da8b790..c89a47b 100644 --- a/vgasrc/clext.c +++ b/vgasrc/clext.c @@ -309,13 +309,13 @@ clext_list_modes(u16 seg, u16 *dest, u16 *last) ****************************************************************/ =20 int -clext_get_window(struct vgamode_s *vmode_g, int window) +clext_get_window(struct vgamode_s *curmode_g, int window) { return stdvga_grdc_read(window + 9); } =20 int -clext_set_window(struct vgamode_s *vmode_g, int window, int val) +clext_set_window(struct vgamode_s *curmode_g, int window, int val) { if (val >=3D 0x100) return -1; @@ -324,26 +324,26 @@ clext_set_window(struct vgamode_s *vmode_g, int windo= w, int val) } =20 int -clext_get_linelength(struct vgamode_s *vmode_g) +clext_get_linelength(struct vgamode_s *curmode_g) { u16 crtc_addr =3D stdvga_get_crtc(); u8 reg13 =3D stdvga_crtc_read(crtc_addr, 0x13); u8 reg1b =3D stdvga_crtc_read(crtc_addr, 0x1b); - return (((reg1b & 0x10) << 4) + reg13) * 8 / stdvga_vram_ratio(vmode_g= ); + return (((reg1b & 0x10) << 4) + reg13) * 8 / stdvga_vram_ratio(curmode= _g); } =20 int -clext_set_linelength(struct vgamode_s *vmode_g, int val) +clext_set_linelength(struct vgamode_s *curmode_g, int val) { u16 crtc_addr =3D stdvga_get_crtc(); - val =3D DIV_ROUND_UP(val * stdvga_vram_ratio(vmode_g), 8); + val =3D DIV_ROUND_UP(val * stdvga_vram_ratio(curmode_g), 8); stdvga_crtc_write(crtc_addr, 0x13, val); stdvga_crtc_mask(crtc_addr, 0x1b, 0x10, (val & 0x100) >> 4); return 0; } =20 int -clext_get_displaystart(struct vgamode_s *vmode_g) +clext_get_displaystart(struct vgamode_s *curmode_g) { u16 crtc_addr =3D stdvga_get_crtc(); u8 b2 =3D stdvga_crtc_read(crtc_addr, 0x0c); @@ -352,14 +352,14 @@ clext_get_displaystart(struct vgamode_s *vmode_g) u8 b4 =3D stdvga_crtc_read(crtc_addr, 0x1d); int val =3D (b1 | (b2<<8) | ((b3 & 0x01) << 16) | ((b3 & 0x0c) << 15) | ((b4 & 0x80) << 12)); - return val * 4 / stdvga_vram_ratio(vmode_g); + return val * 4 / stdvga_vram_ratio(curmode_g); } =20 int -clext_set_displaystart(struct vgamode_s *vmode_g, int val) +clext_set_displaystart(struct vgamode_s *curmode_g, int val) { u16 crtc_addr =3D stdvga_get_crtc(); - val =3D val * stdvga_vram_ratio(vmode_g) / 4; + val =3D val * stdvga_vram_ratio(curmode_g) / 4; stdvga_crtc_write(crtc_addr, 0x0d, val); stdvga_crtc_write(crtc_addr, 0x0c, val >> 8); stdvga_crtc_mask(crtc_addr, 0x1d, 0x80, (val & 0x0800) >> 4); diff --git a/vgasrc/stdvga.c b/vgasrc/stdvga.c index 0e01275..9d8f556 100644 --- a/vgasrc/stdvga.c +++ b/vgasrc/stdvga.c @@ -264,59 +264,59 @@ stdvga_get_vde(void) } =20 int -stdvga_get_window(struct vgamode_s *vmode_g, int window) +stdvga_get_window(struct vgamode_s *curmode_g, int window) { return -1; } =20 int -stdvga_set_window(struct vgamode_s *vmode_g, int window, int val) +stdvga_set_window(struct vgamode_s *curmode_g, int window, int val) { return -1; } =20 int -stdvga_get_linelength(struct vgamode_s *vmode_g) +stdvga_get_linelength(struct vgamode_s *curmode_g) { u8 val =3D stdvga_crtc_read(stdvga_get_crtc(), 0x13); - return val * 8 / stdvga_vram_ratio(vmode_g); + return val * 8 / stdvga_vram_ratio(curmode_g); } =20 int -stdvga_set_linelength(struct vgamode_s *vmode_g, int val) +stdvga_set_linelength(struct vgamode_s *curmode_g, int val) { - val =3D DIV_ROUND_UP(val * stdvga_vram_ratio(vmode_g), 8); + val =3D DIV_ROUND_UP(val * stdvga_vram_ratio(curmode_g), 8); stdvga_crtc_write(stdvga_get_crtc(), 0x13, val); return 0; } =20 int -stdvga_get_displaystart(struct vgamode_s *vmode_g) +stdvga_get_displaystart(struct vgamode_s *curmode_g) { u16 crtc_addr =3D stdvga_get_crtc(); int addr =3D (stdvga_crtc_read(crtc_addr, 0x0c) << 8 | stdvga_crtc_read(crtc_addr, 0x0d)); - return addr * 4 / stdvga_vram_ratio(vmode_g); + return addr * 4 / stdvga_vram_ratio(curmode_g); } =20 int -stdvga_set_displaystart(struct vgamode_s *vmode_g, int val) +stdvga_set_displaystart(struct vgamode_s *curmode_g, int val) { u16 crtc_addr =3D stdvga_get_crtc(); - val =3D val * stdvga_vram_ratio(vmode_g) / 4; + val =3D val * stdvga_vram_ratio(curmode_g) / 4; stdvga_crtc_write(crtc_addr, 0x0c, val >> 8); stdvga_crtc_write(crtc_addr, 0x0d, val); return 0; } =20 int -stdvga_get_dacformat(struct vgamode_s *vmode_g) +stdvga_get_dacformat(struct vgamode_s *curmode_g) { return -1; } =20 int -stdvga_set_dacformat(struct vgamode_s *vmode_g, int val) +stdvga_set_dacformat(struct vgamode_s *curmode_g, int val) { return -1; } diff --git a/vgasrc/stdvga.h b/vgasrc/stdvga.h index 4184c60..5164ca1 100644 --- a/vgasrc/stdvga.h +++ b/vgasrc/stdvga.h @@ -66,14 +66,14 @@ void stdvga_set_cursor_shape(u16 cursor_type); void stdvga_set_cursor_pos(int address); void stdvga_set_scan_lines(u8 lines); u16 stdvga_get_vde(void); -int stdvga_get_window(struct vgamode_s *vmode_g, int window); -int stdvga_set_window(struct vgamode_s *vmode_g, int window, int val); -int stdvga_get_linelength(struct vgamode_s *vmode_g); -int stdvga_set_linelength(struct vgamode_s *vmode_g, int val); -int stdvga_get_displaystart(struct vgamode_s *vmode_g); -int stdvga_set_displaystart(struct vgamode_s *vmode_g, int val); -int stdvga_get_dacformat(struct vgamode_s *vmode_g); -int stdvga_set_dacformat(struct vgamode_s *vmode_g, int val); +int stdvga_get_window(struct vgamode_s *curmode_g, int window); +int stdvga_set_window(struct vgamode_s *curmode_g, int window, int val); +int stdvga_get_linelength(struct vgamode_s *curmode_g); +int stdvga_set_linelength(struct vgamode_s *curmode_g, int val); +int stdvga_get_displaystart(struct vgamode_s *curmode_g); +int stdvga_set_displaystart(struct vgamode_s *curmode_g, int val); +int stdvga_get_dacformat(struct vgamode_s *curmode_g); +int stdvga_set_dacformat(struct vgamode_s *curmode_g, int val); int stdvga_save_restore(int cmd, u16 seg, void *data); void stdvga_enable_video_addressing(u8 disable); int stdvga_setup(void); diff --git a/vgasrc/stdvgamodes.c b/vgasrc/stdvgamodes.c index 173dd4f..3e6b575 100644 --- a/vgasrc/stdvgamodes.c +++ b/vgasrc/stdvgamodes.c @@ -431,19 +431,17 @@ stdvga_override_crtc(int mode, u8 *crtc) } =20 static void -clear_screen(struct vgamode_s *vmode_g) +clear_screen(struct vgamode_s *curmode_g) { - switch (GET_GLOBAL(vmode_g->memmodel)) { + switch (GET_GLOBAL(curmode_g->memmodel)) { case MM_TEXT: - memset16_far(GET_GLOBAL(vmode_g->sstart), 0, 0x0720, 32*1024); + memset16_far(GET_GLOBAL(curmode_g->sstart), 0, 0x0720, 32*1024); break; case MM_CGA: - memset16_far(GET_GLOBAL(vmode_g->sstart), 0, 0x0000, 32*1024); + memset16_far(GET_GLOBAL(curmode_g->sstart), 0, 0x0000, 32*1024); break; default: - // XXX - old code gets/sets/restores sequ register 2 to 0xf - - // but it should always be 0xf anyway. - memset16_far(GET_GLOBAL(vmode_g->sstart), 0, 0x0000, 64*1024); + memset16_far(GET_GLOBAL(curmode_g->sstart), 0, 0x0000, 64*1024); } } =20 diff --git a/vgasrc/swcursor.c b/vgasrc/swcursor.c index f2212d5..765a7c7 100644 --- a/vgasrc/swcursor.c +++ b/vgasrc/swcursor.c @@ -12,12 +12,12 @@ =20 // Draw/undraw a cursor on the framebuffer by xor'ing the cursor cell static void -gfx_set_swcursor(struct vgamode_s *vmode_g, int enable, struct cursorpos c= p) +gfx_set_swcursor(struct vgamode_s *curmode_g, int enable, struct cursorpos= cp) { u16 cursor_type =3D get_cursor_shape(); u8 start =3D cursor_type >> 8, end =3D cursor_type & 0xff; struct gfx_op op; - init_gfx_op(&op, vmode_g); + init_gfx_op(&op, curmode_g); op.x =3D cp.x * 8; int cheight =3D GET_BDA(char_height); op.y =3D cp.y * cheight + start; @@ -42,8 +42,8 @@ set_swcursor(int enable) if (!!(flags & BF_SWCURSOR) =3D=3D enable) // Already in requested mode. return; - struct vgamode_s *vmode_g =3D get_current_mode(); - if (!vmode_g) + struct vgamode_s *curmode_g =3D get_current_mode(); + if (!curmode_g) return; struct cursorpos cp =3D get_cursor_pos(GET_BDA(video_page)); if (cp.x >=3D GET_BDA(video_cols) || cp.y > GET_BDA(video_rows) @@ -53,16 +53,16 @@ set_swcursor(int enable) =20 SET_BDA_EXT(flags, (flags & ~BF_SWCURSOR) | (enable ? BF_SWCURSOR : 0)= ); =20 - if (GET_GLOBAL(vmode_g->memmodel) !=3D MM_TEXT) { - gfx_set_swcursor(vmode_g, enable, cp); + if (GET_GLOBAL(curmode_g->memmodel) !=3D MM_TEXT) { + gfx_set_swcursor(curmode_g, enable, cp); return; } =20 // In text mode, swap foreground and background attributes for cursor void *dest_far =3D text_address(cp) + 1; - u8 attr =3D GET_FARVAR(GET_GLOBAL(vmode_g->sstart), *(u8*)dest_far); + u8 attr =3D GET_FARVAR(GET_GLOBAL(curmode_g->sstart), *(u8*)dest_far); attr =3D (attr >> 4) | (attr << 4); - SET_FARVAR(GET_GLOBAL(vmode_g->sstart), *(u8*)dest_far, attr); + SET_FARVAR(GET_GLOBAL(curmode_g->sstart), *(u8*)dest_far, attr); } =20 // Disable virtual cursor if a vgabios call accesses the framebuffer diff --git a/vgasrc/vbe.c b/vgasrc/vbe.c index d7ce941..3efb54f 100644 --- a/vgasrc/vbe.c +++ b/vgasrc/vbe.c @@ -260,18 +260,18 @@ vbe_104f05(struct bregs *regs) regs->ah =3D VBE_RETURN_STATUS_INVALID; return; } - struct vgamode_s *vmode_g =3D get_current_mode(); - if (! vmode_g) + struct vgamode_s *curmode_g =3D get_current_mode(); + if (! curmode_g) goto fail; if (regs->bh) { - int ret =3D vgahw_get_window(vmode_g, regs->bl); + int ret =3D vgahw_get_window(curmode_g, regs->bl); if (ret < 0) goto fail; regs->dx =3D ret; regs->ax =3D 0x004f; return; } - int ret =3D vgahw_set_window(vmode_g, regs->bl, regs->dx); + int ret =3D vgahw_set_window(curmode_g, regs->bl, regs->dx); if (ret) goto fail; regs->ax =3D 0x004f; @@ -285,21 +285,22 @@ vbe_104f06(struct bregs *regs) { if (regs->bl > 0x02) goto fail; - struct vgamode_s *vmode_g =3D get_current_mode(); - if (! vmode_g) + struct vgamode_s *curmode_g =3D get_current_mode(); + if (! curmode_g) goto fail; - int bpp =3D vga_bpp(vmode_g); + int bpp =3D vga_bpp(curmode_g); =20 if (regs->bl =3D=3D 0x00) { - int ret =3D vgahw_set_linelength(vmode_g, DIV_ROUND_UP(regs->cx * = bpp, 8)); + int ret =3D vgahw_set_linelength(curmode_g + , DIV_ROUND_UP(regs->cx * bpp, 8)); if (ret) goto fail; } else if (regs->bl =3D=3D 0x02) { - int ret =3D vgahw_set_linelength(vmode_g, regs->cx); + int ret =3D vgahw_set_linelength(curmode_g, regs->cx); if (ret) goto fail; } - int linelength =3D vgahw_get_linelength(vmode_g); + int linelength =3D vgahw_get_linelength(curmode_g); if (linelength < 0) goto fail; =20 @@ -315,11 +316,11 @@ fail: static void vbe_104f07(struct bregs *regs) { - struct vgamode_s *vmode_g =3D get_current_mode(); - if (! vmode_g) + struct vgamode_s *curmode_g =3D get_current_mode(); + if (! curmode_g) goto fail; - int bpp =3D vga_bpp(vmode_g); - int linelength =3D vgahw_get_linelength(vmode_g); + int bpp =3D vga_bpp(curmode_g); + int linelength =3D vgahw_get_linelength(curmode_g); if (linelength < 0) goto fail; =20 @@ -328,12 +329,12 @@ vbe_104f07(struct bregs *regs) case 0x80: case 0x00: ret =3D vgahw_set_displaystart( - vmode_g, DIV_ROUND_UP(regs->cx * bpp, 8) + linelength * regs->= dx); + curmode_g, DIV_ROUND_UP(regs->cx * bpp, 8) + linelength * regs= ->dx); if (ret) goto fail; break; case 0x01: - ret =3D vgahw_get_displaystart(vmode_g); + ret =3D vgahw_get_displaystart(curmode_g); if (ret < 0) goto fail; regs->dx =3D ret / linelength; @@ -351,10 +352,10 @@ fail: static void vbe_104f08(struct bregs *regs) { - struct vgamode_s *vmode_g =3D get_current_mode(); - if (! vmode_g) + struct vgamode_s *curmode_g =3D get_current_mode(); + if (! curmode_g) goto fail; - u8 memmodel =3D GET_GLOBAL(vmode_g->memmodel); + u8 memmodel =3D GET_GLOBAL(curmode_g->memmodel); if (memmodel =3D=3D MM_DIRECT || memmodel =3D=3D MM_YUV) { regs->ax =3D 0x034f; return; @@ -362,11 +363,11 @@ vbe_104f08(struct bregs *regs) if (regs->bl > 1) goto fail; if (regs->bl =3D=3D 0) { - int ret =3D vgahw_set_dacformat(vmode_g, regs->bh); + int ret =3D vgahw_set_dacformat(curmode_g, regs->bh); if (ret < 0) goto fail; } - int ret =3D vgahw_get_dacformat(vmode_g); + int ret =3D vgahw_get_dacformat(curmode_g); if (ret < 0) goto fail; regs->bh =3D ret; @@ -385,11 +386,11 @@ vbe_104f09(struct bregs *regs) return; } =20 - struct vgamode_s *vmode_g =3D get_current_mode(); - if (! vmode_g) + struct vgamode_s *curmode_g =3D get_current_mode(); + if (! curmode_g) goto fail; - u8 memmodel =3D GET_GLOBAL(vmode_g->memmodel); - u8 depth =3D GET_GLOBAL(vmode_g->depth); + u8 memmodel =3D GET_GLOBAL(curmode_g->memmodel); + u8 depth =3D GET_GLOBAL(curmode_g->depth); if (memmodel =3D=3D MM_DIRECT || memmodel =3D=3D MM_YUV || depth > 8) { regs->ax =3D 0x034f; return; diff --git a/vgasrc/vgabios.c b/vgasrc/vgabios.c index 73ba1c3..2ca8c3d 100644 --- a/vgasrc/vgabios.c +++ b/vgasrc/vgabios.c @@ -114,14 +114,14 @@ set_active_page(u8 page) return; =20 // Get the mode - struct vgamode_s *vmode_g =3D get_current_mode(); - if (!vmode_g) + struct vgamode_s *curmode_g =3D get_current_mode(); + if (!curmode_g) return; =20 // Calculate memory address of start of page struct cursorpos cp =3D {0, 0, page}; int address =3D (int)text_address(cp); - vgahw_set_displaystart(vmode_g, address); + vgahw_set_displaystart(curmode_g, address); =20 // And change the BIOS page SET_BDA(video_pagestart, address); diff --git a/vgasrc/vgafb.c b/vgasrc/vgafb.c index f8f35c2..bb4f11e 100644 --- a/vgasrc/vgafb.c +++ b/vgasrc/vgafb.c @@ -98,7 +98,7 @@ gfx_planar(struct gfx_op *op) static void gfx_cga(struct gfx_op *op) { - int bpp =3D GET_GLOBAL(op->vmode_g->depth); + int bpp =3D GET_GLOBAL(op->curmode_g->depth); void *dest_far =3D (void*)(op->y / 2 * op->linelength + op->x / 8 * bp= p); switch (op->op) { default: @@ -270,7 +270,7 @@ gfx_direct(struct gfx_op *op) void *fb =3D (void*)GET_GLOBAL(VBE_framebuffer); if (!fb) return; - int depth =3D GET_GLOBAL(op->vmode_g->depth); + int depth =3D GET_GLOBAL(op->curmode_g->depth); int bypp =3D DIV_ROUND_UP(depth, 8); void *dest_far =3D (fb + op->displaystart + op->y * op->linelength + op->x * bypp); @@ -314,19 +314,19 @@ gfx_direct(struct gfx_op *op) =20 // Prepare a struct gfx_op for use. void -init_gfx_op(struct gfx_op *op, struct vgamode_s *vmode_g) +init_gfx_op(struct gfx_op *op, struct vgamode_s *curmode_g) { memset(op, 0, sizeof(*op)); - op->vmode_g =3D vmode_g; - op->linelength =3D vgahw_get_linelength(vmode_g); - op->displaystart =3D vgahw_get_displaystart(vmode_g); + op->curmode_g =3D curmode_g; + op->linelength =3D vgahw_get_linelength(curmode_g); + op->displaystart =3D vgahw_get_displaystart(curmode_g); } =20 // Issue a graphics operation. void handle_gfx_op(struct gfx_op *op) { - switch (GET_GLOBAL(op->vmode_g->memmodel)) { + switch (GET_GLOBAL(op->curmode_g->memmodel)) { case MM_PLANAR: gfx_planar(op); break; @@ -346,11 +346,11 @@ handle_gfx_op(struct gfx_op *op) =20 // Move characters when in graphics mode. static void -gfx_move_chars(struct vgamode_s *vmode_g, struct cursorpos dest +gfx_move_chars(struct vgamode_s *curmode_g, struct cursorpos dest , struct cursorpos movesize, int lines) { struct gfx_op op; - init_gfx_op(&op, vmode_g); + init_gfx_op(&op, curmode_g); op.x =3D dest.x * 8; op.xlen =3D movesize.x * 8; int cheight =3D GET_BDA(char_height); @@ -363,11 +363,11 @@ gfx_move_chars(struct vgamode_s *vmode_g, struct curs= orpos dest =20 // Clear area of screen in graphics mode. static void -gfx_clear_chars(struct vgamode_s *vmode_g, struct cursorpos win +gfx_clear_chars(struct vgamode_s *curmode_g, struct cursorpos win , struct cursorpos winsize, struct carattr ca) { struct gfx_op op; - init_gfx_op(&op, vmode_g); + init_gfx_op(&op, curmode_g); op.x =3D win.x * 8; op.xlen =3D winsize.x * 8; int cheight =3D GET_BDA(char_height); @@ -398,7 +398,7 @@ get_font_data(u8 c) =20 // Write a character to the screen in graphics mode. static void -gfx_write_char(struct vgamode_s *vmode_g +gfx_write_char(struct vgamode_s *curmode_g , struct cursorpos cp, struct carattr ca) { if (cp.x >=3D GET_BDA(video_cols)) @@ -406,7 +406,7 @@ gfx_write_char(struct vgamode_s *vmode_g =20 struct segoff_s font =3D get_font_data(ca.car); struct gfx_op op; - init_gfx_op(&op, vmode_g); + init_gfx_op(&op, curmode_g); op.x =3D cp.x * 8; int cheight =3D GET_BDA(char_height); op.y =3D cp.y * cheight; @@ -425,7 +425,7 @@ gfx_write_char(struct vgamode_s *vmode_g bgattr =3D op.pixels[7]; fgattr =3D bgattr ^ 0x7; } - } else if (fgattr & 0x80 && GET_GLOBAL(vmode_g->depth) < 8) { + } else if (fgattr & 0x80 && GET_GLOBAL(curmode_g->depth) < 8) { usexor =3D 1; fgattr &=3D 0x7f; } @@ -450,7 +450,7 @@ gfx_write_char(struct vgamode_s *vmode_g =20 // Read a character from the screen in graphics mode. static struct carattr -gfx_read_char(struct vgamode_s *vmode_g, struct cursorpos cp) +gfx_read_char(struct vgamode_s *curmode_g, struct cursorpos cp) { u8 lines[16]; int cheight =3D GET_BDA(char_height); @@ -459,7 +459,7 @@ gfx_read_char(struct vgamode_s *vmode_g, struct cursorp= os cp) =20 // Read cell from screen struct gfx_op op; - init_gfx_op(&op, vmode_g); + init_gfx_op(&op, curmode_g); op.op =3D GO_READ8; op.x =3D cp.x * 8; op.y =3D cp.y * cheight; @@ -502,18 +502,18 @@ fail: void vgafb_write_pixel(u8 color, u16 x, u16 y) { - struct vgamode_s *vmode_g =3D get_current_mode(); - if (!vmode_g) + struct vgamode_s *curmode_g =3D get_current_mode(); + if (!curmode_g) return; =20 struct gfx_op op; - init_gfx_op(&op, vmode_g); + init_gfx_op(&op, curmode_g); op.x =3D ALIGN_DOWN(x, 8); op.y =3D y; op.op =3D GO_READ8; handle_gfx_op(&op); =20 - int usexor =3D color & 0x80 && GET_GLOBAL(vmode_g->depth) < 8; + int usexor =3D color & 0x80 && GET_GLOBAL(curmode_g->depth) < 8; if (usexor) op.pixels[x & 0x07] ^=3D color & 0x7f; else @@ -526,12 +526,12 @@ vgafb_write_pixel(u8 color, u16 x, u16 y) u8 vgafb_read_pixel(u16 x, u16 y) { - struct vgamode_s *vmode_g =3D get_current_mode(); - if (!vmode_g) + struct vgamode_s *curmode_g =3D get_current_mode(); + if (!curmode_g) return 0; =20 struct gfx_op op; - init_gfx_op(&op, vmode_g); + init_gfx_op(&op, curmode_g); op.x =3D ALIGN_DOWN(x, 8); op.y =3D y; op.op =3D GO_READ8; @@ -558,18 +558,18 @@ text_address(struct cursorpos cp) static void vgafb_move_chars(struct cursorpos dest, struct cursorpos movesize, int lin= es) { - struct vgamode_s *vmode_g =3D get_current_mode(); - if (!vmode_g) + struct vgamode_s *curmode_g =3D get_current_mode(); + if (!curmode_g) return; =20 - if (GET_GLOBAL(vmode_g->memmodel) !=3D MM_TEXT) { - gfx_move_chars(vmode_g, dest, movesize, lines); + if (GET_GLOBAL(curmode_g->memmodel) !=3D MM_TEXT) { + gfx_move_chars(curmode_g, dest, movesize, lines); return; } =20 int stride =3D GET_BDA(video_cols) * 2; void *dest_addr =3D text_address(dest), *src_addr =3D dest_addr + line= s * stride; - memmove_stride(GET_GLOBAL(vmode_g->sstart), dest_addr, src_addr + memmove_stride(GET_GLOBAL(curmode_g->sstart), dest_addr, src_addr , movesize.x * 2, stride, movesize.y); } =20 @@ -578,18 +578,18 @@ static void vgafb_clear_chars(struct cursorpos win, struct cursorpos winsize , struct carattr ca) { - struct vgamode_s *vmode_g =3D get_current_mode(); - if (!vmode_g) + struct vgamode_s *curmode_g =3D get_current_mode(); + if (!curmode_g) return; =20 - if (GET_GLOBAL(vmode_g->memmodel) !=3D MM_TEXT) { - gfx_clear_chars(vmode_g, win, winsize, ca); + if (GET_GLOBAL(curmode_g->memmodel) !=3D MM_TEXT) { + gfx_clear_chars(curmode_g, win, winsize, ca); return; } =20 int stride =3D GET_BDA(video_cols) * 2; u16 attr =3D ((ca.use_attr ? ca.attr : 0x07) << 8) | ca.car; - memset16_stride(GET_GLOBAL(vmode_g->sstart), text_address(win), attr + memset16_stride(GET_GLOBAL(curmode_g->sstart), text_address(win), attr , winsize.x * 2, stride, winsize.y); } =20 @@ -625,21 +625,21 @@ vgafb_scroll(struct cursorpos win, struct cursorpos w= insize void vgafb_write_char(struct cursorpos cp, struct carattr ca) { - struct vgamode_s *vmode_g =3D get_current_mode(); - if (!vmode_g) + struct vgamode_s *curmode_g =3D get_current_mode(); + if (!curmode_g) return; =20 - if (GET_GLOBAL(vmode_g->memmodel) !=3D MM_TEXT) { - gfx_write_char(vmode_g, cp, ca); + if (GET_GLOBAL(curmode_g->memmodel) !=3D MM_TEXT) { + gfx_write_char(curmode_g, cp, ca); return; } =20 void *dest_far =3D text_address(cp); if (ca.use_attr) { u16 dummy =3D (ca.attr << 8) | ca.car; - SET_FARVAR(GET_GLOBAL(vmode_g->sstart), *(u16*)dest_far, dummy); + SET_FARVAR(GET_GLOBAL(curmode_g->sstart), *(u16*)dest_far, dummy); } else { - SET_FARVAR(GET_GLOBAL(vmode_g->sstart), *(u8*)dest_far, ca.car); + SET_FARVAR(GET_GLOBAL(curmode_g->sstart), *(u8*)dest_far, ca.car); } } =20 @@ -647,14 +647,14 @@ vgafb_write_char(struct cursorpos cp, struct carattr = ca) struct carattr vgafb_read_char(struct cursorpos cp) { - struct vgamode_s *vmode_g =3D get_current_mode(); - if (!vmode_g) + struct vgamode_s *curmode_g =3D get_current_mode(); + if (!curmode_g) return (struct carattr){0, 0, 0}; =20 - if (GET_GLOBAL(vmode_g->memmodel) !=3D MM_TEXT) - return gfx_read_char(vmode_g, cp); + if (GET_GLOBAL(curmode_g->memmodel) !=3D MM_TEXT) + return gfx_read_char(curmode_g, cp); =20 u16 *dest_far =3D text_address(cp); - u16 v =3D GET_FARVAR(GET_GLOBAL(vmode_g->sstart), *dest_far); + u16 v =3D GET_FARVAR(GET_GLOBAL(curmode_g->sstart), *dest_far); return (struct carattr){v, v>>8, 0}; } diff --git a/vgasrc/vgafb.h b/vgasrc/vgafb.h index aae6b9b..d564427 100644 --- a/vgasrc/vgafb.h +++ b/vgasrc/vgafb.h @@ -3,7 +3,7 @@ =20 // Graphics pixel operations. struct gfx_op { - struct vgamode_s *vmode_g; + struct vgamode_s *curmode_g; u32 linelength; u32 displaystart; =20 @@ -30,7 +30,7 @@ struct carattr { =20 // vgafb.c void memcpy_high(void *dest, void *src, u32 len); -void init_gfx_op(struct gfx_op *op, struct vgamode_s *vmode_g); +void init_gfx_op(struct gfx_op *op, struct vgamode_s *curmode_g); void handle_gfx_op(struct gfx_op *op); void *text_address(struct cursorpos cp); void vgafb_scroll(struct cursorpos win, struct cursorpos winsize diff --git a/vgasrc/vgahw.h b/vgasrc/vgahw.h index 8b64660..bd33e20 100644 --- a/vgasrc/vgahw.h +++ b/vgasrc/vgahw.h @@ -64,81 +64,81 @@ static inline int vgahw_setup(void) { return stdvga_setup(); } =20 -static inline int vgahw_get_window(struct vgamode_s *vmode_g, int window) { +static inline int vgahw_get_window(struct vgamode_s *curmode_g, int window= ) { if (CONFIG_VGA_CIRRUS) - return clext_get_window(vmode_g, window); + return clext_get_window(curmode_g, window); if (CONFIG_VGA_BOCHS) - return bochsvga_get_window(vmode_g, window); + return bochsvga_get_window(curmode_g, window); if (CONFIG_VGA_EMULATE_TEXT) - return cbvga_get_window(vmode_g, window); - return stdvga_get_window(vmode_g, window); + return cbvga_get_window(curmode_g, window); + return stdvga_get_window(curmode_g, window); } =20 -static inline int vgahw_set_window(struct vgamode_s *vmode_g, int window +static inline int vgahw_set_window(struct vgamode_s *curmode_g, int window , int val) { if (CONFIG_VGA_CIRRUS) - return clext_set_window(vmode_g, window, val); + return clext_set_window(curmode_g, window, val); if (CONFIG_VGA_BOCHS) - return bochsvga_set_window(vmode_g, window, val); + return bochsvga_set_window(curmode_g, window, val); if (CONFIG_VGA_EMULATE_TEXT) - return cbvga_set_window(vmode_g, window, val); - return stdvga_set_window(vmode_g, window, val); + return cbvga_set_window(curmode_g, window, val); + return stdvga_set_window(curmode_g, window, val); } =20 -static inline int vgahw_get_linelength(struct vgamode_s *vmode_g) { +static inline int vgahw_get_linelength(struct vgamode_s *curmode_g) { if (CONFIG_VGA_CIRRUS) - return clext_get_linelength(vmode_g); + return clext_get_linelength(curmode_g); if (CONFIG_VGA_BOCHS) - return bochsvga_get_linelength(vmode_g); + return bochsvga_get_linelength(curmode_g); if (CONFIG_VGA_EMULATE_TEXT) - return cbvga_get_linelength(vmode_g); - return stdvga_get_linelength(vmode_g); + return cbvga_get_linelength(curmode_g); + return stdvga_get_linelength(curmode_g); } =20 -static inline int vgahw_set_linelength(struct vgamode_s *vmode_g, int val)= { +static inline int vgahw_set_linelength(struct vgamode_s *curmode_g, int va= l) { if (CONFIG_VGA_CIRRUS) - return clext_set_linelength(vmode_g, val); + return clext_set_linelength(curmode_g, val); if (CONFIG_VGA_BOCHS) - return bochsvga_set_linelength(vmode_g, val); + return bochsvga_set_linelength(curmode_g, val); if (CONFIG_VGA_EMULATE_TEXT) - return cbvga_set_linelength(vmode_g, val); - return stdvga_set_linelength(vmode_g, val); + return cbvga_set_linelength(curmode_g, val); + return stdvga_set_linelength(curmode_g, val); } =20 -static inline int vgahw_get_displaystart(struct vgamode_s *vmode_g) { +static inline int vgahw_get_displaystart(struct vgamode_s *curmode_g) { if (CONFIG_VGA_CIRRUS) - return clext_get_displaystart(vmode_g); + return clext_get_displaystart(curmode_g); if (CONFIG_VGA_BOCHS) - return bochsvga_get_displaystart(vmode_g); + return bochsvga_get_displaystart(curmode_g); if (CONFIG_VGA_EMULATE_TEXT) - return cbvga_get_displaystart(vmode_g); - return stdvga_get_displaystart(vmode_g); + return cbvga_get_displaystart(curmode_g); + return stdvga_get_displaystart(curmode_g); } =20 -static inline int vgahw_set_displaystart(struct vgamode_s *vmode_g, int va= l) { +static inline int vgahw_set_displaystart(struct vgamode_s *curmode_g, int = val) { if (CONFIG_VGA_CIRRUS) - return clext_set_displaystart(vmode_g, val); + return clext_set_displaystart(curmode_g, val); if (CONFIG_VGA_BOCHS) - return bochsvga_set_displaystart(vmode_g, val); + return bochsvga_set_displaystart(curmode_g, val); if (CONFIG_VGA_EMULATE_TEXT) - return cbvga_set_displaystart(vmode_g, val); - return stdvga_set_displaystart(vmode_g, val); + return cbvga_set_displaystart(curmode_g, val); + return stdvga_set_displaystart(curmode_g, val); } =20 -static inline int vgahw_get_dacformat(struct vgamode_s *vmode_g) { +static inline int vgahw_get_dacformat(struct vgamode_s *curmode_g) { if (CONFIG_VGA_BOCHS) - return bochsvga_get_dacformat(vmode_g); + return bochsvga_get_dacformat(curmode_g); if (CONFIG_VGA_EMULATE_TEXT) - return cbvga_get_dacformat(vmode_g); - return stdvga_get_dacformat(vmode_g); + return cbvga_get_dacformat(curmode_g); + return stdvga_get_dacformat(curmode_g); } =20 -static inline int vgahw_set_dacformat(struct vgamode_s *vmode_g, int val) { +static inline int vgahw_set_dacformat(struct vgamode_s *curmode_g, int val= ) { if (CONFIG_VGA_BOCHS) - return bochsvga_set_dacformat(vmode_g, val); + return bochsvga_set_dacformat(curmode_g, val); if (CONFIG_VGA_EMULATE_TEXT) - return cbvga_set_dacformat(vmode_g, val); - return stdvga_set_dacformat(vmode_g, val); + return cbvga_set_dacformat(curmode_g, val); + return stdvga_set_dacformat(curmode_g, val); } =20 static inline int vgahw_save_restore(int cmd, u16 seg, void *data) { diff --git a/vgasrc/vgautil.h b/vgasrc/vgautil.h index dd1aa18..245a562 100644 --- a/vgasrc/vgautil.h +++ b/vgasrc/vgautil.h @@ -7,14 +7,14 @@ // cbvga.c struct vgamode_s *cbvga_find_mode(int mode); void cbvga_list_modes(u16 seg, u16 *dest, u16 *last); -int cbvga_get_window(struct vgamode_s *vmode_g, int window); -int cbvga_set_window(struct vgamode_s *vmode_g, int window, int val); -int cbvga_get_linelength(struct vgamode_s *vmode_g); -int cbvga_set_linelength(struct vgamode_s *vmode_g, int val); -int cbvga_get_displaystart(struct vgamode_s *vmode_g); -int cbvga_set_displaystart(struct vgamode_s *vmode_g, int val); -int cbvga_get_dacformat(struct vgamode_s *vmode_g); -int cbvga_set_dacformat(struct vgamode_s *vmode_g, int val); +int cbvga_get_window(struct vgamode_s *curmode_g, int window); +int cbvga_set_window(struct vgamode_s *curmode_g, int window, int val); +int cbvga_get_linelength(struct vgamode_s *curmode_g); +int cbvga_set_linelength(struct vgamode_s *curmode_g, int val); +int cbvga_get_displaystart(struct vgamode_s *curmode_g); +int cbvga_set_displaystart(struct vgamode_s *curmode_g, int val); +int cbvga_get_dacformat(struct vgamode_s *curmode_g); +int cbvga_set_dacformat(struct vgamode_s *curmode_g, int val); int cbvga_save_restore(int cmd, u16 seg, void *data); int cbvga_set_mode(struct vgamode_s *vmode_g, int flags); int cbvga_get_linesize(struct vgamode_s *vmode_g); @@ -30,12 +30,12 @@ int ramfb_setup(void); // clext.c struct vgamode_s *clext_find_mode(int mode); void clext_list_modes(u16 seg, u16 *dest, u16 *last); -int clext_get_window(struct vgamode_s *vmode_g, int window); -int clext_set_window(struct vgamode_s *vmode_g, int window, int val); -int clext_get_linelength(struct vgamode_s *vmode_g); -int clext_set_linelength(struct vgamode_s *vmode_g, int val); -int clext_get_displaystart(struct vgamode_s *vmode_g); -int clext_set_displaystart(struct vgamode_s *vmode_g, int val); +int clext_get_window(struct vgamode_s *curmode_g, int window); +int clext_set_window(struct vgamode_s *curmode_g, int window, int val); +int clext_get_linelength(struct vgamode_s *curmode_g); +int clext_set_linelength(struct vgamode_s *curmode_g, int val); +int clext_get_displaystart(struct vgamode_s *curmode_g); +int clext_set_displaystart(struct vgamode_s *curmode_g, int val); int clext_save_restore(int cmd, u16 seg, void *data); int clext_set_mode(struct vgamode_s *vmode_g, int flags); struct bregs; --=20 2.44.0 _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org From nobody Wed May 15 15:03:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of seabios.org designates 78.46.105.101 as permitted sender) client-ip=78.46.105.101; envelope-from=seabios-bounces@seabios.org; helo=coreboot.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of seabios.org designates 78.46.105.101 as permitted sender) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=fail(p=none dis=none) header.from=koconnor.net Return-Path: Received: from coreboot.org (coreboot.org [78.46.105.101]) by mx.zohomail.com with SMTPS id 171054734057715.752847874978102; Fri, 15 Mar 2024 17:02:20 -0700 (PDT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTPA id A3B7439652; Sat, 16 Mar 2024 00:02:15 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTP id BEEBB21E31 for ; Sat, 16 Mar 2024 00:01:37 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) for ; Fri, 15 Mar 2024 17:01:37 -0700 (PDT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by smtp.gmail.com with ESMTPSA id i23-20020ac84f57000000b0042f1e47e652sm2409124qtw.79.2024.03.15.17.01.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Mar 2024 17:01:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=koconnor.net; s=google; t=1710547296; x=1711152096; darn=seabios.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=es4cuejV6k9cMNPXKrzFb+OcZiHmmJiiyZcb7i7nHQg=; b=D8+nz8vcZ/ApfHNcFdDPH7Iudo5dhkydWC1yAjxH4ikkcclTyDqtDKiaw78gyFCk2z sVMi2Xt4a80ym4kZX/NR4aT0Ic0Eze+/IGYS3PLNSQ9ONUxdu91kSbbfVqaBdTvgrH9a H1E19zxIgsW7bSl0IwqMFKOmNFzcC/cyoc7g0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710547296; x=1711152096; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=es4cuejV6k9cMNPXKrzFb+OcZiHmmJiiyZcb7i7nHQg=; b=tydPSoVrnQsBEdMmk9cKMVhh82lXKeAhlJ/2fZA4I6UYYshRyhckYfZUwo4ye4qVMm wCK4cHLtsYPiORHQP/5aIzDlM/WWWEi5V9zxc1aRWTxOZ3w9yI2OcCwjJfGG2p4PMxDH Y2uKRPeC7VMUDRRZQs0SYvLThg658NpsSCBiiVaL/bB0kE27iLOt0wAvt+574aKHhKJy kStotdfBYOnjvQRV5RNzBDGb1xJ/Y+q9oaY+jKebJjZWfYwuFGmPp2lswPvLbMw+bpBO dp3FJq6irdcJCjqvNak9tsrzW+0+ij91CLmEuQ/OR2SEGu2FgrFTc1RBmJVpey9Ln08n PsVQ== X-Gm-Message-State: AOJu0YwMrjrPvh9kAdIefwiA/JcHMO45/N1Fxc+jPb9btjhUi1EmUzCs zqdd3cYq1Tq0TyHO1eg9ln9t4pp8ZoJ5N6yjSFrIr3F1M9B4O+BvN6QLMGrvgJEJmnqAQUBBiSB V X-Google-Smtp-Source: AGHT+IEeAVepjZ44gm1Q9+p5doKpz3wVrzc9nfjL08Hzuo4p2nL0Mkc7YPqrcgxc9/VBtjQZavzNWQ== X-Received: by 2002:a05:6808:3099:b0:3c3:782a:9937 with SMTP id bl25-20020a056808309900b003c3782a9937mr3285843oib.24.1710547296449; Fri, 15 Mar 2024 17:01:36 -0700 (PDT) From: Kevin O'Connor To: seabios@seabios.org Date: Fri, 15 Mar 2024 19:57:48 -0400 Message-ID: <20240316000129.4099892-3-kevin@koconnor.net> In-Reply-To: <20240316000129.4099892-1-kevin@koconnor.net> References: <20240316000129.4099892-1-kevin@koconnor.net> MIME-Version: 1.0 X-Spam-Level: *** Message-ID-Hash: 6NCUK6LPXYIJVJHD2YITIDTOIHVA77F6 X-Message-ID-Hash: 6NCUK6LPXYIJVJHD2YITIDTOIHVA77F6 X-MailFrom: kevin@koconnor.net X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-seabios.seabios.org-0; header-match-seabios.seabios.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.6b1 Precedence: list Subject: [SeaBIOS] [PATCH 2/2] vgasrc: Rename vgahw_get_linesize() to vgahw_minimum_linelength() List-Id: SeaBIOS mailing list Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable Authentication-Results: coreboot.org; auth=pass smtp.auth=mailman@coreboot.org smtp.mailfrom=seabios-bounces@seabios.org X-Spamd-Bar: / X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1710547342302100001 Content-Type: text/plain; charset="utf-8" Make the relationship between vgahw_get_linelength() and vgahw_get_linesize() more clear by renaming it to vgahw_minimum_linelength(). Signed-off-by: Kevin O'Connor --- vgasrc/cbvga.c | 14 +++++++------- vgasrc/stdvga.c | 16 +++++++++++----- vgasrc/stdvga.h | 1 + vgasrc/vbe.c | 2 +- vgasrc/vgahw.h | 12 ++++++------ vgasrc/vgautil.h | 3 +-- 6 files changed, 27 insertions(+), 21 deletions(-) diff --git a/vgasrc/cbvga.c b/vgasrc/cbvga.c index 9e3cc93..243e6be 100644 --- a/vgasrc/cbvga.c +++ b/vgasrc/cbvga.c @@ -81,6 +81,13 @@ cbvga_set_window(struct vgamode_s *curmode_g, int window= , int val) return -1; } =20 +int +cbvga_minimum_linelength(struct vgamode_s *vmode_g) +{ + /* Can't change mode, always report active pitch. */ + return GET_GLOBAL(CBlinelength); +} + int cbvga_get_linelength(struct vgamode_s *curmode_g) { @@ -156,13 +163,6 @@ cbvga_set_mode(struct vgamode_s *vmode_g, int flags) return 0; } =20 -int -cbvga_get_linesize(struct vgamode_s *vmode_g) -{ - /* Can't change mode, always report active pitch. */ - return GET_GLOBAL(CBlinelength); -} - #define CB_TAG_FRAMEBUFFER 0x0012 struct cb_framebuffer { u32 tag; diff --git a/vgasrc/stdvga.c b/vgasrc/stdvga.c index 9d8f556..da67af4 100644 --- a/vgasrc/stdvga.c +++ b/vgasrc/stdvga.c @@ -275,6 +275,14 @@ stdvga_set_window(struct vgamode_s *curmode_g, int win= dow, int val) return -1; } =20 +// Minimum framebuffer bytes between each vertical line for given mode +int +stdvga_minimum_linelength(struct vgamode_s *vmode_g) +{ + return DIV_ROUND_UP(GET_GLOBAL(vmode_g->width) * vga_bpp(vmode_g), 8); +} + +// Return number of framebuffer bytes between start of each vertical line int stdvga_get_linelength(struct vgamode_s *curmode_g) { @@ -282,6 +290,7 @@ stdvga_get_linelength(struct vgamode_s *curmode_g) return val * 8 / stdvga_vram_ratio(curmode_g); } =20 +// Set number of framebuffer bytes between start of each vertical line int stdvga_set_linelength(struct vgamode_s *curmode_g, int val) { @@ -290,6 +299,7 @@ stdvga_set_linelength(struct vgamode_s *curmode_g, int = val) return 0; } =20 +// Return framebuffer offset of first byte of displayed content int stdvga_get_displaystart(struct vgamode_s *curmode_g) { @@ -299,6 +309,7 @@ stdvga_get_displaystart(struct vgamode_s *curmode_g) return addr * 4 / stdvga_vram_ratio(curmode_g); } =20 +// Set framebuffer offset of first byte of displayed content int stdvga_set_displaystart(struct vgamode_s *curmode_g, int val) { @@ -321,11 +332,6 @@ stdvga_set_dacformat(struct vgamode_s *curmode_g, int = val) return -1; } =20 -int -stdvga_get_linesize(struct vgamode_s *vmode_g) -{ - return DIV_ROUND_UP(GET_GLOBAL(vmode_g->width) * vga_bpp(vmode_g), 8); -} =20 /**************************************************************** * Save/Restore state diff --git a/vgasrc/stdvga.h b/vgasrc/stdvga.h index 5164ca1..ce79783 100644 --- a/vgasrc/stdvga.h +++ b/vgasrc/stdvga.h @@ -68,6 +68,7 @@ void stdvga_set_scan_lines(u8 lines); u16 stdvga_get_vde(void); int stdvga_get_window(struct vgamode_s *curmode_g, int window); int stdvga_set_window(struct vgamode_s *curmode_g, int window, int val); +int stdvga_minimum_linelength(struct vgamode_s *vmode_g); int stdvga_get_linelength(struct vgamode_s *curmode_g); int stdvga_set_linelength(struct vgamode_s *curmode_g, int val); int stdvga_get_displaystart(struct vgamode_s *curmode_g); diff --git a/vgasrc/vbe.c b/vgasrc/vbe.c index 3efb54f..d2aaace 100644 --- a/vgasrc/vbe.c +++ b/vgasrc/vbe.c @@ -110,7 +110,7 @@ vbe_104f01(struct bregs *regs) // Basic information about mode. int width =3D GET_GLOBAL(vmode_g->width); int height =3D GET_GLOBAL(vmode_g->height); - int linesize =3D vgahw_get_linesize(vmode_g); + int linesize =3D vgahw_minimum_linelength(vmode_g); SET_FARVAR(seg, info->bytes_per_scanline, linesize); SET_FARVAR(seg, info->xres, width); SET_FARVAR(seg, info->yres, height); diff --git a/vgasrc/vgahw.h b/vgasrc/vgahw.h index bd33e20..a6ddaa9 100644 --- a/vgasrc/vgahw.h +++ b/vgasrc/vgahw.h @@ -95,6 +95,12 @@ static inline int vgahw_get_linelength(struct vgamode_s = *curmode_g) { return stdvga_get_linelength(curmode_g); } =20 +static inline int vgahw_minimum_linelength(struct vgamode_s *vmode_g) { + if (CONFIG_VGA_EMULATE_TEXT) + return cbvga_minimum_linelength(vmode_g); + return stdvga_minimum_linelength(vmode_g); +} + static inline int vgahw_set_linelength(struct vgamode_s *curmode_g, int va= l) { if (CONFIG_VGA_CIRRUS) return clext_set_linelength(curmode_g, val); @@ -151,10 +157,4 @@ static inline int vgahw_save_restore(int cmd, u16 seg,= void *data) { return stdvga_save_restore(cmd, seg, data); } =20 -static inline int vgahw_get_linesize(struct vgamode_s *vmode_g) { - if (CONFIG_VGA_EMULATE_TEXT) - return cbvga_get_linesize(vmode_g); - return stdvga_get_linesize(vmode_g); -} - #endif // vgahw.h diff --git a/vgasrc/vgautil.h b/vgasrc/vgautil.h index 245a562..ce307c9 100644 --- a/vgasrc/vgautil.h +++ b/vgasrc/vgautil.h @@ -9,6 +9,7 @@ struct vgamode_s *cbvga_find_mode(int mode); void cbvga_list_modes(u16 seg, u16 *dest, u16 *last); int cbvga_get_window(struct vgamode_s *curmode_g, int window); int cbvga_set_window(struct vgamode_s *curmode_g, int window, int val); +int cbvga_minimum_linelength(struct vgamode_s *vmode_g); int cbvga_get_linelength(struct vgamode_s *curmode_g); int cbvga_set_linelength(struct vgamode_s *curmode_g, int val); int cbvga_get_displaystart(struct vgamode_s *curmode_g); @@ -17,7 +18,6 @@ int cbvga_get_dacformat(struct vgamode_s *curmode_g); int cbvga_set_dacformat(struct vgamode_s *curmode_g, int val); int cbvga_save_restore(int cmd, u16 seg, void *data); int cbvga_set_mode(struct vgamode_s *vmode_g, int flags); -int cbvga_get_linesize(struct vgamode_s *vmode_g); void cbvga_setup_modes(u64 addr, u8 bpp, u32 xlines, u32 ylines, u32 linel= ength); int cbvga_setup(void); =20 @@ -77,7 +77,6 @@ void stdvga_list_modes(u16 seg, u16 *dest, u16 *last); void stdvga_build_video_param(void); void stdvga_override_crtc(int mode, u8 *crtc); int stdvga_set_mode(struct vgamode_s *vmode_g, int flags); -int stdvga_get_linesize(struct vgamode_s *vmode_g); void stdvga_set_packed_palette(void); =20 // swcursor.c --=20 2.44.0 _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org