mirror of
https://github.com/genodelabs/genode.git
synced 2025-01-03 04:26:45 +00:00
drivers: use DMA buffer more consistent
Replace 'alloc_dma_buffer' by 'Dma_buffer' issue #4667
This commit is contained in:
parent
ff6b2bffdc
commit
f76f5db2fa
@ -17,6 +17,7 @@
|
|||||||
#include <base/component.h>
|
#include <base/component.h>
|
||||||
#include <base/log.h>
|
#include <base/log.h>
|
||||||
#include <platform_session/device.h>
|
#include <platform_session/device.h>
|
||||||
|
#include <platform_session/dma_buffer.h>
|
||||||
#include <timer_session/connection.h>
|
#include <timer_session/connection.h>
|
||||||
#include <capture_session/connection.h>
|
#include <capture_session/connection.h>
|
||||||
#include <blit/painter.h>
|
#include <blit/painter.h>
|
||||||
@ -73,7 +74,7 @@ struct Pl11x_driver::Main
|
|||||||
{
|
{
|
||||||
using Pixel = Capture::Pixel;
|
using Pixel = Capture::Pixel;
|
||||||
|
|
||||||
Surface<Pixel> surface(_fb_ds.local_addr<Pixel>(), _size);
|
Surface<Pixel> surface(_fb_dma.local_addr<Pixel>(), _size);
|
||||||
|
|
||||||
_captured_screen.apply_to_surface(surface);
|
_captured_screen.apply_to_surface(surface);
|
||||||
}
|
}
|
||||||
@ -90,11 +91,7 @@ struct Pl11x_driver::Main
|
|||||||
Platform::Device _sp810_dev { _platform, Type { "arm,sp810" } };
|
Platform::Device _sp810_dev { _platform, Type { "arm,sp810" } };
|
||||||
Platform::Device::Mmio _lcd_io_mem { _pl11x_dev };
|
Platform::Device::Mmio _lcd_io_mem { _pl11x_dev };
|
||||||
Platform::Device::Mmio _sys_mem { _sp810_dev };
|
Platform::Device::Mmio _sys_mem { _sp810_dev };
|
||||||
|
Platform::Dma_buffer _fb_dma { _platform, FRAMEBUFFER_SIZE, UNCACHED };
|
||||||
Ram_dataspace_capability _fb_ds_cap {
|
|
||||||
_platform.alloc_dma_buffer(FRAMEBUFFER_SIZE, UNCACHED) };
|
|
||||||
|
|
||||||
Attached_dataspace _fb_ds { _env.rm(), _fb_ds_cap };
|
|
||||||
|
|
||||||
void _init_device();
|
void _init_device();
|
||||||
|
|
||||||
@ -197,8 +194,7 @@ void Pl11x_driver::Main::_init_device()
|
|||||||
reg_write(PL11X_REG_TIMING3, tim3);
|
reg_write(PL11X_REG_TIMING3, tim3);
|
||||||
|
|
||||||
/* set framebuffer address and ctrl register */
|
/* set framebuffer address and ctrl register */
|
||||||
addr_t const fb_dma_base = (addr_t)_platform.dma_addr(_fb_ds_cap);
|
reg_write(PL11X_REG_UPBASE, _fb_dma.dma_addr());
|
||||||
reg_write(PL11X_REG_UPBASE, fb_dma_base);
|
|
||||||
reg_write(PL11X_REG_LPBASE, 0);
|
reg_write(PL11X_REG_LPBASE, 0);
|
||||||
reg_write(PL11X_REG_IMSC, 0);
|
reg_write(PL11X_REG_IMSC, 0);
|
||||||
reg_write(PL11X_REG_CTRL, ctrl);
|
reg_write(PL11X_REG_CTRL, ctrl);
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#include <base/log.h>
|
#include <base/log.h>
|
||||||
#include <capture_session/connection.h>
|
#include <capture_session/connection.h>
|
||||||
#include <platform_session/device.h>
|
#include <platform_session/device.h>
|
||||||
|
#include <platform_session/dma_buffer.h>
|
||||||
#include <timer_session/connection.h>
|
#include <timer_session/connection.h>
|
||||||
#include <util/endian.h>
|
#include <util/endian.h>
|
||||||
#include <util/mmio.h>
|
#include <util/mmio.h>
|
||||||
@ -61,13 +62,8 @@ class Main
|
|||||||
Platform::Device::Mmio _fw_mem { _fw_dev };
|
Platform::Device::Mmio _fw_mem { _fw_dev };
|
||||||
Fw _fw { (addr_t)_fw_mem.local_addr<addr_t>() };
|
Fw _fw { (addr_t)_fw_mem.local_addr<addr_t>() };
|
||||||
|
|
||||||
Ram_dataspace_capability _fb_ds_cap {
|
Platform::Dma_buffer _fb_dma { _platform, SCR_HEIGHT * SCR_STRIDE, UNCACHED };
|
||||||
_platform.alloc_dma_buffer(SCR_HEIGHT * SCR_STRIDE, UNCACHED) };
|
Platform::Dma_buffer _config_dma { _platform, 0x1000, UNCACHED };
|
||||||
Attached_dataspace _fb_ds { _env.rm(), _fb_ds_cap };
|
|
||||||
|
|
||||||
Ram_dataspace_capability _config_ds_cap {
|
|
||||||
_platform.alloc_dma_buffer(0x1000, UNCACHED) };
|
|
||||||
Attached_dataspace _config_ds { _env.rm(), _config_ds_cap };
|
|
||||||
|
|
||||||
Capture::Area const _size { SCR_WIDTH, SCR_HEIGHT };
|
Capture::Area const _size { SCR_WIDTH, SCR_HEIGHT };
|
||||||
Capture::Connection _capture { _env };
|
Capture::Connection _capture { _env };
|
||||||
@ -81,7 +77,7 @@ class Main
|
|||||||
{
|
{
|
||||||
using Pixel = Capture::Pixel;
|
using Pixel = Capture::Pixel;
|
||||||
|
|
||||||
Surface<Pixel> surface(_fb_ds.local_addr<Pixel>(), _size);
|
Surface<Pixel> surface(_fb_dma.local_addr<Pixel>(), _size);
|
||||||
|
|
||||||
_captured_screen.apply_to_surface(surface);
|
_captured_screen.apply_to_surface(surface);
|
||||||
}
|
}
|
||||||
@ -173,9 +169,9 @@ class Main
|
|||||||
|
|
||||||
_fw_selector(file.key);
|
_fw_selector(file.key);
|
||||||
|
|
||||||
addr_t config_addr = (addr_t)_config_ds.local_addr<addr_t>();
|
addr_t config_addr = (addr_t)_config_dma.local_addr<addr_t>();
|
||||||
addr_t config_phys = (addr_t)_platform.dma_addr(_config_ds_cap);
|
addr_t config_phys = _config_dma.dma_addr();
|
||||||
addr_t fb_phys = (addr_t)_platform.dma_addr(_fb_ds_cap);
|
addr_t fb_phys = _fb_dma.dma_addr();
|
||||||
|
|
||||||
Ram_fb_config config { config_addr };
|
Ram_fb_config config { config_addr };
|
||||||
config.write<Ram_fb_config::Address>(host_to_big_endian(fb_phys));
|
config.write<Ram_fb_config::Address>(host_to_big_endian(fb_phys));
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
#include <base/component.h>
|
#include <base/component.h>
|
||||||
#include <base/log.h>
|
#include <base/log.h>
|
||||||
#include <os/reporter.h>
|
#include <os/reporter.h>
|
||||||
|
|
||||||
/* WARNING DO NOT COPY THIS !!! */
|
/* WARNING DO NOT COPY THIS !!! */
|
||||||
/*
|
/*
|
||||||
* We make everything public from the platform device classes
|
* We make everything public from the platform device classes
|
||||||
@ -25,6 +24,8 @@
|
|||||||
#undef private
|
#undef private
|
||||||
/* WARNING DO NOT COPY THIS !!! */
|
/* WARNING DO NOT COPY THIS !!! */
|
||||||
|
|
||||||
|
#include <platform_session/dma_buffer.h>
|
||||||
|
|
||||||
using namespace Genode;
|
using namespace Genode;
|
||||||
|
|
||||||
struct Main
|
struct Main
|
||||||
@ -158,7 +159,7 @@ struct Main
|
|||||||
case 3:
|
case 3:
|
||||||
next_step(4, 4, 0x40000000, 32);
|
next_step(4, 4, 0x40000000, 32);
|
||||||
return;
|
return;
|
||||||
case 4:
|
case 4: {
|
||||||
/* Instantiate and destroy all devices */
|
/* Instantiate and destroy all devices */
|
||||||
start_driver(0);
|
start_driver(0);
|
||||||
start_driver(1);
|
start_driver(1);
|
||||||
@ -169,7 +170,7 @@ struct Main
|
|||||||
stop_driver(2);
|
stop_driver(2);
|
||||||
stop_driver(3);
|
stop_driver(3);
|
||||||
/* allocate big DMA dataspace */
|
/* allocate big DMA dataspace */
|
||||||
platform->alloc_dma_buffer(0x80000, UNCACHED);
|
Platform::Dma_buffer buffer { *platform, 0x80000, UNCACHED };
|
||||||
/* close the whole session */
|
/* close the whole session */
|
||||||
platform.destruct();
|
platform.destruct();
|
||||||
platform.construct(env);
|
platform.construct(env);
|
||||||
@ -180,10 +181,10 @@ struct Main
|
|||||||
start_driver(3);
|
start_driver(3);
|
||||||
/* repeatedly start and destroy device sessions to detect leakages */
|
/* repeatedly start and destroy device sessions to detect leakages */
|
||||||
for (unsigned idx = 0; idx < 1000; idx++) {
|
for (unsigned idx = 0; idx < 1000; idx++) {
|
||||||
platform->free_dma_buffer(platform->alloc_dma_buffer(0x4000, UNCACHED));
|
Platform::Dma_buffer dma { *platform, 0x4000, UNCACHED };
|
||||||
}
|
}
|
||||||
next_step(0, 0, 0x40000000, 32);
|
next_step(0, 0, 0x40000000, 32);
|
||||||
return;
|
return; }
|
||||||
case 5:
|
case 5:
|
||||||
stop_driver(0);
|
stop_driver(0);
|
||||||
stop_driver(1);
|
stop_driver(1);
|
||||||
|
Loading…
Reference in New Issue
Block a user