<commit_before>#include <minix/syslib.h>
#include <minix/drivers.h>
#include <machine/int86.h>
#include <sys/mman.h>
#include <sys/types.h>

#include "vbe.h"

/* Constants for VBE 0x105 mode */

#define VRAM_PHYS_ADDR    0xD0000000
#define H_RES             1024
#define V_RES		  768
#define BITS_PER_PIXEL	  8

/* Private global variables */

static char *video_mem;		/* Process address to which VRAM is mapped */

static unsigned h_res;		/* Horizontal screen resolution in pixels */
static unsigned v_res;		/* Vertical screen resolution in pixels */
static unsigned bits_per_pixel; /* Number of VRAM bits per pixel */

void * vg_init(unsigned long mode) {
	int r, s;
	struct mem_range mr;
	vbe_mode_info_t vmi_p;
	struct reg86u reg;

	reg.u.b.intno = 0x10;
	reg.u.b.ah = 0x4F;
	reg.u.b.al = 0x02;
	reg.u.w.bx = 0x1 << 14 | mode;

	s = sys_int86(&reg);

	if (vbe_get_mode_info(mode, &vmi_p) != 0) {
		return NULL;
	}

	h_res = vmi_p.XResolution;
	v_res = vmi_p.YResolution;
	bits_per_pixel = vmi_p.BitsPerPixel;

	mr.mr_base = vmi_p.PhysBasePtr;
	mr.mr_limit = mr.mr_base + h_res * v_res * (bits_per_pixel / 8);
	r = sys_privctl(SELF, SYS_PRIV_ADD_MEM, &mr);

	video_mem = vm_map_phys(SELF, (void *) mr.mr_base, h_res * v_res * (bits_per_pixel / 8));



	return (video_mem == MAP_FAILED ? NULL : video_mem);<commit_msg>Replace magic const 14 by LINEAR_MODEL_BIT and define BIT macro<commit_after>#include <minix/syslib.h>
#include <minix/drivers.h>
#include <machine/int86.h>
#include <sys/mman.h>
#include <sys/types.h>

#include "vbe.h"

/* Constants for VBE 0x105 mode */

#define VRAM_PHYS_ADDR    0xD0000000
#define H_RES             1024
#define V_RES		  768
#define BITS_PER_PIXEL	  8

#define LINEAR_MODEL_BIT 14
#define BIT(n) (0x1 << (n))

/* Private global variables */

static char *video_mem;		/* Process address to which VRAM is mapped */

static unsigned h_res;		/* Horizontal screen resolution in pixels */
static unsigned v_res;		/* Vertical screen resolution in pixels */
static unsigned bits_per_pixel; /* Number of VRAM bits per pixel */

void * vg_init(unsigned long mode) {
	int r, s;
	struct mem_range mr;
	vbe_mode_info_t vmi_p;
	struct reg86u reg;

	reg.u.b.intno = 0x10;
	reg.u.b.ah = 0x4F;
	reg.u.b.al = 0x02;
	reg.u.w.bx = BIT(LINEAR_MODEL_BIT) | mode;

	s = sys_int86(&reg);

	if (vbe_get_mode_info(mode, &vmi_p) != 0) {
		return NULL;
	}

	h_res = vmi_p.XResolution;
	v_res = vmi_p.YResolution;
	bits_per_pixel = vmi_p.BitsPerPixel;

	mr.mr_base = vmi_p.PhysBasePtr;
	mr.mr_limit = mr.mr_base + h_res * v_res * (bits_per_pixel / 8);
	r = sys_privctl(SELF, SYS_PRIV_ADD_MEM, &mr);

	video_mem = vm_map_phys(SELF, (void *) mr.mr_base, h_res * v_res * (bits_per_pixel / 8));



	return (video_mem == MAP_FAILED ? NULL : video_mem);
{'fraction_non_alphanumeric': 0.12323305545487495, 'fraction_numerical': 0.030445813700616164, 'mean_word_length': 3.8336252189141855, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6162656', 'n_tokens_mistral': 1245, 'n_tokens_neox': 1149, 'n_words': 276}