diff options
| author | Loic Guegan <manzerbredes@mailbox.org> | 2021-04-29 15:01:54 +0200 |
|---|---|---|
| committer | Loic Guegan <manzerbredes@mailbox.org> | 2021-04-29 15:01:54 +0200 |
| commit | f37f5d86b74870e878f69bd41a3c70a59c4ce1c1 (patch) | |
| tree | 65620f0504fea111ba870457f32bc072dc27fe7a /src/drivers/framebuffer.cc | |
| parent | fde8a1ab65d5e33d90123a3aaa9b5c15e249689f (diff) | |
Debug memory
Diffstat (limited to 'src/drivers/framebuffer.cc')
| -rw-r--r-- | src/drivers/framebuffer.cc | 38 |
1 files changed, 33 insertions, 5 deletions
diff --git a/src/drivers/framebuffer.cc b/src/drivers/framebuffer.cc index 9f90d84..f5b537b 100644 --- a/src/drivers/framebuffer.cc +++ b/src/drivers/framebuffer.cc @@ -7,10 +7,25 @@ FB_CFG fb_cfg; void framebuffer_init(FB_CFG config){ fb_cfg=config; - PAGING_MAP_RANGE(fb_cfg.location, fb_cfg.pitch*fb_cfg.height); + // Map buffer to the end of the memory + // indeed fb_cfg.location could be to big and + // thus leading to cross u64 size limit while summing it with + // kvar_kernel_vma in paging.cc/hpp + u64 start=0xFFFFFFFFFFFFFFFF - fb_cfg.pitch*fb_cfg.height; + // Ensure we start writing at the begining of the page since + // start is not necessarly 4096 bytes aligned + start=PAGE(start); + PAGE_RMAP_PHY(start-kvar_kernel_vma,fb_cfg.location, fb_cfg.pitch*fb_cfg.height); + fb_cfg.location=start; } void framebuffer_draw(FB_PIXEL p){ + // Check overflow + p.x=p.x>(fb_cfg.width)?fb_cfg.width:p.x; + p.y=p.y>(fb_cfg.width)?fb_cfg.width:p.y; + p.x=p.x<0?0:p.x; + p.y=p.y<0?0:p.y; + u8 *pixel=(u8*)(fb_cfg.location+p.x*(fb_cfg.depth/8)+p.y*fb_cfg.pitch); pixel[0]=p.r; pixel[1]=p.g; @@ -20,11 +35,24 @@ void framebuffer_draw(FB_PIXEL p){ } void framebuffer_scrollup(u32 npixel){ - u64 start=fb_cfg.location+npixel*fb_cfg.pitch; - u64 amount=fb_cfg.pitch*(fb_cfg.height-npixel); - memcpy((void*)start,(void*)fb_cfg.location,amount); // TODO change because page fault can occurs + for(u32 y=0;y<fb_cfg.height;y++){ + if(npixel<fb_cfg.height){ + for(u32 x=0;x<fb_cfg.width;x++){ + u32 *pixel_dst=(u32*)(fb_cfg.location+x*(fb_cfg.depth/8)+y*fb_cfg.pitch); + u32 *pixel_src=(u32*)(fb_cfg.location+x*(fb_cfg.depth/8)+npixel*fb_cfg.pitch); + *pixel_dst=*pixel_src; // Faster than writing pixel by pixel + } + } + else{ + for(u32 x=0;x<fb_cfg.width;x++){ + u8 *pixel_dst=(u8*)(fb_cfg.location+x*(fb_cfg.depth/8)+y*fb_cfg.pitch); + *pixel_dst=0;// Faster than writing pixel by pixel + } + } + npixel++; + } } void framebuffer_clear(){ - memset((void*)fb_cfg.location, 0, fb_cfg.pitch*fb_cfg.height); + // memset((void*)fb_cfg.location, 0, fb_cfg.pitch*fb_cfg.height-1000); }
\ No newline at end of file |
