Hi ashy5000,
Thank you for answering.
I have a xv6 64 bit kernel which things a bit different I think and testing this on a Mac M4 (silicon) with qemu.
I have changed the addressed to:
#define BGA_FB_PADDR 0xFD000000
#define BGA_FB_VADDR 0xFFFFFFFF90000000 // Or any unused virtual address (must be 4KB aligned)
//#define BGA_FB_SIZE 0x4000000
#define BGA_FB_SIZE 1024 * 768
void
map_bga (pde_t *pgdir)
{
// Map the frame buffer physical address to a virtual address
// PTE_W = writeable, PTE_U = user mode accessible (if rendering in user space)
//if (mappages (pgdir, (void *) BGA_FB_VADDR, BGA_FB_SIZE,
if (mappages (pgdir, (void *) BGA_FB_VADDR, BGA_FB_SIZE,
BGA_FB_PADDR, PTE_W | PTE_P) != 0) {
panic("BGA frame buffer mapping failed");
}
}
And it is not crashing anymore but I not seeing a pixel at the screen.
My test is in kernel mode like this in main.c at the main function. I did it also in user mode and have the same problem.
pci_init ();
map_io ();
cprintf ("Status %d\n", BgaIsAvailable ());
// Switch to graphics mode.
BgaSetVideoMode (1024, 768, 8, 1, 1);
unsigned char * lfb = (unsigned char *) (0xFFFFFFFF90000000);
for (int i=100; i<2000; i++)
*(lfb+i) = 40;
I pci enable bga and I get the next message:
cpu0: starting xv6
0 0 0 0
PCI: 0:0.0: 8086

class: 6.0 (Bridge device) irq: 0
0 0 0 0
PCI: 0:1.0: 8086:7000: class: 6.1 (Bridge device) irq: 0
0 0 0 0
PCI: 0:1.1: 8086:7010: class: 1.1 (Mass storage controller) irq: 0
0 0 0 0
PCI: 0:1.3: 8086:7113: class: 6.80 (Bridge device) irq: 9
fd 0 0 8
PCI: 0:2.0: 1234

class: 3.0 (Display controller) irq: 0
Enable BGA
pcicmd reg:0x7
mem region 0: 16777216 bytes at 0xfd000000
mem region 2: 4096 bytes at 0xfebf0000
maybe it has to do with qemu in combination with pci (something with 64 bit or so)?
In a way when I write bytes to 0x90000000 or 0xFFFFFFFF90000000 (virtual address) it does not work.
When I write bytes in banked mode it is working and getting nice results but I want to have a frame buffer because it is way faster.
Could it be a problem in qemu on macOS ?
Thank you in advance,
Kind regards,
Robert