4 #include "ui/common/discover-client.h"
6 static const char *device_type_string(enum device_type type)
13 case DEVICE_TYPE_NETWORK:
15 case DEVICE_TYPE_OPTICAL:
19 case DEVICE_TYPE_UNKNOWN:
25 static int print_device_add(struct device *device,
26 void __attribute__((unused)) *arg)
28 struct boot_option *opt;
30 printf("new device:\n");
31 printf("\tid: %s\n", device->id);
32 printf("\ttype: %s\n", device_type_string(device->type));
33 printf("\tname: %s\n", device->name);
34 printf("\tdesc: %s\n", device->description);
35 printf("\ticon: %s\n", device->icon_file);
37 printf("\tboot options:\n");
38 list_for_each_entry(&device->boot_options, opt, list) {
39 printf("\t\tid: %s\n", opt->id);
40 printf("\t\tname: %s\n", opt->name);
41 printf("\t\tdesc: %s\n", opt->description);
42 printf("\t\ticon: %s\n", opt->icon_file);
43 printf("\t\tboot: %s\n", opt->boot_image_file);
44 printf("\t\tinit: %s\n", opt->initrd_file);
45 printf("\t\tdtb: %s\n", opt->dtb_file);
46 printf("\t\targs: %s\n", opt->boot_args);
52 static int print_boot_option_add(struct device *dev,
53 struct boot_option *opt,
54 void __attribute__((unused)) *arg)
56 printf("new boot option (dev: %s):\n", dev->id);
57 printf("\tdev id: %s\n", opt->device_id);
58 printf("\tid: %s\n", opt->id);
59 printf("\tname: %s\n", opt->name);
60 printf("\tdesc: %s\n", opt->description);
61 printf("\ticon: %s\n", opt->icon_file);
62 printf("\tboot: %s\n", opt->boot_image_file);
63 printf("\tinit: %s\n", opt->initrd_file);
64 printf("\targs: %s\n", opt->boot_args);
65 printf("\tdefault:%d\n", opt->is_default);
70 static void print_device_remove(struct device *device,
71 void __attribute__((unused)) *arg)
73 printf("removed device:\n");
74 printf("\tid: %s\n", device->id);
75 printf("\tname: %s\n", device->name);
78 static void print_status(struct status *status,
79 void __attribute__((unused)) *arg)
82 printf("\ttype: %d\n", status->type);
83 printf("\tmessage: %s\n", status->message);
87 static void print_sysinfo(struct system_info *sysinfo,
88 void __attribute__((unused)) *arg)
93 printf("\ttype: %s\n", sysinfo->type);
94 printf("\tid: %s\n", sysinfo->identifier);
96 if (sysinfo->n_interfaces == 0)
97 printf("\tno interfaces.\n");
99 printf("\tinterfaces:\n");
101 for (i = 0; i < sysinfo->n_interfaces; i++) {
102 struct interface_info *if_info = sysinfo->interfaces[i];
103 uint8_t *m = if_info->hwaddr;
105 printf("\t\tname: %s\n", if_info->name);
107 if (if_info->hwaddr_size == 6)
108 printf("\t\tmac: %02x:%02x:%02x:%02x:%02x:%02x\n",
109 m[0], m[1], m[2], m[3], m[4], m[5]);
111 printf("\t\tmac: unknown hwaddr size %d\n",
112 if_info->hwaddr_size);
116 static struct discover_client_ops client_ops = {
117 .device_add = print_device_add,
118 .boot_option_add = print_boot_option_add,
119 .device_remove = print_device_remove,
120 .update_status = print_status,
121 .update_sysinfo = print_sysinfo,
126 struct discover_client *client;
127 struct waitset *waitset;
129 waitset = waitset_create(NULL);
131 client = discover_client_init(waitset, &client_ops, NULL);
138 rc = waiter_poll(waitset);