From 1de55b117abe74e9842af19fd90aa55edf571ce5 Mon Sep 17 00:00:00 2001 From: jack Date: Fri, 8 Mar 2024 00:20:24 -0500 Subject: [PATCH] removed some debug print statements --- application_processor/build.rs | 43 +------------------ .../src/post_boot/messaging.rs | 6 --- application_processor/src/replace.rs | 1 - component/build.rs | 37 +--------------- component/src/post_boot/messaging.rs | 6 --- deployment/src/lib.rs | 35 +++++++++++++++ 6 files changed, 37 insertions(+), 91 deletions(-) diff --git a/application_processor/build.rs b/application_processor/build.rs index 0b1cd22..00db3dd 100644 --- a/application_processor/build.rs +++ b/application_processor/build.rs @@ -7,12 +7,7 @@ use rand::rngs::ThreadRng; use rand::Rng; use bcrypt::bcrypt; -use deployment::{force_rerun, generate_random_bytes, parse_component_id, SecretDb}; - - -struct LineParser<'a> { - data: &'a str, -} +use deployment::{force_rerun, generate_random_bytes, parse_component_id, SecretDb, LineParser}; /* * Generate an address that is a multiple of 8 @@ -22,37 +17,6 @@ fn gen_addr(start: u32, end: u32, rng: &mut ThreadRng) -> u32 { rng.gen_range((start/8 + 1)..(end/8)) * 8 } -impl<'a> LineParser<'a> { - fn take_until_index(&mut self, index: usize) -> &'a str { - let out = &self.data[..index]; - self.data = &self.data[index..]; - out - } - - fn take_token(&mut self) -> Option<&'a str> { - if self.data.len() == 0 { - return None; - } - - let out = self.take_until_index(self.data.find(' ').unwrap_or(self.data.len())); - self.data = self.data.trim_start(); - Some(out) - } - - fn take_string(&mut self) -> Option<&'a str> { - if self.data.get(..1)? != "\"" { - return None; - } - - self.data = &self.data[1..]; - - let out = self.take_until_index(self.data.find('"')?); - self.data = &self.data[1..]; - - Some(out) - } -} - // this build script just parses ap ectf params from inc/ectf_params.h into a rust file $OUT_DIR/ectf_params.rs fn main() { force_rerun(); @@ -127,11 +91,6 @@ fn main() { rust_code.push_str("];\n"); }, - Some("COMPONENT_CNT") => { - let data = parser.take_token().expect("no parameter for COMPONENT_CNT"); - - rust_code.push_str(&format!("pub const COMPONENTS_LEN: u8 = {};\n", data)); - }, Some("AP_BOOT_MSG") => { let data = parser.take_string().expect("no parameter for AP_BOOT_MSG"); diff --git a/application_processor/src/post_boot/messaging.rs b/application_processor/src/post_boot/messaging.rs index 57bc863..3005bae 100644 --- a/application_processor/src/post_boot/messaging.rs +++ b/application_processor/src/post_boot/messaging.rs @@ -10,7 +10,6 @@ use crate::ApError; use crate::ap_driver::ApDriver; pub fn secure_send(driver: &mut ApDriver, address: I2cAddr, message: &[u8]) -> Result<(), ApError> { - uprintln_debug!("secure send to: {address:x?} {message:?}"); let flash_data = driver.get_flash_data(); let component = flash_data.get_component_for_i2c_addr(address) .ok_or(ApError::InvalidComponentError)?; @@ -34,8 +33,6 @@ pub fn secure_send(driver: &mut ApDriver, address: I2cAddr, message: &[u8]) -> R signature: signature.into(), })?; - uprintln_debug!("secure send done"); - Ok(()) } @@ -44,7 +41,6 @@ pub fn secure_receive( address: I2cAddr, recv_buf: &mut [u8; MAX_POST_BOOT_MESSAGE_SIZE] ) -> Result { - uprintln_debug!("secure recieve from: {address:x?}"); let flash_data = driver.get_flash_data(); let component = flash_data.get_component_for_i2c_addr(address) .ok_or(ApError::InvalidComponentError)?; @@ -77,7 +73,5 @@ pub fn secure_receive( let message_len = message.message.len(); recv_buf[..message_len].copy_from_slice(message.message.as_slice()); - uprintln_debug!("secure recv done: {:?}", message.message); - Ok(message_len) } diff --git a/application_processor/src/replace.rs b/application_processor/src/replace.rs index db24d48..b2100f6 100644 --- a/application_processor/src/replace.rs +++ b/application_processor/src/replace.rs @@ -34,7 +34,6 @@ fn perform_replace(driver: &mut ApDriver) -> Result<(), ApError> { driver.save_flash_data(flash_data); - uprintln_debug!("Replaced 0x{:08x} with 0x{:08x}", old_component_id, new_component_id); uprintln_success!("Replace"); Ok(()) diff --git a/component/build.rs b/component/build.rs index ebb0215..326caa2 100644 --- a/component/build.rs +++ b/component/build.rs @@ -4,7 +4,7 @@ use std::path::PathBuf; use std::env; use rand::rngs::ThreadRng; -use deployment::{SecretDb, parse_component_id, generate_encrypted_rust_const, force_rerun}; +use deployment::{SecretDb, parse_component_id, generate_encrypted_rust_const, force_rerun, LineParser}; use rand::Rng; /* @@ -15,41 +15,6 @@ fn gen_addr(start: u32, end: u32, rng: &mut ThreadRng) -> u32 { rng.gen_range((start/8 + 1)..(end/8)) * 8 } -struct LineParser<'a> { - data: &'a str, -} - -impl<'a> LineParser<'a> { - fn take_until_index(&mut self, index: usize) -> &'a str { - let out = &self.data[..index]; - self.data = &self.data[index..]; - out - } - - fn take_token(&mut self) -> Option<&'a str> { - if self.data.len() == 0 { - return None; - } - - let out = self.take_until_index(self.data.find(' ').unwrap_or(self.data.len())); - self.data = self.data.trim_start(); - Some(out) - } - - fn take_string(&mut self) -> Option<&'a str> { - if self.data.get(..1)? != "\"" { - return None; - } - - self.data = &self.data[1..]; - - let out = self.take_until_index(self.data.find('"')?); - self.data = &self.data[1..]; - - Some(out) - } -} - // this build script just parses ap ectf params from inc/ectf_params.h into a rust file $OUT_DIR/ectf_params.rs fn main() { force_rerun(); diff --git a/component/src/post_boot/messaging.rs b/component/src/post_boot/messaging.rs index 516ada6..d3cf01b 100644 --- a/component/src/post_boot/messaging.rs +++ b/component/src/post_boot/messaging.rs @@ -11,7 +11,6 @@ use crate::ComponentError; use crate::component_driver::ComponentDriver; pub fn secure_send(driver: &mut ComponentDriver, message: &[u8]) -> Result<(), ComponentError> { - uprintln!("secure send: {message:?}"); // TODO: send ap error if serialization fails let post_boot_request: PostBootMessageStart = driver.recv_struct()?; @@ -37,8 +36,6 @@ pub fn secure_send(driver: &mut ComponentDriver, message: &[u8]) -> Result<(), C signature: signature.into(), })?; - uprintln!("secure send done"); - Ok(()) } @@ -46,7 +43,6 @@ pub fn secure_receive( driver: &mut ComponentDriver, recv_buf: &mut [u8; MAX_POST_BOOT_MESSAGE_SIZE] ) -> Result { - uprintln!("secure recieve"); // TODO: send ap error if serialization fails let post_boot_request: PostBootMessageStart = driver.recv_struct()?; @@ -96,7 +92,5 @@ pub fn secure_receive( let message_len = message.message.len(); recv_buf[..message_len].copy_from_slice(message.message.as_slice()); - uprintln!("secure recieve done: {:?}", message.message); - Ok(message_len) } \ No newline at end of file diff --git a/deployment/src/lib.rs b/deployment/src/lib.rs index f58952e..facfdea 100644 --- a/deployment/src/lib.rs +++ b/deployment/src/lib.rs @@ -314,4 +314,39 @@ pub fn force_rerun() { write!(file, "a").unwrap(); println!("cargo:rerun-if-changed=.cargo_build_rs_rerun"); +} + +pub struct LineParser<'a> { + pub data: &'a str, +} + +impl<'a> LineParser<'a> { + pub fn take_until_index(&mut self, index: usize) -> &'a str { + let out = &self.data[..index]; + self.data = &self.data[index..]; + out + } + + pub fn take_token(&mut self) -> Option<&'a str> { + if self.data.len() == 0 { + return None; + } + + let out = self.take_until_index(self.data.find(' ').unwrap_or(self.data.len())); + self.data = self.data.trim_start(); + Some(out) + } + + pub fn take_string(&mut self) -> Option<&'a str> { + if self.data.get(..1)? != "\"" { + return None; + } + + self.data = &self.data[1..]; + + let out = self.take_until_index(self.data.find('"')?); + self.data = &self.data[1..]; + + Some(out) + } } \ No newline at end of file