Exemplo n.º 1
0
/* Returns 0 if successful
*/
static int hook_debug_interrupts( void )
{
    int         i;
    PACKAGE FarPtr package = NULL;

    if( my_package_bind( DOS4G_KERNEL_PACKAGE_NAME, DOS4G_DEBUG_HOOK_ENTRY, &package, (ACTION **)&debug_hook ) )
        return( 1 );

    if( my_package_bind( DOS4G_KERNEL_PACKAGE_NAME, DOS4G_INTCHAIN_ENTRY, &package, (ACTION **)&chain_interrupt ) )
        return( 2 );

    /* OK to not find this entry point
    */
    my_package_bind( DOS4G_KERNEL_PACKAGE_NAME, DOS4G_NULLP_ENTRY, &package, (ACTION **)&D32NullPtrCheck );

    if( D32NullPtrCheck != NULL_PTR )           /* Disable NULLP checking for now */
        nullp_checks = D32NullPtrCheck( 0 );

    for( i = 0; i < sizeof( hook_exceptions ) / sizeof( hook_exceptions[0] ); i++ )
        debug_hook( hook_exceptions[i], 1, debug_handler );
    for( i = 0; i < sizeof( hook_interrupts ) / sizeof( hook_interrupts[0] ); i++ )
        debug_hook( hook_interrupts[i], 0, debug_handler );

    /*  Hook the hot key interrupt in protected mode and make it pass up.
    */
    if( _d16info.miscellaneous & D16misc_AT_compat ) {
        debug_hook( hotkey_int, 1, debug_handler );
        debug_hook( hotkey_int, 0, debug_handler );
        rsi_int_passup( hotkey_int );
    }

#ifdef TIMER
    if( timer_mult != 0 ) {
        debug_hook( INT_TIMER, 0, debug_handler );          /* Hook as interrupt only */
        outp( TIMER0, ( 65536 / timer_mult ) & 0xff );
        outp( TIMER0, ( 65536 / timer_mult ) >> 8 );
    }
Exemplo n.º 2
0
/**
 * @brief	Retrieve the data associated with a managed string.
 * @param	s	the input managed string.
 * @return	NULL on failure or for an improperly constructed string; otherwise, a pointer to the string's data.
 */
void *st_data_get(stringer_t *s) {

	uint32_t opts;
	void *result = NULL;

	if (!s || !(opts = s->opts)) {
		return NULL;
	}

#ifdef MAGMA_PEDANTIC
	else if (!st_valid_opts(opts)) {
		debug_hook();
		log_pedantic("Invalid string options. { opt = %u = %s }", opts, st_info_opts(opts, MEMORYBUF(128), 128));
		return NULL;
	}
#endif

	switch (opts & (CONSTANT_T | NULLER_T | BLOCK_T | PLACER_T | MANAGED_T | MAPPED_T)) {

	case (CONSTANT_T):
		result = ((constant_t *)s)->data;
		break;
	case (NULLER_T):
		result = ((nuller_t *)s)->data;
		break;
	case (BLOCK_T):
		result = ((block_t *)s)->data;
		break;
	case (PLACER_T):
		result = ((placer_t *)s)->data;
		break;
	case (MANAGED_T):
		result = ((managed_t *)s)->data;
		break;
	case (MAPPED_T):
		result = ((mapped_t *)s)->data;
		break;
	}

	return result;
}
Exemplo n.º 3
0
EFI_STATUS
efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *systab)
{
	EFI_STATUS rc;

	InitializeLib(image, systab);

	/*
	 * if SHIM_DEBUG is set, wait for a debugger to attach.
	 */
	debug_hook();

	rc = uefi_call_wrapper(BS->HandleProtocol, 3, image, &LoadedImageProtocol, (void *)&this_image);
	if (EFI_ERROR(rc)) {
		Print(L"Error: could not find loaded image: %d\n", rc);
		return rc;
	}

	Print(L"System BootOrder not found.  Initializing defaults.\n");

	set_boot_order();

	rc = find_boot_options(this_image->DeviceHandle);
	if (EFI_ERROR(rc)) {
		Print(L"Error: could not find boot options: %d\n", rc);
		return rc;
	}

	try_start_first_option(image);

	Print(L"Reset System\n");
	uefi_call_wrapper(RT->ResetSystem, 4, EfiResetCold,
			  EFI_SUCCESS, 0, NULL);

	return EFI_SUCCESS;
}
Exemplo n.º 4
0
EFI_STATUS
efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *systab)
{
	EFI_STATUS rc;
	update_table **updates = NULL;
	UINTN n_updates = 0;
	EFI_RESET_TYPE reset_type = EfiResetWarm;

	InitializeLib(image, systab);

	/*
	 * if SHIM_DEBUG is set, print info for our attached debugger.
	 */
	debug_hook();

	/*
	 * Basically the workflow here is:
	 * 1) find and validate any update state variables with the right GUID
	 * 2) allocate our capsule data structures and add the capsules
	 *    #1 described
	 * 3) update status variables
	 * 4) apply the capsule updates
	 * 5) reboot
	 */

	/*
	 * Step 1: find and validate update state variables
	 */
	/* XXX TODO:
	 * 1) survey the reset types first, and separate into groups
	 *    according to them
	 * 2) if there's more than one, mirror BootCurrent back into BootNext
	 *    so we can do multiple runs
	 * 3) only select the ones from one type for the first go
	 */
	rc = find_updates(&n_updates, &updates);
	if (EFI_ERROR(rc)) {
		Print(L"fwupdate: Could not find updates: %r\n", rc);
		return rc;
	}
	if (n_updates == 0) {
		Print(L"fwupdate: No updates to process.  Called in error?\n");
		return EFI_INVALID_PARAMETER;
	}

	/*
	 * Step 2: Build our data structure and add the capsules to it.
	 */
	EFI_CAPSULE_HEADER *capsules[n_updates + 1];
	EFI_CAPSULE_BLOCK_DESCRIPTOR *cbd_data;
	UINTN i;
	rc = allocate((void **)&cbd_data,
		      sizeof (EFI_CAPSULE_BLOCK_DESCRIPTOR)*(n_updates+1));
	if (EFI_ERROR(rc)) {
		Print(L"%a:%a():%d: Tried to allocate %d\n",
		      __FILE__, __func__, __LINE__,
		      sizeof (EFI_CAPSULE_BLOCK_DESCRIPTOR)*(n_updates+1));
		Print(L"fwupdate: Could not allocate memory: %r.\n",rc);
		return rc;
	}
	for (i = 0; i < n_updates; i++) {
		rc = add_capsule(updates[i], &capsules[i], &cbd_data[i]);
		if (EFI_ERROR(rc)) {
			Print(L"fwupdate: Could not build update list: %r\n",
			      rc);
			return rc;
		}
	}

	cbd_data[i].Length = 0;
	cbd_data[i].Union.ContinuationPointer = 0;

	/*
	 * Step 3: update the state variables.
	 */
	rc = set_statuses(n_updates, updates);
	if (EFI_ERROR(rc)) {
		Print(L"fwupdate: Could not set update status: %r\n", rc);
		return rc;
	}

	/*
	 * Step 4: apply the capsules.
	 */
	rc = apply_capsules(capsules, cbd_data, n_updates, &reset_type);
	if (EFI_ERROR(rc)) {
		Print(L"fwupdate: Could not apply capsules: %r\n", rc);
		return rc;
	}

	/*
	 * Step 5: if #4 didn't reboot us, do it manually.
	 */
	if (debugging) {
		Print(L"Reset System\n");
		uefi_call_wrapper(BS->Stall, 1, 10000000);
	}
	uefi_call_wrapper(RT->ResetSystem, 4, reset_type, EFI_SUCCESS,
			  0, NULL);

	return EFI_SUCCESS;
}