Пример #1
0
static int prepare(void)
{
	int error;

	pm_prepare_console();

	sys_sync();
	if (freeze_processes()) {
		error = -EBUSY;
		goto Thaw;
	}

	if (pm_disk_mode == PM_DISK_PLATFORM) {
		if (pm_ops && pm_ops->prepare) {
			if ((error = pm_ops->prepare(PM_SUSPEND_DISK)))
				goto Thaw;
		}
	}

	/* Free memory before shutting down devices. */
	free_some_memory();

	if ((error = device_suspend(PM_SUSPEND_DISK)))
		goto Finish;

	return 0;
 Finish:
	platform_finish();
 Thaw:
	thaw_processes();
	pm_restore_console();
	return error;
}
Пример #2
0
void g_free_all_handles(int task_id) /* Should only be called in tasker */
{
	mem_entry *cur_entry = &mem_array[mem_handles];
	file_entry *cur_file_entry = &file_array[file_handles];

	int not_lock_dos = !islocked(DOS_SEM);
	int current = mem_handles;

	if (not_lock_dos) lock_dos(440);

	while (current > 0)
	 {
	   cur_entry--;
	   current--;
	   if ((cur_entry->task_id == task_id) && (!cur_entry->kept_open) &&
		   (!(cur_entry->empty)))
		{
		  free_some_memory(cur_entry->memory_pointer);
		};
	 };

	current=file_handles;
	while (current > 0)
	 {
	   current--;
	   cur_file_entry--;
	   if ((cur_file_entry->task_id == task_id) && (!cur_file_entry->kept_open))
		{
		  fclose(cur_file_entry->file_pointer);
		  delete_file_entry(current);
		};
	 };
	if (not_lock_dos) unlock_dos();
};
Пример #3
0
int g_free(void *memory_pointer)
{
#ifdef DEBUG
	char s[80];
#endif

	int dos_not_locked;
	int result;
	int now_tasking = tasking;


	if (now_tasking)
	{
	  dos_not_locked = !islocked(DOS_SEM);
	  if (dos_not_locked) lock_dos(435);
	}
	result=!free_some_memory(memory_pointer);

#ifdef DEBUG
	  sprintf(s,"Freeing pointer %p",memory_pointer);
#endif

	if (now_tasking)
	{
	  if (dos_not_locked) unlock_dos();
	}
	return (result);
};
Пример #4
0
int g_free_from_who(void *memory_pointer, int who)
{
#ifdef DEBUG
	char s[80];
#endif

	int not_lock_dos;
	int result;
	int now_tasking = tasking;

	if (now_tasking)
	{
	  not_lock_dos = !islocked(DOS_SEM);
	  if (not_lock_dos) lock_dos(434);
	}
	result=!free_some_memory(memory_pointer);

#ifdef DEBUG
	  sprintf(s,"Freeing pointer %p",memory_pointer);
#endif

	if (now_tasking)
	{
	  if (not_lock_dos) unlock_dos();
	}
	return (result);
};
Пример #5
0
static int prepare_processes(void)
{
	int error;

	pm_prepare_console();
	sys_sync();
	disable_nonboot_cpus();

	if (freeze_processes()) {
		error = -EBUSY;
		goto thaw;
	}

	if (pm_disk_mode == PM_DISK_PLATFORM) {
		if (pm_ops && pm_ops->prepare) {
			if ((error = pm_ops->prepare(PM_SUSPEND_DISK)))
				goto thaw;
		}
	}

	/* Free memory before shutting down devices. */
	free_some_memory();
	return 0;
thaw:
	thaw_processes();
	enable_nonboot_cpus();
	pm_restore_console();
	return error;
}
Пример #6
0
static void do_software_suspend(void)
{
	if (arch_prepare_suspend()) {
		printk("%sArchitecture failed to prepare\n", name_suspend);
		return;
	}		
	if (pm_prepare_console())
		printk( "%sCan't allocate a console... proceeding\n", name_suspend);
	if (!prepare_suspend_processes()) {

		/* At this point, all user processes and "dangerous"
                   kernel threads are stopped. Free some memory, as we
                   need half of memory free. */

		free_some_memory();
		
		/* No need to invalidate any vfsmnt list -- 
		 * they will be valid after resume, anyway.
		 */
		blk_run_queues();

		/* Save state of all device drivers, and stop them. */		   
		if(drivers_suspend()==0)
			/* If stopping device drivers worked, we proceed basically into
			 * suspend_save_image.
			 *
			 * do_magic(0) returns after system is resumed.
			 *
			 * do_magic() copies all "used" memory to "free" memory, then
			 * unsuspends all device drivers, and writes memory to disk
			 * using normal kernel mechanism.
			 */
			do_magic(0);
		thaw_processes();
	}
	software_suspend_enabled = 1;
	MDELAY(1000);
	pm_restore_console();
}