2929#include < utility>
3030#include < vector>
3131
32- #include < vulkan/vulkan.h>
3332#include " absl/log/log.h"
33+ #include " vulkan/vulkan.h"
3434
3535#include " cuttlefish/common/libs/utils/environment.h"
3636#include " cuttlefish/common/libs/utils/subprocess.h"
@@ -140,8 +140,10 @@ if __name__ == "__m5_main__":
140140
141141void GenerateGem5File (const CuttlefishConfig& config,
142142 const CuttlefishConfig::InstanceSpecific& instance) {
143- // Gem5 specific config, currently users have to change these config locally (without through launch_cvd input flag) to meet their design
144- // TODO: Add these config into launch_cvd input flag or parse from one json file
143+ // Gem5 specific config, currently users have to change these config locally
144+ // (without through launch_cvd input flag) to meet their design
145+ // TODO: Add these config into launch_cvd input flag or parse from one json
146+ // file
145147 std::string cpu_class = " AtomicSimpleCPU" ;
146148 std::string l1_icache_class = " None" ;
147149 std::string l1_dcache_class = " None" ;
@@ -154,8 +156,8 @@ void GenerateGem5File(const CuttlefishConfig& config,
154156 std::string mem_ranks = " None" ;
155157
156158 // start generating starter_fs.py
157- std::string fs_path = instance. gem5_binary_dir () +
158- " /configs/example/arm/starter_fs.py" ;
159+ std::string fs_path =
160+ instance. gem5_binary_dir () + " /configs/example/arm/starter_fs.py" ;
159161 std::ofstream starter_fs_ofstream (fs_path.c_str ());
160162 starter_fs_ofstream << kFsHeader << " \n " ;
161163
@@ -167,33 +169,57 @@ void GenerateGem5File(const CuttlefishConfig& config,
167169
168170 // args
169171 starter_fs_ofstream << " parser = argparse.ArgumentParser(epilog=__doc__)\n " ;
170- starter_fs_ofstream << " parser.add_argument(\" --disk-image\" , action=\" append\" , type=str, default=[])\n " ;
171- starter_fs_ofstream << " parser.add_argument(\" --mem-type\" , default=\" " << mem_type << " \" , choices=ObjectList.mem_list.get_names())\n " ;
172- starter_fs_ofstream << " parser.add_argument(\" --mem-channels\" , type=int, default=" << mem_channels << " )\n " ;
173- starter_fs_ofstream << " parser.add_argument(\" --mem-ranks\" , type=int, default=" << mem_ranks << " )\n " ;
174- starter_fs_ofstream << " parser.add_argument(\" --mem-size\" , action=\" store\" , type=str, default=\" " << instance.memory_mb () << " MB\" )\n " ;
175- starter_fs_ofstream << " parser.add_argument(\" --restore\" , type=str, default=None)\n " ;
172+ starter_fs_ofstream << " parser.add_argument(\" --disk-image\" , "
173+ " action=\" append\" , type=str, default=[])\n " ;
174+ starter_fs_ofstream << " parser.add_argument(\" --mem-type\" , default=\" "
175+ << mem_type
176+ << " \" , choices=ObjectList.mem_list.get_names())\n " ;
177+ starter_fs_ofstream
178+ << " parser.add_argument(\" --mem-channels\" , type=int, default="
179+ << mem_channels << " )\n " ;
180+ starter_fs_ofstream
181+ << " parser.add_argument(\" --mem-ranks\" , type=int, default="
182+ << mem_ranks << " )\n " ;
183+ starter_fs_ofstream << " parser.add_argument(\" --mem-size\" , "
184+ " action=\" store\" , type=str, default=\" "
185+ << instance.memory_mb () << " MB\" )\n " ;
186+ starter_fs_ofstream
187+ << " parser.add_argument(\" --restore\" , type=str, default=None)\n " ;
176188 starter_fs_ofstream << " args = parser.parse_args()\n " ;
177189
178190 // instantiate system
179191 starter_fs_ofstream << " root = Root(full_system=True)\n " ;
180192 starter_fs_ofstream << " mem_mode = " << cpu_class << " .memory_mode()\n " ;
181- starter_fs_ofstream << " has_caches = True if mem_mode == \" timing\" else False\n " ;
182- starter_fs_ofstream << " root.system = devices.SimpleSystem(has_caches, args.mem_size, mem_mode=mem_mode, workload=ArmFsLinux(object_file=SysPaths.binary(\" " << config.assembly_dir () << " /kernel\" )))\n " ;
193+ starter_fs_ofstream
194+ << " has_caches = True if mem_mode == \" timing\" else False\n " ;
195+ starter_fs_ofstream
196+ << " root.system = devices.SimpleSystem(has_caches, args.mem_size, "
197+ " mem_mode=mem_mode, workload=ArmFsLinux(object_file=SysPaths.binary(\" "
198+ << config.assembly_dir () << " /kernel\" )))\n " ;
183199
184200 // mem config and pci instantiate
185201 starter_fs_ofstream << kFsMemPci ;
186202
187203 // system settings
188- starter_fs_ofstream << " root.system.cpu_cluster = [devices.CpuCluster(root.system, " << num_cores << " , \" " << cpu_freq << " \" , \" 1.0V\" , " << cpu_class << " , " << l1_icache_class << " , " << l1_dcache_class << " , " << walk_cache_class << " , " << l2_Cache_class << " )]\n " ;
189- starter_fs_ofstream << " root.system.addCaches(has_caches, last_cache_level=2)\n " ;
190- starter_fs_ofstream << " root.system.realview.setupBootLoader(root.system, SysPaths.binary)\n " ;
191- starter_fs_ofstream << " root.system.workload.dtb_filename = os.path.join(m5.options.outdir, 'system.dtb')\n " ;
192- starter_fs_ofstream << " root.system.generateDtb(root.system.workload.dtb_filename)\n " ;
193- starter_fs_ofstream << " root.system.workload.initrd_filename = \" " << instance.PerInstancePath (" initrd.img" ) << " \"\n " ;
194- starter_fs_ofstream << " root_dir = \" " << StringFromEnv (" HOME" , " ." ) << " \"\n " ;
195-
196- // kernel cmd
204+ starter_fs_ofstream
205+ << " root.system.cpu_cluster = [devices.CpuCluster(root.system, "
206+ << num_cores << " , \" " << cpu_freq << " \" , \" 1.0V\" , " << cpu_class
207+ << " , " << l1_icache_class << " , " << l1_dcache_class << " , "
208+ << walk_cache_class << " , " << l2_Cache_class << " )]\n " ;
209+ starter_fs_ofstream
210+ << " root.system.addCaches(has_caches, last_cache_level=2)\n " ;
211+ starter_fs_ofstream << " root.system.realview.setupBootLoader(root.system, "
212+ " SysPaths.binary)\n " ;
213+ starter_fs_ofstream << " root.system.workload.dtb_filename = "
214+ " os.path.join(m5.options.outdir, 'system.dtb')\n " ;
215+ starter_fs_ofstream
216+ << " root.system.generateDtb(root.system.workload.dtb_filename)\n " ;
217+ starter_fs_ofstream << " root.system.workload.initrd_filename = \" "
218+ << instance.PerInstancePath (" initrd.img" ) << " \"\n " ;
219+ starter_fs_ofstream << " root_dir = \" " << StringFromEnv (" HOME" , " ." )
220+ << " \"\n " ;
221+
222+ // kernel cmd
197223 starter_fs_ofstream << kFsKernelCmd << " \n " ;
198224
199225 // execute main
@@ -204,9 +230,7 @@ void GenerateGem5File(const CuttlefishConfig& config,
204230
205231Gem5Manager::Gem5Manager (Arch arch) : arch_(arch) {}
206232
207- bool Gem5Manager::IsSupported () {
208- return HostSupportsQemuCli ();
209- }
233+ bool Gem5Manager::IsSupported () { return HostSupportsQemuCli (); }
210234
211235Result<std::unordered_map<std::string, std::string>>
212236Gem5Manager::ConfigureGraphics (
@@ -308,9 +332,9 @@ Result<std::vector<MonitorCommand>> Gem5Manager::StartCommands(
308332
309333 // Add debug-flags and debug-file before the script (i.e. starter_fs.py).
310334 // We check the flags are not empty first since they are optional
311- if (!config.gem5_debug_flags ().empty ()) {
335+ if (!config.gem5_debug_flags ().empty ()) {
312336 gem5_cmd.AddParameter (" --debug-flags=" , config.gem5_debug_flags ());
313- if (!instance.gem5_debug_file ().empty ()) {
337+ if (!instance.gem5_debug_file ().empty ()) {
314338 gem5_cmd.AddParameter (" --debug-file=" , instance.gem5_debug_file ());
315339 }
316340 }
@@ -320,11 +344,11 @@ Result<std::vector<MonitorCommand>> Gem5Manager::StartCommands(
320344
321345 // restore checkpoint case
322346 if (!instance.gem5_checkpoint_dir ().empty ()) {
323- gem5_cmd.AddParameter (" --restore=" ,
324- instance.gem5_checkpoint_dir ());
347+ gem5_cmd.AddParameter (" --restore=" , instance.gem5_checkpoint_dir ());
325348 }
326349
327- gem5_cmd.AddParameter (" --mem-size=" , instance.memory_mb () * 1024ULL * 1024ULL );
350+ gem5_cmd.AddParameter (" --mem-size=" ,
351+ instance.memory_mb () * 1024ULL * 1024ULL );
328352 for (const auto & disk : instance.virtual_disk_paths ()) {
329353 gem5_cmd.AddParameter (" --disk-image=" , disk);
330354 }
@@ -336,5 +360,5 @@ Result<std::vector<MonitorCommand>> Gem5Manager::StartCommands(
336360 return commands;
337361}
338362
339- } // namespace vm_manager
340- } // namespace cuttlefish
363+ } // namespace vm_manager
364+ } // namespace cuttlefish
0 commit comments