Skip to content

Automatically Load the hiffy_call result#664

Merged
mkeeter merged 1 commit into
masterfrom
mkeeter/hiffy-call-unpack
May 21, 2026
Merged

Automatically Load the hiffy_call result#664
mkeeter merged 1 commit into
masterfrom
mkeeter/hiffy-call-unpack

Conversation

@mkeeter
Copy link
Copy Markdown
Contributor

@mkeeter mkeeter commented May 12, 2026

(staged on #663)

This PR changes the return type from hiffy_call from Result<Result<Value, String>> to a Result<T: Load, HiffyCallError>. There are two changes here:

  • We automatically unpack into a T: Load (instead of returning a Value)
  • We collapse the nested outer / inner error types into an enum HiffyCallError, which represents both cases

This ends up being a bunch of churn, but is a significant cleanup overall.

@mkeeter mkeeter requested a review from labbott May 12, 2026 21:54
@mkeeter mkeeter force-pushed the mkeeter/hiffy-call-unpack branch from 34d42b2 to 9899a0c Compare May 13, 2026 21:41
@mkeeter mkeeter force-pushed the mkeeter/generic-cells branch 2 times, most recently from 89d1b37 to b3a0238 Compare May 14, 2026 16:20
@mkeeter mkeeter force-pushed the mkeeter/hiffy-call-unpack branch from 9899a0c to 76fc855 Compare May 14, 2026 16:20
@mkeeter mkeeter force-pushed the mkeeter/generic-cells branch from b3a0238 to 8b10ba0 Compare May 14, 2026 16:48
@mkeeter mkeeter force-pushed the mkeeter/hiffy-call-unpack branch from 76fc855 to 7c9ee88 Compare May 14, 2026 16:48
@mkeeter mkeeter force-pushed the mkeeter/generic-cells branch from 8b10ba0 to 379e0b9 Compare May 14, 2026 19:08
@mkeeter mkeeter force-pushed the mkeeter/hiffy-call-unpack branch 3 times, most recently from a98eb7d to 3aa54d7 Compare May 18, 2026 19:53
@mkeeter mkeeter force-pushed the mkeeter/generic-cells branch from 511a371 to 356f019 Compare May 18, 2026 19:53
Comment thread cmd/monorail/src/lib.rs

let op = hubris.get_idol_command("Monorail.write_vsc7448_reg")?;
let value = humility_hiffy::hiffy_call(
humility_hiffy::hiffy_call::<()>(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is actually () because a match value statement got removed below

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The match expects a Base(U0), which is equivalent to (). Writing a random register works fine:

matt@niles ~ () $ pfexec ./humility -t sidecar-b monorail write PTP_DOM[0]:PTP_CLOCK_ID_LSB 0x123
humility: attached to 0483:3754:002600184D4B500E20373831 via ST-Link V3
humility: Writing 0x123 to ANA_ACL:PTP_DOM[0]:PTP_CLOCK_ID_LSB at 0x71434470
  bits |    value   | field
  31:0 | 0x123      | CLOCK_ID_LSB
matt@niles ~ () $ pfexec ./humility -t sidecar-b monorail read PTP_DOM[0]:PTP_CLOCK_ID_LSB
humility: attached to 0483:3754:002600184D4B500E20373831 via ST-Link V3
humility: Reading ANA_ACL:PTP_DOM[0]:PTP_CLOCK_ID_LSB from 0x71434470
ANA_ACL:PTP_DOM[0]:PTP_CLOCK_ID_LSB => 0x123
  bits |    value   | field
  31:0 | 0x123      | CLOCK_ID_LSB

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahhh I parsed that as unsigned 0 but I see () now

Comment thread cmd/monorail/src/lib.rs
pretty_print_fields(value as u32, &reg.fields, 0);
let op = hubris.get_idol_command("Monorail.write_phy_reg")?;
let value = humility_hiffy::hiffy_call(
humility_hiffy::hiffy_call::<()>(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another case where I'm not sure this is actually ()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, the match was looking for Base(U0), which is ():

matt@niles ~ () $ pfexec ./humility -t sidecar-b monorail phy write -p43 13 12
humility: attached to 0483:3754:002600184D4B500E20373831 via ST-Link V3
Writing 0xc to port 43 PHY, register STANDARD:MMD_EEE_ACCESS
matt@niles ~ () $ pfexec ./humility -t sidecar-b monorail phy read -p43 13
humility: attached to 0483:3754:002600184D4B500E20373831 via ST-Link V3
Reading from port 43 PHY, register STANDARD:MMD_EEE_ACCESS
Got result 0xc

Comment thread cmd/rendmp/src/lib.rs
Comment on lines +1669 to +1676
let r = hiffy_call(hubris, core, context, &power_state_op, &[], None, None);
let v = match r {
Ok(r) => Ok(r),
Err(HiffyCallError::Hiffy(s)) => Err(s),
Err(HiffyCallError::Other(e)) => {
return Err(e.context("power state check"));
}
};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vibes and doesn't need to be addressed here: I've seen this pattern with hiffy_call a few times now but I don't know if it can be made common

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this is a bit wordier but I wanted to preserve the original behavior (which actually cares about the difference between a Humility error and an error reported by Hiffy).

@mkeeter mkeeter force-pushed the mkeeter/generic-cells branch from 356f019 to a45b581 Compare May 20, 2026 19:40
@mkeeter mkeeter force-pushed the mkeeter/hiffy-call-unpack branch 2 times, most recently from 2f8ca39 to 8bba220 Compare May 20, 2026 20:09
@mkeeter mkeeter force-pushed the mkeeter/generic-cells branch 2 times, most recently from 759562f to a88a132 Compare May 20, 2026 20:45
@mkeeter mkeeter force-pushed the mkeeter/hiffy-call-unpack branch from 8bba220 to 2d71dee Compare May 20, 2026 20:45
@mkeeter mkeeter force-pushed the mkeeter/generic-cells branch from a88a132 to cecefd8 Compare May 20, 2026 23:03
@mkeeter mkeeter force-pushed the mkeeter/hiffy-call-unpack branch 2 times, most recently from e0235e1 to edfb6c2 Compare May 21, 2026 13:45
@mkeeter mkeeter force-pushed the mkeeter/generic-cells branch 2 times, most recently from e363734 to ff617b0 Compare May 21, 2026 14:09
@mkeeter mkeeter force-pushed the mkeeter/hiffy-call-unpack branch 2 times, most recently from 9e5eb49 to eced31a Compare May 21, 2026 14:24
@mkeeter mkeeter force-pushed the mkeeter/generic-cells branch from 2856341 to d10f467 Compare May 21, 2026 14:37
@mkeeter mkeeter force-pushed the mkeeter/hiffy-call-unpack branch from eced31a to 1347d84 Compare May 21, 2026 14:37
Base automatically changed from mkeeter/generic-cells to master May 21, 2026 15:22
@mkeeter
Copy link
Copy Markdown
Contributor Author

mkeeter commented May 21, 2026

Going through and testing modified commands one-by-one:

console-proxy

matt@niles ~ () $ pfexec ./humility -t gimlet-d console-proxy attach
humility: attached to 0483:3754:000D00344741500820383733 via ST-Link V3

BRM23230022 console login: root
Dec 30 19:11:05 BRM23230022 login: ROOT LOGIN /dev/console

    #####
   ##   ##
  ##   # ##  ##   ##
  ##  #  ##   ## ##     Oxide Computer Company
  ## #   ##    ###      Engineering
   ##   ##    ## ##
    #####    ##   ##    Compute Sled

BRM23230022 # 

host cosmo

matt@niles ~ () $ pfexec ./humility -t cosmo-b host cosmo last-post-code
humility: attached to 0483:374f:002A001C4D46500F20373033 via ST-Link V3
Bootloader Code: 0xed80000f
  Source:  ASP TEE
  Status:  BL_ERR_BOUNDARY_CHECK (0x0f)
  Detail:  Out of Boundary Condition Reached
matt@niles ~ () $ pfexec ./humility -t cosmo-b host cosmo post-codes | head -n10
humility: attached to 0483:374f:002A001C4D46500F20373033 via ST-Link V3
Bootloader Code: 0xee1000b3
  Source:  ASP BL2
  Status:  BL_SUCCESS_BYPASS_IDEVID_CHECK (0xb3)
  Detail:  IDEVID validation failed but bypassed (unsecure)
Bootloader Code: 0xee1000a0
  Source:  ASP BL2
  Status:  BL_SUCCESS_C_MAIN (0xa0)
  Detail:  Successfully entered C Main
Bootloader Code: 0xee1000a3
  Source:  ASP BL2

monorail

matt@niles ~ () $ pfexec ./humility -t sidecar-b monorail status
humility: attached to 0483:3754:002600184D4B500E20373831 via ST-Link V3
PORT | MODE    SPEED  DEV     SERDES  LINK |   PHY    MAC LINK  MEDIA LINK
-----|-------------------------------------|-------------------------------
 0   | SGMII   100M   1G_0    1G_1    down | --       --         --
 1   | SGMII   100M   1G_1    1G_2    down | --       --         --
 2   | SGMII   100M   1G_2    1G_3    down | --       --         --
 3   | SGMII   100M   1G_3    1G_4    down | --       --         --
 4   | SGMII   100M   1G_4    1G_5    err  | --       --         --
 5   | SGMII   100M   1G_5    1G_6    down | --       --         --
 6   | SGMII   100M   1G_6    1G_7    down | --       --         --
 7   | SGMII   100M   1G_7    1G_8    down | --       --         --
 8   | SGMII   100M   2G5_0   6G_0    down | --       --         --
 9   | SGMII   100M   2G5_1   6G_1    down | --       --         --
 10  | SGMII   100M   2G5_2   6G_2    down | --       --         --
 11  | SGMII   100M   2G5_3   6G_3    down | --       --         --
 12  | SGMII   100M   2G5_4   6G_4    down | --       --         --
 13  | SGMII   100M   2G5_5   6G_5    up   | --       --         --
 14  | SGMII   100M   2G5_6   6G_6    up   | --       --         --
 15  | SGMII   100M   2G5_7   6G_7    up   | --       --         --
 16  | SGMII   100M   2G5_8   6G_8    down | --       --         --
 17  | SGMII   100M   2G5_9   6G_9    down | --       --         --
 18  | SGMII   100M   2G5_10  6G_10   down | --       --         --
 19  | SGMII   100M   2G5_11  6G_11   down | --       --         --
 20  | SGMII   100M   2G5_12  6G_12   down | --       --         --
 21  | SGMII   100M   2G5_13  6G_13   down | --       --         --
 22  | --      --     --      --      --   | --       --         --
 23  | --      --     --      --      --   | --       --         --
 24  | SGMII   100M   2G5_16  6G_16   down | --       --         --
 25  | SGMII   100M   2G5_17  6G_17   down | --       --         --
 26  | SGMII   100M   2G5_18  6G_18   down | --       --         --
 27  | SGMII   100M   2G5_19  6G_19   down | --       --         --
 28  | SGMII   100M   2G5_20  6G_20   down | --       --         --
 29  | SGMII   100M   2G5_21  6G_21   down | --       --         --
 30  | SGMII   100M   2G5_22  6G_22   down | --       --         --
 31  | SGMII   100M   2G5_23  6G_23   down | --       --         --
 32  | --      --     --      --      --   | --       --         --
 33  | --      --     --      --      --   | --       --         --
 34  | --      --     --      --      --   | --       --         --
 35  | --      --     --      --      --   | --       --         --
 36  | --      --     --      --      --   | --       --         --
 37  | --      --     --      --      --   | --       --         --
 38  | --      --     --      --      --   | --       --         --
 39  | --      --     --      --      --   | --       --         --
 40  | QSGMII  100M   1G_16   6G_14   up   | VSC8504  up        up
 41  | QSGMII  100M   1G_17   6G_14   up   | VSC8504  up        down
 42  | QSGMII  100M   1G_18   6G_14   up   | VSC8504  up        down
 43  | QSGMII  100M   1G_19   6G_14   up   | VSC8504  up        down
 44  | QSGMII  1G     1G_20   6G_15   up   | VSC8562  err       down
 45  | QSGMII  1G     1G_21   6G_15   up   | VSC8562  up        down
 46  | --      --     --      --      --   | --       --         --
 47  | --      --     --      --      --   | --       --         --
 48  | SGMII   100M   2G5_24  1G_0    up   | --       --         --
 49  | BASEKR  --     10G_0   10G_0   down | --       --         --
 50  | --      --     --      --      --   | --       --         --
 51  | SGMII   100M   2G5_27  10G_2   down | --       --         --
 52  | SGMII   100M   2G5_28  10G_3   down | --       --         --

matt@niles ~ () $ pfexec ./humility -t sidecar-b monorail counters --reset -p48
humility: attached to 0483:3754:002600184D4B500E20373831 via ST-Link V3
matt@niles ~ () $ pfexec ./humility -t sidecar-b monorail counters -p48
humility: attached to 0483:3754:002600184D4B500E20373831 via ST-Link V3
Packet counters: (port 48)
  Receive:
    Unicast:   0
    Multicast: 21
    Broadcast:  0
  Transmit:
    Unicast:   0
    Multicast: 0
    Broadcast:  4

matt@niles ~ () $ pfexec ./humility -t sidecar-b monorail phy read -p43 2
humility: attached to 0483:3754:002600184D4B500E20373831 via ST-Link V3
Reading from port 43 PHY, register STANDARD:IDENTIFIER_1
Got result 0x7

matt@niles ~ () $ pfexec ./humility -t sidecar-b monorail read ANA_AC:RAM_CTRL:RAM_INIT
humility: attached to 0483:3754:002600184D4B500E20373831 via ST-Link V3
humility: Reading ANA_AC:RAM_CTRL:RAM_INIT from 0x71f94358
ANA_AC:RAM_CTRL:RAM_INIT => 0x1
  bits |    value   | field
     1 | 0x0        | RAM_INIT
     0 | 0x1        | RAM_ENA
     
matt@niles ~ () $ pfexec ./humility -t sidecar-b monorail write PTP_DOM[0]:PTP_CLOCK_ID_LSB 0x123
humility: attached to 0483:3754:002600184D4B500E20373831 via ST-Link V3
humility: Writing 0x123 to ANA_ACL:PTP_DOM[0]:PTP_CLOCK_ID_LSB at 0x71434470
  bits |    value   | field
  31:0 | 0x123      | CLOCK_ID_LSB
matt@niles ~ () $ pfexec ./humility -t sidecar-b monorail read PTP_DOM[0]:PTP_CLOCK_ID_LSB
humility: attached to 0483:3754:002600184D4B500E20373831 via ST-Link V3
humility: Reading ANA_ACL:PTP_DOM[0]:PTP_CLOCK_ID_LSB from 0x71434470
ANA_ACL:PTP_DOM[0]:PTP_CLOCK_ID_LSB => 0x123
  bits |    value   | field
  31:0 | 0x123      | CLOCK_ID_LSB
  
matt@niles ~ () $ pfexec ./humility -t sidecar-b monorail phy write -p43 13 12
humility: attached to 0483:3754:002600184D4B500E20373831 via ST-Link V3
Writing 0xc to port 43 PHY, register STANDARD:MMD_EEE_ACCESS
matt@niles ~ () $ pfexec ./humility -t sidecar-b monorail phy read -p43 13
humility: attached to 0483:3754:002600184D4B500E20373831 via ST-Link V3
Reading from port 43 PHY, register STANDARD:MMD_EEE_ACCESS
Got result 0xc

matt@niles ~ () $ pfexec ./humility -t sidecar-b monorail mac
humility: attached to 0483:3754:002600184D4B500E20373831 via ST-Link V3
Reading 15 MAC addresses...
 PORT |        MAC
------|-------------------
   13 | a8:40:25:04:0e:82
      | a8:40:25:04:0e:82
   14 | a8:40:25:04:06:cf
      | a8:40:25:04:06:cf
   15 | a8:40:25:04:06:c7
      | a8:40:25:04:06:c7
   40 | a8:40:25:06:01:19
      | a8:40:25:06:01:19
   44 | e8:ea:6a:09:ca:3d
      | 1c:61:b4:19:39:40
      | e8:ea:6a:09:ca:3d
   48 | a8:40:25:05:ff:00
      | a8:40:25:05:ff:00
      | a8:40:25:05:ff:00
      | a8:40:25:05:ff:00

net

matt@niles ~ () $ pfexec ./humility -t sidecar-b net ip
humility: attached to 0483:3754:002600184D4B500E20373831 via ST-Link V3
MAC address:  a8:40:25:05:ff:00
IPv6 address: fe80::aa40:25ff:fe05:ff00
matt@niles ~ () $ pfexec ./humility -t sidecar-b net mac
humility: attached to 0483:3754:002600184D4B500E20373831 via ST-Link V3
humility: Reading 6 MAC addresses...
 PORT |        MAC
------|-------------------
    1 | 1c:61:b4:19:39:40
      | e8:ea:6a:09:ca:3d
    3 | a8:40:25:05:ff:00
      | a8:40:25:05:ff:00
      | a8:40:25:05:ff:00
      | a8:40:25:05:ff:01
matt@niles ~ () $ pfexec ./humility -t sidecar-b net status
humility: attached to 0483:3754:002600184D4B500E20373831 via ST-Link V3
          ------------------              ---------------------
          |            UP  1 <----------> 0  UP           UP  0 <------>
  SP <--> 3  KSZ8463       |              |      VSC85x2      |
     RMII |            UP  2 <----------> 1  UP          DOWN 1 <------>
          ------------------  100BASE-FX  ---------------------  SGMII
matt@niles ~ () $ pfexec ./humility -t sidecar-b net counters
humility: attached to 0483:3754:002600184D4B500E20373831 via ST-Link V3
 -------------------------------------------------------------------
 |  KSZ8463  |         Transmit         |         Receive          |
 |           |   UC   |   BC   |   MC   |   UC   |   BC   |   MC   |
 |-----------|--------|--------|--------|--------|--------|--------|
 | Port 1    |      0 |      0 |    486 |      0 |     88 |    694 |
 | Port 2    |      0 |      0 |    162 |      0 |      0 |      0 |
 | Port 3    |      0 |     88 |    694 |      0 |      0 |    648 |
 -------------------------------------------------------------------

 -------------------------------------------------------
 |     VSC8562     |     Transmit    |     Receive     |
 |                 |  Good  |   Bad  |  Good  |   Bad  |
 |-----------------------------------------------------|
 | Port 0 | MAC    |    486 |      0 |    782 |      0 |
 |        | Media  |    782 |      0 |    486 |      0 |
 | Port 1 | MAC    |    162 |      0 |      0 |      0 |
 |        | Media  |      0 |      0 |    162 |      0 |
 -------------------------------------------------------

            ┌──────────────────┐            ┌───────────────────┐
            │ KSZ8463          │            │ VSC85x2           │
            │                  │tx        rx│                   │tx
            │               486├───────────►│486             486├───────►
            │                  │1          0│                   │0
┌────┐    rx│               782│◄───────────┤782             782│◄───────
│    ├─────►│648               │rx        tx│                   │rx
│ SP │     3│                  │            │                   │
│    │◄─────┤782               │tx        rx│                   │tx
└────┘    tx│               162├───────────►│162             162├───────►
            │                  │2          1│                   │1
            │                 0│◄───────────┤0                 0│◄───────
            │                  │rx        tx│                   │rx
            └──────────────────┘            └───────────────────┘
                                             MEDIA           MAC

qspi

matt@niles ~ () $ pfexec ./humility -t gimlet-d qspi --slot 1 -r -n10 --addr=0
humility: attached to 0483:3754:000D00344741500820383733 via ST-Link V3
humility: Setting slot to 1
             \/  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
0x00000000 | ff ff ff ff ff ff ff ff de bc                   | ..........
matt@niles ~ () $ pfexec ./humility -t gimlet-d qspi --slot 0 -r -n10 --addr=0
humility: attached to 0483:3754:000D00344741500820383733 via ST-Link V3
humility: Setting slot to 0
             \/  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
0x00000000 | ff ff ff ff ff ff ff ff de bc                   | ..........

(I didn't test write_persistent_data, but checked against the Idol file that the return ok value is ())

rendmp

matt@niles ~ () $ pfexec ./humility -t gimlet-d rendmp --rail=VDD_VCORE --blackbox
humility: attached to 0483:3754:000D00344741500820383733 via ST-Link V3
rail0 uptime: 0 sec
rail1 uptime: 0 sec
controller fault: 00000000000000000000000000000000 ()
rail0 fault: 00000000000000000000000000000000 ()
rail1 fault: 00000000000000000000000000000000 ()
phase fault uc: 00000000000000000000000000000000 ()
phase fault oc: 00000000000000000000000000000000 ()
adc fault uc: 00000000000000000000000000000000 ()
adc fault oc: 00000000000000000000000000000000 ()
rail0 status: 0000000000000000 ()
rail1 status: 0000000000000000 ()
status cml: 00000000 ()
status mfr: 00000000 ()
rail1 status vout: 00000000 ()
rail0 status vout: 00000000 ()
rail1 status iout: 00000000 ()
rail0 status iout: 00000000 ()
rail1 status temperature: 00000000 ()
rail0 status temperature: 00000000 ()
rail1 status input: 00000000 ()
rail0 status input: 00000000 ()

     | RAIL 0  | RAIL 1
-----|---------|-----------
VIN  | 0.00 V  | 0.00 V
VOUT | 0.000 V | 0.000 V
IIN  | 0.00 A  | 0.00 A
IOUT | 0.0 A   | 0.0 A
TEMP | 0°C     | 0°C
controller read temperature: 0°C

 PHASE | TEMPERATURE | CURRENT
-------|-------------|----------
 0     | 0°C         | 0.0 A
 1     | 0°C         | 0.0 A
 2     | 0°C         | 0.0 A
 3     | 0°C         | 0.0 A
 4     | 0°C         | 0.0 A
 5     | 0°C         | 0.0 A
 6     | 0°C         | 0.0 A
 7     | 0°C         | 0.0 A
 8     | 0°C         | 0.0 A
 9     | 0°C         | 0.0 A
 10    | 0°C         | 0.0 A
 11    | 0°C         | 0.0 A
 12    | 0°C         | 0.0 A
 13    | 0°C         | 0.0 A
 14    | 0°C         | 0.0 A
 15    | 0°C         | 0.0 A
 16    | 0°C         | 0.0 A
 17    | 0°C         | 0.0 A
 18    | 0°C         | 0.0 A
 19    | 0°C         | 0.0 A

(this matches stock humility's behavior on an empty blackbox)

tofino-eeprom

Not tested, but I checked the Idol return types against the idl file

auxflash

matt@niles ~ () $ pfexec ./humility -t sidecar-b auxflash status
humility: attached to 0483:3754:002600184D4B500E20373831 via ST-Link V3
 slot | status
------|----------------------------
    0 | Active (86d84981...)
    1 | Valid  (86d84981...)
    2 | Valid  (40851455...)
    3 | Valid  (40851455...)
    4 | Valid  (6d9dc15f...)
    5 | Valid  (6d9dc15f...)
    6 | Valid  (dba90cf0...)
    7 | Valid  (dba90cf0...)
    8 | Valid  (0c234d97...)
    9 | Valid  (0c234d97...)
   10 | Valid  (0d424a47...)
   11 | Valid  (0d424a47...)
   12 | Valid  (08319eb6...)
   13 | Valid  (08319eb6...)
   14 | Valid  (0cf1dfd3...)
   15 | Valid  (0cf1dfd3...)
   
matt@niles ~ () $ pfexec ./humility -t sidecar-b auxflash read --slot 0 -c 10 out.bin
humility: attached to 0483:3754:002600184D4B500E20373831 via ST-Link V3
xmatt@niles ~ () $ xxd out.bin
00000000: 4348 434b 2000 0000 64bf                 CHCK ...d.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the humility_hiffy call path to return typed decoded values (T: reflect::Load) directly from hiffy_call, while also collapsing the previously nested error shape into a single HiffyCallError enum. It also updates downstream callers and enhances the Load derive macro to support generic parameters and an optional reflected-type name check.

Changes:

  • Change hiffy_call to return a loaded T: reflect::Load and introduce HiffyCallError to unify error handling.
  • Update callers across commands/crates to use typed hiffy_call::<T>() / hiffy_decode::<T>() and simplify manual Value unpacking.
  • Extend #[derive(Load)] to support generics and add #[load(check_name)] for runtime reflected-name validation (used by newly generic doppel cell wrappers).

Reviewed changes

Copilot reviewed 16 out of 17 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
load_derive/src/lib.rs Adds #[load(check_name)] support and generic-aware Load impl generation (with some correctness gaps noted).
humility-spd/src/lib.rs Switches packrat buffer reads to typed reflect::read_variable and generic ClaimOnceCell.
humility-hiffy/src/lib.rs Introduces HiffyCallError; makes hiffy_call/hiffy_decode generic over T: Load.
humility-hiffy/Cargo.toml Removes unused parse_int dependency from humility-hiffy.
humility-doppel/src/lib.rs Makes ClaimOnceCell/StaticCell/UnsafeCell/MaybeUninit generic and adds #[load(check_name)].
humility-core/src/reflect.rs Moves Load for Array impl earlier (no functional change).
humility-auxflash/src/lib.rs Updates auxflash operations to use typed hiffy_call and HiffyCallError matching.
cmd/tofino-eeprom/src/lib.rs Updates EEPROM read/write loops to typed hiffy_call::<()>().
cmd/ringbuf/src/lib.rs Updates StaticCell usage to StaticCell<Ringbuf>.
cmd/rendmp/src/lib.rs Updates blackbox dump and worker decode path for typed hiffy_call/hiffy_decode.
cmd/qspi/src/lib.rs Updates QSPI calls to typed hiffy_call::<()>() and simplifies success handling.
cmd/net/src/lib.rs Updates network commands to typed hiffy_call / hiffy_decode::<Struct> and simplifies parsing.
cmd/monorail/src/lib.rs Updates monorail reads/writes and status decoding to typed hiffy_call / hiffy_decode::<Struct>.
cmd/host/src/lib.rs Updates host buffer reads and post-code operations to typed hiffy_call.
cmd/hiffy/src/lib.rs Adapts CLI call path to new HiffyCallError while preserving “return_code” printing behavior.
cmd/console-proxy/src/posix.rs Updates UART operations to typed hiffy_call and removes now-unused imports/logic.
Cargo.lock Removes parse_int from humility-hiffy dependency list.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread load_derive/src/lib.rs
Comment thread load_derive/src/lib.rs
Comment thread load_derive/src/lib.rs
Comment on lines +47 to +59
fn has_check_name(attrs: &[syn::Attribute]) -> bool {
attrs.iter().any(|a| {
if !a.path().is_ident("load") {
return false;
}
let mut found = false;
let _ = a.parse_nested_meta(|meta| {
if meta.path.is_ident("check_name") {
found = true;
}
Ok(())
});
found
Comment thread load_derive/src/lib.rs
Comment thread humility-hiffy/src/lib.rs Outdated
Comment thread cmd/rendmp/src/lib.rs Outdated
};
let v = hiffy_decode(self.hubris, op, value)
let v = hiffy_decode::<Base>(self.hubris, op, value)
.context("failed to decode {op:?} result")?;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

@labbott labbott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We love a net negative PR 😎

@mkeeter mkeeter force-pushed the mkeeter/hiffy-call-unpack branch 2 times, most recently from b5d57e1 to b40ed6c Compare May 21, 2026 16:45
@mkeeter
Copy link
Copy Markdown
Contributor Author

mkeeter commented May 21, 2026

Copilot review also looked at the tail end of the previous PR (#663), so those can be ignored.

@mkeeter mkeeter force-pushed the mkeeter/hiffy-call-unpack branch from b40ed6c to cc28c4f Compare May 21, 2026 17:29
@mkeeter mkeeter merged commit f6887d4 into master May 21, 2026
12 checks passed
@mkeeter mkeeter deleted the mkeeter/hiffy-call-unpack branch May 21, 2026 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants