§H.12 step 2: session-slot table, session_find/session_register
src/starkernel/vm/session.c: kmalloc'd-at-boot slot table sized from stadium_max_vm_count() (mirrors stadium.c's own StadiumVMQuota, not a fixed compile-time array as originally planned -- that table was already moved off a fixed array for the same "population isn't knowable in advance" reason). session_boot_init()/session_find()/session_register() implemented for real, no stubs; session_register() zeroes identity and leaves pinned=0, matching VMIdentity's own documented default and deferring pin policy to callers. Added session.c to Makefile.starkernel's explicit source lists. No callers yet. Verified 3-arch boot to ok> (amd64/aarch64/riscv64). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
668e36bb17
commit
6d9fe3f515
@@ -76,6 +76,54 @@ typedef struct {
|
||||
VMIdentity identity; /* embedded, not referenced -- see vm_identity.h */
|
||||
} Session;
|
||||
|
||||
/*
|
||||
* session_boot_init - Boot-time allocation, mirroring stadium_boot_init()'s
|
||||
* own kmalloc-sized-from-budget shape rather than a fixed compile-time
|
||||
* array (stadium.c's own StadiumVMQuota table was moved off a fixed array
|
||||
* for the same reason -- population isn't knowable in advance). Must run
|
||||
* after stadium_boot_init() (session slot count is sized from
|
||||
* stadium_max_vm_count()) and before the first session is registered.
|
||||
* No callers yet (§H.12 step 2) -- wiring into the boot sequence happens
|
||||
* in a later punch-list step.
|
||||
*
|
||||
* @return 0 on success, -1 if kmalloc failed or stadium_max_vm_count() is 0
|
||||
* (Stadium not yet initialized).
|
||||
*/
|
||||
int session_boot_init(void);
|
||||
|
||||
/*
|
||||
* session_find - Look up a session by the VMUuid of the patron it
|
||||
* references. Linear scan, same shape as stadium.c's own
|
||||
* quota_slot_for_vm() -- the population this searches is small (one entry
|
||||
* per VM, not per word/block).
|
||||
*
|
||||
* @return Pointer to the live session, or NULL if none is registered for
|
||||
* vm_id.
|
||||
*/
|
||||
Session *session_find(VMUuid vm_id);
|
||||
|
||||
/*
|
||||
* session_register - Register a new session for vm_id. identity starts
|
||||
* zeroed (VMIdentity's own documented default: installed=0, "no lock,
|
||||
* allow freely" -- §H.12 Correction 2). pinned starts 0 (unpinned); use
|
||||
* session_set_pinned() separately to pin, keeping this function's job to
|
||||
* "create the session record" only, not "create and also decide pin
|
||||
* policy" -- callers (e.g. the capsule-birth admission path, §H.12 phase 2)
|
||||
* decide pinning themselves.
|
||||
*
|
||||
* @param vm_id The patron this session references. Must not already have
|
||||
* a registered session (session_find(vm_id) must be NULL).
|
||||
* @param parent Who birthed this session (vm_uuid_hera() for Hera's own
|
||||
* self-registration -- self-referential, matching the
|
||||
* existing parent_vm_id convention documented in
|
||||
* capsule_run.h).
|
||||
* @param name Copied into the new session's name buffer, truncated to
|
||||
* SESSION_NAME_BUF - 1 if longer.
|
||||
* @return Pointer to the new session, or NULL if the slot table is full,
|
||||
* not yet initialized, or vm_id is already registered.
|
||||
*/
|
||||
Session *session_register(VMUuid vm_id, VMUuid parent, const char *name);
|
||||
|
||||
#endif /* __STARKERNEL__ */
|
||||
|
||||
#endif /* STARKERNEL_SESSION_H */
|
||||
|
||||
Reference in New Issue
Block a user