summaryrefslogtreecommitdiffstats
path: root/arch/sparc/ap1000/mpp.c
blob: 1e6596a07c8cb62b3d80baca060897bde0a1e88b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
  /*
   * Copyright 1996 The Australian National University.
   * Copyright 1996 Fujitsu Laboratories Limited
   * 
   * This software may be distributed under the terms of the Gnu
   * Public License version 2 or later
  */
/*
 * simple mpp functions for the AP+
 */

#include <asm/ap1000/apreg.h>
#include <asm/ap1000/apservice.h>
#include <linux/mm.h>
#include <linux/sched.h>
#include <linux/interrupt.h>
#include <asm/pgtable.h>

extern int cap_cid0;
extern int cap_ncel0;
extern struct cap_init cap_init;

static volatile int mpp_current_task = 0;
static int gang_factor = DEF_GANG_FACTOR;
static int last_task = 0;


void mpp_schedule(struct cap_request *req)
{
	mpp_current_task = req->data[0];
	current->need_resched = 1;
	mark_bh(TQUEUE_BH);
}


void mpp_notify_schedule(struct task_struct *tsk)
{
	last_task = tsk->taskid;

	msc_switch_check(tsk);

	if (gang_factor == 0) return;

	if (cap_cid0 == cap_init.bootcid && 
	    mpp_current_task != tsk->taskid) {
		struct cap_request req;

		mpp_current_task = tsk->taskid;
	
		req.cid = mpp_cid();
		req.type = REQ_SCHEDULE;
		req.size = sizeof(req);
 		req.header = MAKE_HEADER(-1);
		req.data[0] = mpp_current_task;
		
		bif_queue(&req,NULL,0);
	}
}


int mpp_weight(struct task_struct *tsk)
{
	extern int block_parallel_tasks;

	if (!MPP_IS_PAR_TASK(tsk->taskid)) return 0;

	if (block_parallel_tasks) return -1000;

	/* XXX task[] fixme */
	if (last_task && last_task != tsk->taskid && task[last_task] &&
	    !msc_switch_ok()) return -1000;

	if (cap_cid0 != cap_init.bootcid &&
	    tsk->taskid != mpp_current_task) {
		return -gang_factor;
	}
	return 0;
}

void mpp_set_gang_factor(int factor)
{
	gang_factor = factor;
}