From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-io1-f48.google.com (mail-io1-f48.google.com [209.85.166.48]) by mx.groups.io with SMTP id smtpd.web08.40273.1655791494509070643 for ; Mon, 20 Jun 2022 23:04:54 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=QHAs52O8; spf=pass (domain: gmail.com, ip: 209.85.166.48, mailfrom: ayushdevel1325@gmail.com) Received: by mail-io1-f48.google.com with SMTP id 19so13197673iou.12 for ; Mon, 20 Jun 2022 23:04:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:from:date:message-id:subject:to; bh=C5Hq8HRM9aMwsC8HFgFK1FjL9uO6Wy2E3kDEaQuYXys=; b=QHAs52O86S0ETrwUfT8nJhcYyDbxA/Fzdmt3mzOhpG7QHNdw5oxVrHtgJ6LhHYaT3K E0DkszlGa+7+SpOPANYQp2uL2FGJA4PQ55gPtG9nCvgjcBdJhqbkJ7MJxRaTKl8YAWgB 5TbbLQvGHPk3IK24s2Vw/Asb9jVSxGriHVkCcO+2oOhtpn8GhAcfLdaHUCKZ7TJfw+Bo ZzxH5j1K9er7wvGaLG8IU8PHvEQfejbC99JZAlqip5xrjAJZbSV3c3vlAjdlt65Bef5J CmkFHPPspGK34DZDljtkEi2XDXWQYx6Drg/SVD2z6j7fcWOtl/J0T2PzNFblxSOYZ5L7 03HQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=C5Hq8HRM9aMwsC8HFgFK1FjL9uO6Wy2E3kDEaQuYXys=; b=59S7Qi//y11PJmrkCEN7saYz3JppQnol0qgr3n2X+gsalQtz00l0mzLHuD6FIcOddN Sv3WK906DybnwSiWFywyb1RvtLN3L53dWGFBCZAt6CbicdXyVar9L3QURSE0yLusyE89 E1ZYt5eL0gZoJDJ4xw+Fe97EFkk/S+Y6XJYqotJf9LhejIckYJOS66rWqNcPZLa+KVdd fvPmK/6aNWA7UeuczlN0JeYzOrzgNOM0IjsNJM3upR1FkB1rATS5nPbtw6gzix9+0Igf Y9u230fCVXHebCIhZUP/b14W30S13TCyKF3H4ycFHWoh9mJQ00HDO0x0Y95TQfkkrwI+ YX7A== X-Gm-Message-State: AJIora9OKDp64Z8pLSjsgXLfN8nMa2B26l5m2TxGiblADdlwRyODug5Z MlYcmVUV6UAritY6RkwrI1Ktz0E2ckq61SS2Yk3AcPnCFUU= X-Google-Smtp-Source: AGRyM1uuOJC7DQ57Y0zm41thXzDHF/NzJ7b1eYos8qecEEjSIDGvye2JQZQKUcQ1uWGs1T+0H3xhdoAce61VDtWFIGQ= X-Received: by 2002:a5d:9345:0:b0:66c:d57a:d06 with SMTP id i5-20020a5d9345000000b0066cd57a0d06mr11880955ioo.56.1655791493763; Mon, 20 Jun 2022 23:04:53 -0700 (PDT) MIME-Version: 1.0 From: "Ayush Singh" Date: Tue, 21 Jun 2022 11:34:42 +0530 Message-ID: Subject: Discussing how SystemTable and its Pointers should be treated in Rust To: edk2-devel-groups-io , Michael Kubacki , michael.d.kinney@intel.com, jabeena.b.gaibusab@intel.com, Jiewen Yao Content-Type: text/plain; charset="UTF-8" Hello everyone, I wanted to discuss and get ideas about how I should implement the various services (like allocator and stdin) for UEFI in Rust. I have come up with two approaches: 1. Initialize the pointers needed for a module to work early on and keep them local to the module. This will mean that the allocator module will store the `allocate_pool` and `free_pool` pointers in a static private to the module which will be initialized by the std before the Rust main is run. 2. Only have one global pointer to the SystemTable and pass that to the functions (like allocate and deallocate) when needed. I am leaning more towards the first approach right now since it would mean that we will only need to assert that the local pointer is valid. However, the 1st approach is a NOGO if it is possible that the pointers in SysteTable can be changed by UEFI. By change, I mean that for example the `allocate_pool` pointer in SystemTable is replaced with a different pointer midway through the program. In that case, the pointer in the allocator module will become invalid but the SystemTable will contain the pointer to the new location of `allocate_pool` and stay valid. Yours Sincerely, Ayush Singh