~ubuntu-branches/ubuntu/oneiric/seabios/oneiric

« back to all changes in this revision

Viewing changes to debian/patches/0034-Allocate-cdemu-buffer-in-low-mem-instead-of-ebda.patch

  • Committer: Bazaar Package Importer
  • Author(s): Serge Hallyn
  • Date: 2010-10-22 11:04:31 UTC
  • Revision ID: james.westby@ubuntu.com-20101022110431-fnfj73ra6xkq623n
Tags: 0.6.0-0ubuntu2
Add all patches which were included in qemu-0.13.0-rc2 (per
commit on Jul 13, 2010).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
From d5d02b6c979da4baeae3a35e7f149881203e6255 Mon Sep 17 00:00:00 2001
 
2
From: Kevin O'Connor <kevin@koconnor.net>
 
3
Date: Sun, 6 Jun 2010 16:18:03 -0400
 
4
Subject: [PATCH 34/54] Allocate cdemu buffer in low mem instead of ebda.
 
5
 
 
6
Using the low memory buffer gives more flexibility with the final
 
7
location of the buffer.
 
8
 
 
9
Don't allocate the buffer at all if no cdrom drives are present.
 
10
---
 
11
 src/biosvar.h |    2 --
 
12
 src/cdrom.c   |   33 ++++++++++++++++++---------------
 
13
 src/post.c    |    2 +-
 
14
 3 files changed, 19 insertions(+), 18 deletions(-)
 
15
 
 
16
diff --git a/src/biosvar.h b/src/biosvar.h
 
17
index ea2d67d..dce35af 100644
 
18
--- a/src/biosvar.h
 
19
+++ b/src/biosvar.h
 
20
@@ -234,8 +234,6 @@ struct extended_bios_data_area_s {
 
21
 
 
22
     // Stack space available for code that needs it.
 
23
     u8 extra_stack[512] __aligned(8);
 
24
-
 
25
-    u8 cdemu_buf[2048 * !!CONFIG_CDROM_EMU];
 
26
 } PACKED;
 
27
 
 
28
 // The initial size and location of EBDA
 
29
diff --git a/src/cdrom.c b/src/cdrom.c
 
30
index f7af425..655ee00 100644
 
31
--- a/src/cdrom.c
 
32
+++ b/src/cdrom.c
 
33
@@ -17,6 +17,9 @@
 
34
  * CD emulation
 
35
  ****************************************************************/
 
36
 
 
37
+struct drive_s *cdemu_drive_gf VAR16VISIBLE;
 
38
+u8 *cdemu_buf_fl VAR16VISIBLE;
 
39
+
 
40
 static int
 
41
 cdemu_read(struct disk_op_s *op)
 
42
 {
 
43
@@ -30,12 +33,12 @@ cdemu_read(struct disk_op_s *op)
 
44
 
 
45
     int count = op->count;
 
46
     op->count = 0;
 
47
-    u8 *cdbuf_far = (void*)offsetof(struct extended_bios_data_area_s, cdemu_buf);
 
48
+    u8 *cdbuf_fl = GET_GLOBAL(cdemu_buf_fl);
 
49
 
 
50
     if (op->lba & 3) {
 
51
         // Partial read of first block.
 
52
         dop.count = 1;
 
53
-        dop.buf_fl = MAKE_FLATPTR(ebda_seg, cdbuf_far);
 
54
+        dop.buf_fl = cdbuf_fl;
 
55
         int ret = process_op(&dop);
 
56
         if (ret)
 
57
             return ret;
 
58
@@ -43,10 +46,7 @@ cdemu_read(struct disk_op_s *op)
 
59
         if (thiscount > count)
 
60
             thiscount = count;
 
61
         count -= thiscount;
 
62
-        memcpy_far(FLATPTR_TO_SEG(op->buf_fl)
 
63
-                   , (void*)FLATPTR_TO_OFFSET(op->buf_fl)
 
64
-                   , ebda_seg, cdbuf_far + (op->lba & 3) * 512
 
65
-                   , thiscount * 512);
 
66
+        memcpy_fl(op->buf_fl, cdbuf_fl + (op->lba & 3) * 512, thiscount * 512);
 
67
         op->buf_fl += thiscount * 512;
 
68
         op->count += thiscount;
 
69
         dop.lba++;
 
70
@@ -69,14 +69,12 @@ cdemu_read(struct disk_op_s *op)
 
71
     if (count) {
 
72
         // Partial read on last block.
 
73
         dop.count = 1;
 
74
-        dop.buf_fl = MAKE_FLATPTR(ebda_seg, cdbuf_far);
 
75
+        dop.buf_fl = cdbuf_fl;
 
76
         int ret = process_op(&dop);
 
77
         if (ret)
 
78
             return ret;
 
79
         u8 thiscount = count;
 
80
-        memcpy_far(FLATPTR_TO_SEG(op->buf_fl)
 
81
-                   , (void*)FLATPTR_TO_OFFSET(op->buf_fl)
 
82
-                   , ebda_seg, cdbuf_far, thiscount * 512);
 
83
+        memcpy_fl(op->buf_fl, cdbuf_fl, thiscount * 512);
 
84
         op->count += thiscount;
 
85
     }
 
86
 
 
87
@@ -106,22 +104,27 @@ process_cdemu_op(struct disk_op_s *op)
 
88
     }
 
89
 }
 
90
 
 
91
-struct drive_s *cdemu_drive_gf VAR16VISIBLE;
 
92
-
 
93
 void
 
94
 cdemu_setup(void)
 
95
 {
 
96
     if (!CONFIG_CDROM_EMU)
 
97
         return;
 
98
+    cdemu_drive_gf = NULL;
 
99
+    cdemu_buf_fl = NULL;
 
100
+    if (!Drives.cdcount)
 
101
+        return;
 
102
 
 
103
     struct drive_s *drive_g = malloc_fseg(sizeof(*drive_g));
 
104
-    if (! drive_g) {
 
105
+    u8 *buf = malloc_low(CDROM_SECTOR_SIZE);
 
106
+    if (!drive_g || !buf) {
 
107
         warn_noalloc();
 
108
-        cdemu_drive_gf = NULL;
 
109
+        free(drive_g);
 
110
+        free(buf);
 
111
         return;
 
112
     }
 
113
-    memset(drive_g, 0, sizeof(*drive_g));
 
114
     cdemu_drive_gf = drive_g;
 
115
+    cdemu_buf_fl = buf;
 
116
+    memset(drive_g, 0, sizeof(*drive_g));
 
117
     drive_g->type = DTYPE_CDEMU;
 
118
     drive_g->blksize = DISK_SECTOR_SIZE;
 
119
     drive_g->sectors = (u64)-1;
 
120
diff --git a/src/post.c b/src/post.c
 
121
index 25535e2..fc7acc5 100644
 
122
--- a/src/post.c
 
123
+++ b/src/post.c
 
124
@@ -217,7 +217,6 @@ post(void)
 
125
     // Initialize internal tables
 
126
     boot_setup();
 
127
     drive_setup();
 
128
-    cdemu_setup();
 
129
 
 
130
     // Start hardware initialization (if optionrom threading)
 
131
     if (CONFIG_THREADS && CONFIG_THREAD_OPTIONROMS)
 
132
@@ -250,6 +249,7 @@ post(void)
 
133
     boot_prep();
 
134
 
 
135
     // Finalize data structures before boot
 
136
+    cdemu_setup();
 
137
     pmm_finalize();
 
138
     malloc_finalize();
 
139
     memmap_finalize();
 
140
-- 
 
141
1.7.1
 
142