kernel: server: replace ctx with tid

Threads haven't been called contexts for a very long time.

Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
Sean Cross 2020-11-11 16:04:35 +08:00
parent 7156ab5e79
commit 4b83edc43b

View file

@ -50,7 +50,7 @@ enum QueuedMessage {
Empty, Empty,
BlockingScalarMessage( BlockingScalarMessage(
u16, /* client PID */ u16, /* client PID */
u16, /* client CTX */ u16, /* client TID */
usize, /* server return address */ usize, /* server return address */
usize, /* id */ usize, /* id */
usize, /* arg1 */ usize, /* arg1 */
@ -60,7 +60,7 @@ enum QueuedMessage {
), ),
ScalarMessage( ScalarMessage(
u16, /* client PID */ u16, /* client PID */
u16, /* client CTX */ u16, /* client TID */
usize, /* server return address */ usize, /* server return address */
usize, /* id */ usize, /* id */
usize, /* arg1 */ usize, /* arg1 */
@ -70,7 +70,7 @@ enum QueuedMessage {
), ),
MemoryMessageSend( MemoryMessageSend(
u16, /* client PID */ u16, /* client PID */
u16, /* client CTX */ u16, /* client TID */
usize, /* reserved */ usize, /* reserved */
usize, /* id */ usize, /* id */
usize, /* buf */ usize, /* buf */
@ -80,7 +80,7 @@ enum QueuedMessage {
), ),
MemoryMessageROLend( MemoryMessageROLend(
u16, /* client PID */ u16, /* client PID */
u16, /* client CTX */ u16, /* client TID */
usize, /* address of memory base in server */ usize, /* address of memory base in server */
usize, /* id */ usize, /* id */
usize, /* buf */ usize, /* buf */
@ -90,7 +90,7 @@ enum QueuedMessage {
), ),
MemoryMessageRWLend( MemoryMessageRWLend(
u16, /* client PID */ u16, /* client PID */
u16, /* client CTX */ u16, /* client TID */
usize, /* address of memory base in server */ usize, /* address of memory base in server */
usize, /* id */ usize, /* id */
usize, /* buf */ usize, /* buf */
@ -103,7 +103,7 @@ enum QueuedMessage {
/// we could receive the message. /// we could receive the message.
MemoryMessageROLendTerminated( MemoryMessageROLendTerminated(
u16, /* client PID */ u16, /* client PID */
u16, /* client CTX */ u16, /* client TID */
usize, /* address of memory base in server */ usize, /* address of memory base in server */
usize, /* id */ usize, /* id */
usize, /* buf */ usize, /* buf */
@ -116,7 +116,7 @@ enum QueuedMessage {
/// we could receive the message. /// we could receive the message.
MemoryMessageRWLendTerminated( MemoryMessageRWLendTerminated(
u16, /* client PID */ u16, /* client PID */
u16, /* client CTX */ u16, /* client TID */
usize, /* address of memory base in server */ usize, /* address of memory base in server */
usize, /* id */ usize, /* id */
usize, /* buf */ usize, /* buf */
@ -129,7 +129,7 @@ enum QueuedMessage {
/// we could receive the message. /// we could receive the message.
BlockingScalarTerminated( BlockingScalarTerminated(
u16, /* client PID */ u16, /* client PID */
u16, /* client CTX */ u16, /* client TID */
usize, /* server return address */ usize, /* server return address */
usize, /* id */ usize, /* id */
usize, /* arg1 */ usize, /* arg1 */
@ -144,7 +144,7 @@ enum QueuedMessage {
/// sending process. /// sending process.
WaitingReturnMemory( WaitingReturnMemory(
u16, /* client PID */ u16, /* client PID */
u16, /* client CTX */ u16, /* client TID */
usize, /* address of memory base in server */ usize, /* address of memory base in server */
usize, /* client base address */ usize, /* client base address */
usize, /* Range size */ usize, /* Range size */
@ -154,7 +154,7 @@ enum QueuedMessage {
/// to the previous process. /// to the previous process.
WaitingForget( WaitingForget(
u16, /* client PID */ u16, /* client PID */
u16, /* client CTX */ u16, /* client TID */
usize, /* address of memory base in server */ usize, /* address of memory base in server */
usize, /* client base address */ usize, /* client base address */
usize, /* Range size */ usize, /* Range size */
@ -164,7 +164,7 @@ enum QueuedMessage {
/// page. /// page.
WaitingReturnScalar( WaitingReturnScalar(
u16, /* client PID */ u16, /* client PID */
u16, /* client CTX */ u16, /* client TID */
usize, /* server return address */ usize, /* server return address */
), ),
} }
@ -270,7 +270,7 @@ impl Server {
match *entry { match *entry {
QueuedMessage::MemoryMessageROLend( QueuedMessage::MemoryMessageROLend(
msg_pid, msg_pid,
ctx, tid,
arg1, arg1,
arg2, arg2,
arg3, arg3,
@ -280,13 +280,13 @@ impl Server {
) => { ) => {
if msg_pid == pid.get() as _ { if msg_pid == pid.get() as _ {
*entry = QueuedMessage::MemoryMessageROLendTerminated( *entry = QueuedMessage::MemoryMessageROLendTerminated(
msg_pid, ctx, arg1, arg2, arg3, arg4, arg5, arg6, msg_pid, tid, arg1, arg2, arg3, arg4, arg5, arg6,
); );
} }
} }
QueuedMessage::MemoryMessageRWLend( QueuedMessage::MemoryMessageRWLend(
msg_pid, msg_pid,
ctx, tid,
arg1, arg1,
arg2, arg2,
arg3, arg3,
@ -296,13 +296,13 @@ impl Server {
) => { ) => {
if msg_pid == pid.get() as _ { if msg_pid == pid.get() as _ {
*entry = QueuedMessage::MemoryMessageRWLendTerminated( *entry = QueuedMessage::MemoryMessageRWLendTerminated(
msg_pid, ctx, arg1, arg2, arg3, arg4, arg5, arg6, msg_pid, tid, arg1, arg2, arg3, arg4, arg5, arg6,
); );
} }
} }
QueuedMessage::BlockingScalarMessage( QueuedMessage::BlockingScalarMessage(
msg_pid, msg_pid,
ctx, tid,
arg1, arg1,
arg2, arg2,
arg3, arg3,
@ -312,7 +312,7 @@ impl Server {
) => { ) => {
if msg_pid == pid.get() as _ { if msg_pid == pid.get() as _ {
*entry = QueuedMessage::BlockingScalarTerminated( *entry = QueuedMessage::BlockingScalarTerminated(
msg_pid, ctx, arg1, arg2, arg3, arg4, arg5, arg6, msg_pid, tid, arg1, arg2, arg3, arg4, arg5, arg6,
); );
} }
} }
@ -338,15 +338,15 @@ impl Server {
return Err(xous_kernel::Error::BadAddress); return Err(xous_kernel::Error::BadAddress);
} }
print!(" [memory in queue[{}]: {:?}]", idx, self.queue[idx]); print!(" [memory in queue[{}]: {:?}]", idx, self.queue[idx]);
let (pid, ctx, server_addr, client_addr, len, forget, is_memory) = match self.queue[idx] { let (pid, tid, server_addr, client_addr, len, forget, is_memory) = match self.queue[idx] {
QueuedMessage::WaitingReturnMemory(pid, ctx, server_addr, client_addr, len) => { QueuedMessage::WaitingReturnMemory(pid, tid, server_addr, client_addr, len) => {
(pid, ctx, server_addr, client_addr, len, false, true) (pid, tid, server_addr, client_addr, len, false, true)
} }
QueuedMessage::WaitingForget(pid, ctx, server_addr, client_addr, len) => { QueuedMessage::WaitingForget(pid, tid, server_addr, client_addr, len) => {
(pid, ctx, server_addr, client_addr, len, true, true) (pid, tid, server_addr, client_addr, len, true, true)
} }
QueuedMessage::WaitingReturnScalar(pid, ctx, return_address) => { QueuedMessage::WaitingReturnScalar(pid, tid, return_address) => {
(pid, ctx, return_address, 0, 0, true, false) (pid, tid, return_address, 0, 0, true, false)
} }
_ => return Ok(WaitingMessage::None), _ => return Ok(WaitingMessage::None),
}; };
@ -366,13 +366,13 @@ impl Server {
self.queue_tail = 0; self.queue_tail = 0;
} }
// Destructure the PID and context ID from the `pid_ctx` field // Destructure the PID and context ID from the `pid_tid` field
// println!("Taking waiting message -- pid: {} ctx: {}", pid, ctx); print!(" [taking waiting message and returning to pid: {} tid: {}", pid, tid);
if !is_memory { if !is_memory {
return Ok(WaitingMessage::ScalarMessage( return Ok(WaitingMessage::ScalarMessage(
PID::new(pid as _).unwrap(), PID::new(pid as _).unwrap(),
ctx as _, tid as _,
)); ));
} }
@ -394,7 +394,7 @@ impl Server {
let len = MemorySize::new(len).expect("memory length was 0, but address was not None"); let len = MemorySize::new(len).expect("memory length was 0, but address was not None");
Ok(WaitingMessage::BorrowedMemory( Ok(WaitingMessage::BorrowedMemory(
PID::new(pid as _).unwrap(), PID::new(pid as _).unwrap(),
ctx as _, tid as _,
server_addr, server_addr,
client_addr, client_addr,
len, len,
@ -427,7 +427,7 @@ impl Server {
QueuedMessage::WaitingReturnScalar(_, _, _) => return None, QueuedMessage::WaitingReturnScalar(_, _, _) => return None,
QueuedMessage::MemoryMessageROLend( QueuedMessage::MemoryMessageROLend(
pid, pid,
ctx, tid,
client_addr, client_addr,
id, id,
buf, buf,
@ -444,11 +444,11 @@ impl Server {
valid: MemorySize::new(valid), valid: MemorySize::new(valid),
}), }),
}, },
QueuedMessage::WaitingReturnMemory(pid, ctx, buf, client_addr, buf_size), QueuedMessage::WaitingReturnMemory(pid, tid, buf, client_addr, buf_size),
), ),
QueuedMessage::MemoryMessageRWLend( QueuedMessage::MemoryMessageRWLend(
pid, pid,
ctx, tid,
client_addr, client_addr,
id, id,
buf, buf,
@ -465,11 +465,11 @@ impl Server {
valid: MemorySize::new(valid), valid: MemorySize::new(valid),
}), }),
}, },
QueuedMessage::WaitingReturnMemory(pid, ctx, buf, client_addr, buf_size), QueuedMessage::WaitingReturnMemory(pid, tid, buf, client_addr, buf_size),
), ),
QueuedMessage::MemoryMessageROLendTerminated( QueuedMessage::MemoryMessageROLendTerminated(
pid, pid,
ctx, tid,
client_addr, client_addr,
id, id,
buf, buf,
@ -486,11 +486,11 @@ impl Server {
valid: MemorySize::new(valid), valid: MemorySize::new(valid),
}), }),
}, },
QueuedMessage::WaitingReturnMemory(pid, ctx, buf, client_addr, buf_size), QueuedMessage::WaitingReturnMemory(pid, tid, buf, client_addr, buf_size),
), ),
QueuedMessage::MemoryMessageRWLendTerminated( QueuedMessage::MemoryMessageRWLendTerminated(
pid, pid,
ctx, tid,
client_addr, client_addr,
id, id,
buf, buf,
@ -507,12 +507,12 @@ impl Server {
valid: MemorySize::new(valid), valid: MemorySize::new(valid),
}), }),
}, },
QueuedMessage::WaitingReturnMemory(pid, ctx, buf, client_addr, buf_size), QueuedMessage::WaitingReturnMemory(pid, tid, buf, client_addr, buf_size),
), ),
QueuedMessage::BlockingScalarMessage( QueuedMessage::BlockingScalarMessage(
pid, pid,
ctx, tid,
client_addr, client_addr,
id, id,
arg1, arg1,
@ -530,11 +530,11 @@ impl Server {
arg4, arg4,
}), }),
}, },
QueuedMessage::WaitingReturnScalar(pid, ctx, client_addr), QueuedMessage::WaitingReturnScalar(pid, tid, client_addr),
), ),
QueuedMessage::MemoryMessageSend( QueuedMessage::MemoryMessageSend(
_pid, _pid,
_ctx, _tid,
_reserved, _reserved,
id, id,
buf, buf,
@ -560,7 +560,7 @@ impl Server {
} }
// Scalar messages have nothing to return, so they can go straight to the `Free` state // Scalar messages have nothing to return, so they can go straight to the `Free` state
QueuedMessage::ScalarMessage(_pid, _ctx, _reserved, id, arg1, arg2, arg3, arg4) => { QueuedMessage::ScalarMessage(_pid, _tid, _reserved, id, arg1, arg2, arg3, arg4) => {
let msg = xous_kernel::MessageEnvelope { let msg = xous_kernel::MessageEnvelope {
sender, sender,
body: xous_kernel::Message::Scalar(xous_kernel::ScalarMessage { body: xous_kernel::Message::Scalar(xous_kernel::ScalarMessage {
@ -580,7 +580,7 @@ impl Server {
} }
QueuedMessage::BlockingScalarTerminated( QueuedMessage::BlockingScalarTerminated(
_pid, _pid,
_ctx, _tid,
_reserved, _reserved,
id, id,
arg1, arg1,
@ -623,7 +623,7 @@ impl Server {
message: xous_kernel::Message, message: xous_kernel::Message,
original_address: Option<MemoryAddress>, original_address: Option<MemoryAddress>,
) -> core::result::Result<usize, xous_kernel::Error> { ) -> core::result::Result<usize, xous_kernel::Error> {
// println!("Queueing message: {:?} for pid: {} ctx: {}", message, pid.get(), context); // println!("Queueing message: {:?} for pid: {} tid: {}", message, pid.get(), context);
if self.queue[self.queue_head] != QueuedMessage::Empty { if self.queue[self.queue_head] != QueuedMessage::Empty {
return Err(xous_kernel::Error::ServerQueueFull); return Err(xous_kernel::Error::ServerQueueFull);
} }
@ -696,7 +696,7 @@ impl Server {
message: &Message, message: &Message,
client_address: Option<MemoryAddress>, client_address: Option<MemoryAddress>,
) -> core::result::Result<usize, xous_kernel::Error> { ) -> core::result::Result<usize, xous_kernel::Error> {
// println!("Queueing address message: {:?} (pid: {} ctx: {})", message, pid.get(), context); // println!("Queueing address message: {:?} (pid: {} tid: {})", message, pid.get(), context);
if self.queue[self.queue_head] != QueuedMessage::Empty { if self.queue[self.queue_head] != QueuedMessage::Empty {
return Err(xous_kernel::Error::ServerQueueFull); return Err(xous_kernel::Error::ServerQueueFull);
} }