Print this page
7127  remove -Wno-missing-braces from Makefile.uts


 108                 if ((got_first_block = read_firstblock(drivenum)) == 0) {
 109                         /* retry */
 110                         got_first_block = read_firstblock(drivenum);
 111                 }
 112 
 113                 if (got_devparams || got_first_block) {
 114                         (void) sprintf((char *)name, "biosdev-0x%x", drivenum);
 115                         devi = ddi_root_node();
 116                         (void) e_ddi_prop_update_byte_array(DDI_DEV_T_NONE,
 117                             devi, (char *)name,
 118                             (uchar_t *)&biosdev_info[drivenum - 0x80],
 119                             sizeof (biosdev_data_t));
 120                 }
 121         }
 122 }
 123 #endif
 124 
 125 static int
 126 bios_check_extension_present(uchar_t drivenum)
 127 {
 128         struct bop_regs rp = {0};
 129         extern struct bootops           *bootops;
 130 
 131         rp.eax.word.ax = 0x4100;
 132         rp.ebx.word.bx = 0x55AA;
 133         rp.edx.word.dx = drivenum;
 134 
 135         /* make sure we have extension support */
 136         BOP_DOINT(bootops, 0x13, &rp);
 137 
 138         if (((rp.eflags & PS_C) != 0) || (rp.ebx.word.bx != 0xAA55)) {
 139                 dprintf(("bios_check_extension_present int13 fn 41 "
 140                     "failed %d bx = %x\n", rp.eflags, rp.ebx.word.bx));
 141                 return (0);
 142         }
 143 
 144         if ((rp.ecx.word.cx & 0x7) == 0) {
 145                 dprintf(("bios_check_extension_present get device parameters "
 146                     "not supported cx = %x\n", rp.ecx.word.cx));
 147                 return (0);
 148         }
 149 
 150         return (1);
 151 }
 152 
 153 static int
 154 get_dev_params(uchar_t drivenum)
 155 {
 156         struct bop_regs rp = {0};
 157         fn48_t   *bufp;
 158         extern struct bootops           *bootops;
 159         int i;
 160         int index;
 161         uchar_t *tmp;
 162 
 163         dprintf(("In get_dev_params\n"));
 164 
 165         bufp = (fn48_t *)BIOS_RES_BUFFER_ADDR;
 166 
 167         /*
 168          * We cannot use bzero here as we're initializing data
 169          * at an address below kernel base.
 170          */
 171         for (i = 0; i < sizeof (*bufp); i++)
 172                 ((uchar_t *)bufp)[i] = 0;
 173 
 174         bufp->buflen = sizeof (*bufp);
 175         rp.eax.word.ax = 0x4800;
 176         rp.edx.byte.dl = drivenum;


 188 
 189         index = drivenum - 0x80;
 190         biosdev_info[index].edd_valid = 1;
 191 
 192         /*
 193          * Some compilers turn a structure copy into a call
 194          * to memcpy.  Since we are copying data below kernel
 195          * base intentionally, and memcpy asserts that's not
 196          * the case, we do the copy manually here.
 197          */
 198         tmp = (uchar_t *)&biosdev_info[index].fn48_dev_params;
 199         for (i = 0; i < sizeof (*bufp); i++)
 200                 tmp[i] = ((uchar_t *)bufp)[i];
 201 
 202         return (1);
 203 }
 204 
 205 static int
 206 drive_present(uchar_t drivenum)
 207 {
 208         struct bop_regs rp = {0};
 209 
 210         rp.eax.byte.ah = 0x8;   /* get params */
 211         rp.edx.byte.dl = drivenum;
 212 
 213         BOP_DOINT(bootops, 0x13, &rp);
 214 
 215         if (((rp.eflags & PS_C) != 0) || rp.eax.byte.ah != 0) {
 216                 dprintf(("drive not present drivenum %x eflag %x ah %x\n",
 217                     drivenum, rp.eflags, rp.eax.byte.ah));
 218                 return (0);
 219         }
 220 
 221         dprintf(("drive-present %x\n", drivenum));
 222         return (1);
 223 }
 224 
 225 static void
 226 reset_disk(uchar_t drivenum)
 227 {
 228         struct bop_regs rp = {0};
 229         int status;
 230 
 231         rp.eax.byte.ah = 0x0;   /* reset disk */
 232         rp.edx.byte.dl = drivenum;
 233 
 234         BOP_DOINT(bootops, 0x13, &rp);
 235 
 236         status = rp.eax.byte.ah;
 237 
 238         if (((rp.eflags & PS_C) != 0) || status != 0)
 239                 dprintf(("Bad disk reset driv %x, status %x\n", drivenum,
 240                     status));
 241 }
 242 
 243 /* Get first block */
 244 static int
 245 read_firstblock(uchar_t drivenum)
 246 {
 247 
 248         struct bop_regs rp = {0};
 249         caddr_t  bufp;
 250         uchar_t status;
 251         int i, index;
 252 
 253 
 254         reset_disk(drivenum);
 255         bufp = (caddr_t)BIOS_RES_BUFFER_ADDR;
 256 
 257 
 258         rp.eax.byte.ah = 0x2;   /* Read disk */
 259         rp.eax.byte.al = 1;     /* nsect */
 260         rp.ecx.byte.ch = 0;     /* cyl & 0xff */
 261         rp.ecx.byte.cl = 1;     /* cyl >> 2 & 0xc0 (sector number) */
 262         rp.edx.byte.dh = 0;     /* head */
 263         rp.edx.byte.dl = drivenum;      /* drivenum */
 264 
 265         /* es:bx is buf address */
 266         rp.ebx.word.bx = (uint16_t)FP_OFF((uint_t)(uintptr_t)bufp);
 267         rp.es = FP_SEG((uint_t)(uintptr_t)bufp);
 268 


 272         if (((rp.eflags & PS_C) != 0) || status != 0) {
 273                 dprintf(("read_firstblock AH not clear %x \n", status));
 274                 return (0);
 275         }
 276 
 277         dprintf(("drivenum %x uid at 0x1b8 is %x\n", drivenum,
 278             *(uint32_t *)(bufp +0x1b8)));
 279 
 280         index = drivenum - 0x80;
 281 
 282         biosdev_info[index].first_block_valid = 1;
 283         for (i = 0; i < 512; i++)
 284                 biosdev_info[index].first_block[i] = *((uchar_t *)bufp + i);
 285 
 286         return (1);
 287 }
 288 
 289 static int
 290 is_eltorito(uchar_t drivenum)
 291 {
 292         struct bop_regs rp = {0};
 293         fn4b_t   *bufp;
 294         extern struct bootops           *bootops;
 295         int i;
 296 
 297         dprintf(("In is_eltorito\n"));
 298 
 299         bufp = (fn4b_t *)BIOS_RES_BUFFER_ADDR;
 300 
 301         /*
 302          * We cannot use bzero here as we're initializing data
 303          * at an address below kernel base.
 304          */
 305         for (i = 0; i < sizeof (*bufp); i++)
 306                 ((uchar_t *)bufp)[i] = 0;
 307 
 308         bufp->pkt_size = sizeof (*bufp);
 309         rp.eax.word.ax = 0x4b01;
 310         rp.edx.byte.dl = drivenum;
 311 
 312         rp.esi.word.si = (uint16_t)FP_OFF((uint_t)(uintptr_t)bufp);


 108                 if ((got_first_block = read_firstblock(drivenum)) == 0) {
 109                         /* retry */
 110                         got_first_block = read_firstblock(drivenum);
 111                 }
 112 
 113                 if (got_devparams || got_first_block) {
 114                         (void) sprintf((char *)name, "biosdev-0x%x", drivenum);
 115                         devi = ddi_root_node();
 116                         (void) e_ddi_prop_update_byte_array(DDI_DEV_T_NONE,
 117                             devi, (char *)name,
 118                             (uchar_t *)&biosdev_info[drivenum - 0x80],
 119                             sizeof (biosdev_data_t));
 120                 }
 121         }
 122 }
 123 #endif
 124 
 125 static int
 126 bios_check_extension_present(uchar_t drivenum)
 127 {
 128         struct bop_regs rp = {{0}};
 129         extern struct bootops           *bootops;
 130 
 131         rp.eax.word.ax = 0x4100;
 132         rp.ebx.word.bx = 0x55AA;
 133         rp.edx.word.dx = drivenum;
 134 
 135         /* make sure we have extension support */
 136         BOP_DOINT(bootops, 0x13, &rp);
 137 
 138         if (((rp.eflags & PS_C) != 0) || (rp.ebx.word.bx != 0xAA55)) {
 139                 dprintf(("bios_check_extension_present int13 fn 41 "
 140                     "failed %d bx = %x\n", rp.eflags, rp.ebx.word.bx));
 141                 return (0);
 142         }
 143 
 144         if ((rp.ecx.word.cx & 0x7) == 0) {
 145                 dprintf(("bios_check_extension_present get device parameters "
 146                     "not supported cx = %x\n", rp.ecx.word.cx));
 147                 return (0);
 148         }
 149 
 150         return (1);
 151 }
 152 
 153 static int
 154 get_dev_params(uchar_t drivenum)
 155 {
 156         struct bop_regs rp = {{0}};
 157         fn48_t   *bufp;
 158         extern struct bootops           *bootops;
 159         int i;
 160         int index;
 161         uchar_t *tmp;
 162 
 163         dprintf(("In get_dev_params\n"));
 164 
 165         bufp = (fn48_t *)BIOS_RES_BUFFER_ADDR;
 166 
 167         /*
 168          * We cannot use bzero here as we're initializing data
 169          * at an address below kernel base.
 170          */
 171         for (i = 0; i < sizeof (*bufp); i++)
 172                 ((uchar_t *)bufp)[i] = 0;
 173 
 174         bufp->buflen = sizeof (*bufp);
 175         rp.eax.word.ax = 0x4800;
 176         rp.edx.byte.dl = drivenum;


 188 
 189         index = drivenum - 0x80;
 190         biosdev_info[index].edd_valid = 1;
 191 
 192         /*
 193          * Some compilers turn a structure copy into a call
 194          * to memcpy.  Since we are copying data below kernel
 195          * base intentionally, and memcpy asserts that's not
 196          * the case, we do the copy manually here.
 197          */
 198         tmp = (uchar_t *)&biosdev_info[index].fn48_dev_params;
 199         for (i = 0; i < sizeof (*bufp); i++)
 200                 tmp[i] = ((uchar_t *)bufp)[i];
 201 
 202         return (1);
 203 }
 204 
 205 static int
 206 drive_present(uchar_t drivenum)
 207 {
 208         struct bop_regs rp = {{0}};
 209 
 210         rp.eax.byte.ah = 0x8;   /* get params */
 211         rp.edx.byte.dl = drivenum;
 212 
 213         BOP_DOINT(bootops, 0x13, &rp);
 214 
 215         if (((rp.eflags & PS_C) != 0) || rp.eax.byte.ah != 0) {
 216                 dprintf(("drive not present drivenum %x eflag %x ah %x\n",
 217                     drivenum, rp.eflags, rp.eax.byte.ah));
 218                 return (0);
 219         }
 220 
 221         dprintf(("drive-present %x\n", drivenum));
 222         return (1);
 223 }
 224 
 225 static void
 226 reset_disk(uchar_t drivenum)
 227 {
 228         struct bop_regs rp = {{0}};
 229         int status;
 230 
 231         rp.eax.byte.ah = 0x0;   /* reset disk */
 232         rp.edx.byte.dl = drivenum;
 233 
 234         BOP_DOINT(bootops, 0x13, &rp);
 235 
 236         status = rp.eax.byte.ah;
 237 
 238         if (((rp.eflags & PS_C) != 0) || status != 0)
 239                 dprintf(("Bad disk reset driv %x, status %x\n", drivenum,
 240                     status));
 241 }
 242 
 243 /* Get first block */
 244 static int
 245 read_firstblock(uchar_t drivenum)
 246 {
 247 
 248         struct bop_regs rp = {{0}};
 249         caddr_t  bufp;
 250         uchar_t status;
 251         int i, index;
 252 
 253 
 254         reset_disk(drivenum);
 255         bufp = (caddr_t)BIOS_RES_BUFFER_ADDR;
 256 
 257 
 258         rp.eax.byte.ah = 0x2;   /* Read disk */
 259         rp.eax.byte.al = 1;     /* nsect */
 260         rp.ecx.byte.ch = 0;     /* cyl & 0xff */
 261         rp.ecx.byte.cl = 1;     /* cyl >> 2 & 0xc0 (sector number) */
 262         rp.edx.byte.dh = 0;     /* head */
 263         rp.edx.byte.dl = drivenum;      /* drivenum */
 264 
 265         /* es:bx is buf address */
 266         rp.ebx.word.bx = (uint16_t)FP_OFF((uint_t)(uintptr_t)bufp);
 267         rp.es = FP_SEG((uint_t)(uintptr_t)bufp);
 268 


 272         if (((rp.eflags & PS_C) != 0) || status != 0) {
 273                 dprintf(("read_firstblock AH not clear %x \n", status));
 274                 return (0);
 275         }
 276 
 277         dprintf(("drivenum %x uid at 0x1b8 is %x\n", drivenum,
 278             *(uint32_t *)(bufp +0x1b8)));
 279 
 280         index = drivenum - 0x80;
 281 
 282         biosdev_info[index].first_block_valid = 1;
 283         for (i = 0; i < 512; i++)
 284                 biosdev_info[index].first_block[i] = *((uchar_t *)bufp + i);
 285 
 286         return (1);
 287 }
 288 
 289 static int
 290 is_eltorito(uchar_t drivenum)
 291 {
 292         struct bop_regs rp = {{0}};
 293         fn4b_t   *bufp;
 294         extern struct bootops           *bootops;
 295         int i;
 296 
 297         dprintf(("In is_eltorito\n"));
 298 
 299         bufp = (fn4b_t *)BIOS_RES_BUFFER_ADDR;
 300 
 301         /*
 302          * We cannot use bzero here as we're initializing data
 303          * at an address below kernel base.
 304          */
 305         for (i = 0; i < sizeof (*bufp); i++)
 306                 ((uchar_t *)bufp)[i] = 0;
 307 
 308         bufp->pkt_size = sizeof (*bufp);
 309         rp.eax.word.ax = 0x4b01;
 310         rp.edx.byte.dl = drivenum;
 311 
 312         rp.esi.word.si = (uint16_t)FP_OFF((uint_t)(uintptr_t)bufp);