~vcs-imports/qemu/git

« back to all changes in this revision

Viewing changes to linux-user/vm86.c

  • Committer: blueswir1
  • Date: 2007-09-25 17:30:09 UTC
  • Revision ID: git-v1:eb296a0a03eebd2d73718d31cd0d8a8db0b804de
 Remove the target dependency introduced by previous patch


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3239 c046a42c-6fe2-441c-8c8c-71466251a162

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
    return (((uint8_t *)bitmap)[nr >> 3] >> (nr & 7)) & 1;
40
40
}
41
41
 
42
 
static inline void vm_putw(uint32_t segptr, unsigned int reg16, unsigned int val)
 
42
static inline void vm_putw(uint8_t *segptr, unsigned int reg16, unsigned int val)
43
43
{
44
44
    stw(segptr + (reg16 & 0xffff), val);
45
45
}
46
46
 
47
 
static inline void vm_putl(uint32_t segptr, unsigned int reg16, unsigned int val)
 
47
static inline void vm_putl(uint8_t *segptr, unsigned int reg16, unsigned int val)
48
48
{
49
49
    stl(segptr + (reg16 & 0xffff), val);
50
50
}
51
51
 
52
 
static inline unsigned int vm_getb(uint32_t segptr, unsigned int reg16)
53
 
{
54
 
    return ldub(segptr + (reg16 & 0xffff));
55
 
}
56
 
 
57
 
static inline unsigned int vm_getw(uint32_t segptr, unsigned int reg16)
 
52
static inline unsigned int vm_getw(uint8_t *segptr, unsigned int reg16)
58
53
{
59
54
    return lduw(segptr + (reg16 & 0xffff));
60
55
}
61
56
 
62
 
static inline unsigned int vm_getl(uint32_t segptr, unsigned int reg16)
 
57
static inline unsigned int vm_getl(uint8_t *segptr, unsigned int reg16)
63
58
{
64
59
    return ldl(segptr + (reg16 & 0xffff));
65
60
}
69
64
    TaskState *ts = env->opaque;
70
65
    struct target_vm86plus_struct * target_v86;
71
66
 
72
 
    if (!lock_user_struct(VERIFY_WRITE, target_v86, ts->target_v86, 0))
73
 
        /* FIXME - should return an error */
74
 
        return;
 
67
    lock_user_struct(target_v86, ts->target_v86, 0);
75
68
    /* put the VM86 registers in the userspace register structure */
76
69
    target_v86->regs.eax = tswap32(env->regs[R_EAX]);
77
70
    target_v86->regs.ebx = tswap32(env->regs[R_EBX]);
201
194
static void do_int(CPUX86State *env, int intno)
202
195
{
203
196
    TaskState *ts = env->opaque;
204
 
    uint32_t int_addr, segoffs, ssp;
 
197
    uint32_t *int_ptr, segoffs;
 
198
    uint8_t *ssp;
205
199
    unsigned int sp;
206
200
 
207
201
    if (env->segs[R_CS].selector == TARGET_BIOSSEG)
211
205
    if (intno == 0x21 && is_revectored((env->regs[R_EAX] >> 8) & 0xff,
212
206
                                       &ts->vm86plus.int21_revectored))
213
207
        goto cannot_handle;
214
 
    int_addr = (intno << 2);
215
 
    segoffs = ldl(int_addr);
 
208
    int_ptr = (uint32_t *)(intno << 2);
 
209
    segoffs = tswap32(*int_ptr);
216
210
    if ((segoffs >> 16) == TARGET_BIOSSEG)
217
211
        goto cannot_handle;
218
212
#if defined(DEBUG_VM86)
220
214
            intno, segoffs >> 16, segoffs & 0xffff);
221
215
#endif
222
216
    /* save old state */
223
 
    ssp = env->segs[R_SS].selector << 4;
 
217
    ssp = (uint8_t *)(env->segs[R_SS].selector << 4);
224
218
    sp = env->regs[R_ESP] & 0xffff;
225
219
    vm_putw(ssp, sp - 2, get_vflags(env));
226
220
    vm_putw(ssp, sp - 4, env->segs[R_CS].selector);
263
257
void handle_vm86_fault(CPUX86State *env)
264
258
{
265
259
    TaskState *ts = env->opaque;
266
 
    uint32_t csp, ssp;
 
260
    uint8_t *csp, *pc, *ssp;
267
261
    unsigned int ip, sp, newflags, newip, newcs, opcode, intno;
268
262
    int data32, pref_done;
269
263
 
270
 
    csp = env->segs[R_CS].selector << 4;
 
264
    csp = (uint8_t *)(env->segs[R_CS].selector << 4);
271
265
    ip = env->eip & 0xffff;
 
266
    pc = csp + ip;
272
267
 
273
 
    ssp = env->segs[R_SS].selector << 4;
 
268
    ssp = (uint8_t *)(env->segs[R_SS].selector << 4);
274
269
    sp = env->regs[R_ESP] & 0xffff;
275
270
 
276
271
#if defined(DEBUG_VM86)
277
 
    fprintf(logfile, "VM86 exception %04x:%08x\n",
278
 
            env->segs[R_CS].selector, env->eip);
 
272
    fprintf(logfile, "VM86 exception %04x:%08x %02x %02x\n",
 
273
            env->segs[R_CS].selector, env->eip, pc[0], pc[1]);
279
274
#endif
280
275
 
281
276
    data32 = 0;
282
277
    pref_done = 0;
283
278
    do {
284
 
        opcode = vm_getb(csp, ip);
 
279
        opcode = csp[ip];
285
280
        ADD16(ip, 1);
286
281
        switch (opcode) {
287
282
        case 0x66:      /* 32-bit data */     data32=1; break;
331
326
        VM86_FAULT_RETURN;
332
327
 
333
328
    case 0xcd: /* int */
334
 
        intno = vm_getb(csp, ip);
 
329
        intno = csp[ip];
335
330
        ADD16(ip, 1);
336
331
        env->eip = ip;
337
332
        if (ts->vm86plus.vm86plus.flags & TARGET_vm86dbg_active) {
386
381
    }
387
382
}
388
383
 
389
 
int do_vm86(CPUX86State *env, long subfunction, abi_ulong vm86_addr)
 
384
int do_vm86(CPUX86State *env, long subfunction, target_ulong vm86_addr)
390
385
{
391
386
    TaskState *ts = env->opaque;
392
387
    struct target_vm86plus_struct * target_v86;
398
393
    case TARGET_VM86_GET_IRQ_BITS:
399
394
    case TARGET_VM86_GET_AND_RESET_IRQ:
400
395
        gemu_log("qemu: unsupported vm86 subfunction (%ld)\n", subfunction);
401
 
        ret = -TARGET_EINVAL;
 
396
        ret = -EINVAL;
402
397
        goto out;
403
398
    case TARGET_VM86_PLUS_INSTALL_CHECK:
404
399
        /* NOTE: on old vm86 stuff this will return the error
429
424
    ts->vm86_saved_regs.gs = env->segs[R_GS].selector;
430
425
 
431
426
    ts->target_v86 = vm86_addr;
432
 
    if (!lock_user_struct(VERIFY_READ, target_v86, vm86_addr, 1))
433
 
        return -TARGET_EFAULT;
 
427
    lock_user_struct(target_v86, vm86_addr, 1);
434
428
    /* build vm86 CPU state */
435
429
    ts->v86flags = tswap32(target_v86->regs.eflags);
436
430
    env->eflags = (env->eflags & ~SAFE_MASK) |