Esempio n. 1
0
static void
vc_mem_get_size(void)
{
#ifdef CONFIG_ARCH_BCM2708
	mm_vc_mem_size = 256 * 1024 * 1024;	// Static for now
#else
	CHAL_IPC_HANDLE ipc_handle;
	uint32_t wakeup_register;

	// Get the videocore memory size from the IPC mailbox if not yet
	// assigned.
	if (mm_vc_mem_size == 0) {
		ipc_handle = chal_ipc_config(NULL);
		if (ipc_handle == NULL) {
			LOG_ERR("%s: failed to get IPC handlle", __func__);
			return;
		}

		chal_ipc_query_wakeup_vc(ipc_handle, &wakeup_register);
		if ((wakeup_register & ~1) == 0) {
			LOG_DBG("%s: videocore not yet loaded, skipping...",
				__func__);
		} else {
			if (chal_ipc_read_mailbox(ipc_handle,
						  IPC_MAILBOX_ID_0,
						  &mm_vc_mem_size) !=
			    BCM_SUCCESS) {
				LOG_ERR("%s: failed to read from IPC mailbox",
					__func__);
			}
		}
	}
#endif
}
Esempio n. 2
0
static void vc_mem_get_size(void)
{
	CHAL_IPC_HANDLE ipc_handle;
	uint32_t wakeup_register;

	mm_vc_mem_base &= 0x3fffffff;
	mm_vc_mem_load &= 0x3fffffff;

	/* Get the videocore memory size from the IPC mailbox if not yet
	 * assigned.
	 */
	if (mm_vc_mem_size == 0) {
		ipc_handle = chal_ipc_config(NULL);
		if (ipc_handle == NULL) {
			LOG_ERR("%s: failed to get IPC handlle", __func__);
			return;
		}

		chal_ipc_query_wakeup_vc(ipc_handle, &wakeup_register);
		if ((wakeup_register & ~1) == 0) {
			LOG_DBG("%s: videocore not yet loaded, skipping...",
				__func__);
		} else {
			struct {
				VC_DEBUG_HEADER_T header;
				VC_DEBUG_PARAMS_T params;

			} vc_dbg;

			/*
			 * When we switch to using an Open Kernel
			 * (versus a Secure Kernel) we get the videocore memory
			 * size by reading the debug header.
			 *
			 * The debug Header & params are described using
			 * the VC_DEBUG_HEADER_T and VC_DEBUG_PARAMS_T
			 * structures.
			 * The VC_DEBUG_HEADER_T can be found in the firmware
			 * at an offset of VC_DEBUG_HEADER_OFFSET.
			 */

			if (vc_mem_access_mem
			    (0, &vc_dbg,
			     mm_vc_mem_load + VC_DEBUG_HEADER_OFFSET,
			     sizeof(vc_dbg)) == 0) {
				if ((vc_dbg.header.magic ==
				     VC_DEBUG_HEADER_MAGIC)
				    && (vc_dbg.header.paramSize >=
					sizeof(vc_dbg.params))) {
					/*
					 * Looks like a valid debug header.
					 * Grab the size.
					 */
					mm_vc_mem_size =
					    vc_dbg.params.vcMemSize;
				}
			}

			if (mm_vc_mem_size == 0) {
				if (chal_ipc_read_mailbox(ipc_handle,
							  IPC_MAILBOX_ID_0,
							  &mm_vc_mem_size) !=
				    BCM_SUCCESS) {
					LOG_ERR
					    ("%s: failed to read from IPC mailbox",
					     __func__);
				}
			}
		}
	}
}