blob: f82b072332f07792a90f5d7b4bd5f058e2990f0a [file] [log] [blame]
/*
* Copyright (C) 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "common/vsoc/lib/vsoc_memory.h"
#include <string>
#include <type_traits>
#include "common/vsoc/shm/audio_data_layout.h"
#include "common/vsoc/shm/base.h"
#include "common/vsoc/shm/e2e_test_region_layout.h"
#include "common/vsoc/shm/gralloc_layout.h"
#include "common/vsoc/shm/input_events_layout.h"
#include "common/vsoc/shm/ril_layout.h"
#include "common/vsoc/shm/screen_layout.h"
#include "common/vsoc/shm/socket_forward_layout.h"
#include "common/vsoc/shm/wifi_exchange_layout.h"
namespace vsoc {
namespace {
template <class R>
RegionMemoryLayout ValidateAndBuildLayout(int region_size,
int g_to_h_signal_table_log_size,
int h_to_g_signal_table_log_size,
const char* managed_by = nullptr) {
// Double check that the Layout is a valid shm type.
ASSERT_SHM_COMPATIBLE(R);
return RegionMemoryLayout(R::region_name, region_size,
g_to_h_signal_table_log_size,
h_to_g_signal_table_log_size, managed_by);
}
} // namespace
const std::vector<RegionMemoryLayout>& GetVsocMemoryLayout() {
static const std::vector<RegionMemoryLayout> layout = {
ValidateAndBuildLayout<layout::input_events::InputEventsLayout>(
/*size*/ 4096, /*g->h*/ 2, /*h->g*/ 2),
ValidateAndBuildLayout<layout::screen::ScreenLayout>(
/*size*/ 12292096, /*g->h*/ 2, /*h->g*/ 2),
ValidateAndBuildLayout<layout::gralloc::GrallocManagerLayout>(
/*size*/ 40960, /*g->h*/ 2, /*h->g*/ 2),
ValidateAndBuildLayout<layout::gralloc::GrallocBufferLayout>(
/*size*/ 407142400, /*g->h*/ 0, /*h->g*/ 0,
/* managed_by */ layout::gralloc::GrallocManagerLayout::region_name),
ValidateAndBuildLayout<layout::socket_forward::SocketForwardLayout>(
/*size*/ 2105344, /*g->h*/ 7, /*h->g*/ 7),
ValidateAndBuildLayout<layout::wifi::WifiExchangeLayout>(
/*size*/ 139264, /*g->h*/ 2, /*h->g*/ 2),
ValidateAndBuildLayout<layout::ril::RilLayout>(
/*size*/ 4096, /*g->h*/ 2, /*h->g*/ 2),
ValidateAndBuildLayout<layout::e2e_test::E2EPrimaryTestRegionLayout>(
/*size*/ 16384, /*g->h*/ 1, /*h->g*/ 1),
ValidateAndBuildLayout<layout::e2e_test::E2ESecondaryTestRegionLayout>(
/*size*/ 16384, /*g->h*/ 1, /*h->g*/ 1),
ValidateAndBuildLayout<layout::e2e_test::E2EManagerTestRegionLayout>(
/*size*/ 4096, /*g->h*/ 1, /*h->g*/ 1),
ValidateAndBuildLayout<layout::e2e_test::E2EManagedTestRegionLayout>(
/*size*/ 16384, /*g->h*/ 1, /*h->g*/ 1),
ValidateAndBuildLayout<layout::audio_data::AudioDataLayout>(
/*size*/ 20480, /*g->h*/ 2, /*h->g*/ 2)};
return layout;
}
} // namespace vsoc